-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
accepts-invalidbugzillaIssues migrated from bugzillaIssues migrated from bugzillac++11clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
Bugzilla Link | 39426 |
Version | 7.0 |
OS | All |
CC | @DougGregor |
Extended Description
clang version 7.0.0 (tags/RELEASE_700/final) compiles such code without
any error:
$ cat > test.cpp
typedef enum FooEnum : int FooEnum;
enum FooEnum : int { A = 1, B };
$ clang++ -c -pedantic -std=c++11 test.cpp
$
while gcc (8.2.1) rejects it.
[dcl.typedef]/1
The typedef specifier shall not be combined in a decl-specifier-seq with any other kind of specifier except a defining-type-specifier,[...]
[dcl.type]/1
defining-type-specifier:
type-specifier
class-specifier
enum-specifier
[dcl.enum]/1
enum-specifier:
enum-head { enumerator-listopt }
enum-head { enumerator-list , }
So the code bellow is legal c++:
typedef enum FooEnum : int { A = 1, B } FooEnum;
but this one is not legal c++:
typedef enum FooEnum : int FooEnum;
Because enum FooEnum:int is not a defining-type-specifier
.
Metadata
Metadata
Assignees
Labels
accepts-invalidbugzillaIssues migrated from bugzillaIssues migrated from bugzillac++11clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"