Open haoxintu opened 4 years ago
$cat bug.cc class A1 {}; class A2 {}; class A3 {}; union : A1, A2, A3 {} u;
$clang++ -c bug.cc bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ 3 errors generated.
In GCC $g++ -c bug.cc bug.cc:4:17: error: derived union ‘’ invalid 4 | union : A1, A2, A3 {} u; | ^~
I doubt that how clang deal with this case. I guess there are two situations:
According to the marking "~~" in error messages, I guess clang might have the first issue?
Also, I have tested it in almost all clang versions, they all have this issue.
We could diagnose this better; it'd be preferable to produce a single diagnostic perhaps pointing to the : token and underlining both the union and the base-specifiers.
:
union
(But this isn't a bug, per se.)
Extended Description
$cat bug.cc class A1 {}; class A2 {}; class A3 {}; union : A1, A2, A3 {} u;
$clang++ -c bug.cc bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ bug.cc:4:1: error: unions cannot have base classes union : A1, A2, A3 {} u; ^ ~~ 3 errors generated.
In GCC $g++ -c bug.cc bug.cc:4:17: error: derived union ‘’ invalid
4 | union : A1, A2, A3 {} u;
| ^~
I doubt that how clang deal with this case. I guess there are two situations:
According to the marking "~~" in error messages, I guess clang might have the first issue?
Also, I have tested it in almost all clang versions, they all have this issue.