Details
Diff Detail
Event Timeline
This patch does not seem to be correct. Using an enumerator as a nested-name-specifier is a C++11 extension. MSVC enables C++11 by default. The only bug I can see here is that our diagnostic is misworded: in C++11, we should say "%0 is not a class, namespace, or enumeration" (remove the word "scoped"), and in C++98, we should say "%0 is not a class or namespace"
MSVC supported using an enumerator as a nested-name-specifier for a long time. For instance, VS2005 compiled the code:
enum ABCD { A, B, C }; int main() { return ABCD::A; }
without errors:
C:\Tools>cl tt.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. tt.cpp tt.cpp(4) : warning C4482: nonstandard extension used: enum 'ABCD' used in qualified name Microsoft (R) Incremental Linker Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. /out:tt.exe tt.obj C:\Tools>
VS2010 compiles this code without warnings by default. It is reasonable to accept this code in Microsoft mode without warnings by default, isn't it?
However, complaining on using extension make the patch simpler, will update it.
LGTM with a couple of tweaks. (We should also fix the "is not a class, namespace, or scoped enumeration" diagnostic to remove the word "scoped", feel free to go ahead and commit a patch for that.)
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
1232 ↗ | (On Diff #18311) | Remove the "unscoped" here. C++98 didn't have scoped enumerations, and in any case, this diagnostic is not specific to unscoped enumerations. |
lib/Sema/SemaCXXScopeSpec.cpp | ||
286–287 | s/may be used in extended syntax/is accepted as an extension/ |
s/may be used in extended syntax/is accepted as an extension/