[cfe-commits] r58916 - in /cfe/trunk: include/clang/AST/DeclBase.h include/clang/AST/DeclCXX.h include/clang/Basic/DiagnosticKinds.def lib/Sema/Sema.cpp lib/Sema/Sema.h lib/Sema/SemaCXXScopeSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp test/SemaCXX/nested-name-spec.cpp
dgregor at apple.com
dgregor at apple.com
Wed Nov 19 13:59:20 PST 2008
On Wed, November 19, 2008 11:59 am, argiris kirtzidis wrote:
> Douglas Gregor wrote:
>>
>> That isn't the way I read C++03 3.4.3p1. The second sentence says:
>>
>> "During the lookup for a name preceding the::scope resolution
>> operator, object, function, and enumerator names are ignored."
>>
>> An enumeration name is not an operator, object, function, or
>> enumerator name, so we shouldn't be ignoring them.
>
> I think you are right but let's be absolutely certain about this; you
> brought up GCC as the compiler that gets it right, but GCC also ignores
> enumerations:
>
> namespace A {
> int x;
> }
>
> void f() {
> enum A {};
> A::x = 0;
> }
>
> GCC compiles it without errors.
Hrm, you're right. That's a bit disturbing. This, of course, is the fun one:
#include <iostream>
namespace A {
int x = 17;
}
int main() {
enum A { x = 42 };
std::cout << A::x << '\n';
}
With GCC 4.4 (which supports scoped enums in its C++0x mode), we get "17"
in C++98 mode and "42" in C++0x mode. I'm pretty certain the code is
ill-formed in C++98/03, but it's time for me to go ask in a larger forum.
- Doug
More information about the cfe-commits
mailing list