[llvm-bugs] [Bug 46072] access to scope enum through variable not possible
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 29 15:44:33 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46072
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
This is subtle, but I believe Clang's behavior is correct. This example:
class a {
enum test {
f
};
};
introduces 'f' as a member of class 'a'. In general, the members of an unscoped
enumeration become members of the enclosing scope. However, this example:
class aa {
enum class test {
f
};
};
does *not* introduce 'f' as a member of class 'aa', only of 'aa::test'.
The syntax 'a.X::b' can only be used to name members of 'a'. So it's valid to
use 'a_.test::f' to name the 'f' member of 'a_', but it's not valid to use
'aa_.test::f', because 'aa::test::f' is not a member of 'aa'.
Here's an analogous situation not involving enumerator name injection:
struct A {
static const int f = 1;
};
struct B {
using test = A;
};
int n = B().test::f; // error, 'A::f' is not a member of 'B'
struct C : A {
using test = A;
};
int m = C().test::f; // OK, 'A::f' is a member of 'C'
--
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/20200529/2149e8b9/attachment.html>
More information about the llvm-bugs
mailing list