| Issue |
113844
|
| Summary |
C++: Accessing enumerators from a scoped member enum through operator `.` triggers an error
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
TheCalligrapher
|
Here's the code sample that demonsrates the problem
```
struct S
{
enum T { A };
enum class U { B };
};
int main()
{
S s;
S::A; // OK
S::T::A; // OK
S::U::B; // OK
s.A; // OK
s.T::A; // OK
s.U::B; // Error???
}
```
All six lines that refer to enumerators from enums declared inside class `S` are perfectly valid. However, Clang issues an error
```
error: 'S::U::B' is not a member of class 'S'
17 | s.U::B; // Error???
| ~~~^
```
for last one (i.e. `s.U::B`). Why?
What makes it especially weird is that Clang has no problems with the qualified name in the `s.T::A` line, i.e. it does allow one to optionally use qualified name to access enumerators from a "classic" unscoped enum (a possibility introduced by C++11). However, for some unknown reason Clang rejects a similar attempt to access an enumerator from a _scoped_ enum.
GCC and MSVC++ have no issues with such code.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs