https://bugs.llvm.org/show_bug.cgi?id=39426

            Bug ID: 39426
           Summary: accept ill-formed typedef with not fully defined enum
           Product: clang
           Version: 7.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: dushis...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

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.

according to
https://stackoverflow.com/questions/52971159/strong-enum-typedef-clang-bug-or-c11-standard-uncertainty/52973516#52973516


[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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to