<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - accept ill-formed typedef with not fully defined enum"
href="https://bugs.llvm.org/show_bug.cgi?id=39426">39426</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>accept ill-formed typedef with not fully defined enum
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dushistov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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
<a href="https://stackoverflow.com/questions/52971159/strong-enum-typedef-clang-bug-or-c11-standard-uncertainty/52973516#52973516">https://stackoverflow.com/questions/52971159/strong-enum-typedef-clang-bug-or-c11-standard-uncertainty/52973516#52973516</a>
[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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>