Closed be579e8c-b74b-475b-a126-3b8cefdd833c closed 12 months ago
FWIW with inline variables:
static constexpr auto B = A::B;
Is safe and does the right thing.
While I would like "using A::B" to work, I would rather warn on this until this is allowed by the standard.
Of couse we cannot straight out forbid referring to a unscoped enumerator because it needs still to be allowed as a member declaration if the NNS is a class.
I sent this issue to WMM twice with a year of distance between each iteration, but he did not respond -.- So there is no DR# yet.
Hello Mike,
7.3.3p7 says
A /using-declaration/ shall not name a scoped enumerator.
Presumably, this is intended to forbid the following case too.
enum A { B }; void f() { using A::B; }
However, A::B is an unscoped enumerator according to 7.2p2. It should probably forbid the nested-name-specifier of the using-declaration to name an enumeration, instead.
Thanks, Johannes.
[namespace.udecl]p7 is clear that we should diagnose this, but it's not obvious why. The functionality is useful and doesn't have any obvious semantic issues.
Johannes: Do you have a DR# for this? I couldn't find it in the issues list, and I'd like to suggest a different resolution :)
@llvm/issue-subscribers-clang-frontend
Author: None (be579e8c-b74b-475b-a126-3b8cefdd833c)
There are both valid and accepted by all the implementations I checked.
Extended Description
Clang is supposed to reject the below, but doesn't
Although the spec (N3225) doesn't say so currently (DR already filed), clang should presumably also reject referring to an unscoped enumerator in a using declaration:
I think best may be to forbid the using declaration of having a nested name specifier referring to an enumeration.