[llvm-bugs] [Bug 39426] New: accept ill-formed typedef with not fully defined enum
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 24 13:01:30 PDT 2018
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: unassignedclangbugs at nondot.org
Reporter: dushistov at gmail.com
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181024/2373f91a/attachment.html>
More information about the llvm-bugs
mailing list