[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

argiris kirtzidis akyrtzi at gmail.com
Wed Nov 19 11:59:45 PST 2008

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 

namespace A {
  int x;

void f() {
  enum A {};
  A::x = 0;

GCC compiles it without errors.

>>> In C++0x, we *can* do qualified name lookup into an enumeration, so 
>>> the example fails because we can't bind an 'int' to a reference to a 
>>> 'float'.
>> I was under the impression that this happens to 'enum class' which is 
>> different from 'enum'. You can do qualified name lookup even with 
>> simple enums (not 'enum class') ?
> Yes. The C++0x 3.4.3p1 says:
>     "The name of a class, concept map (but not a concept), or 
> namespace member or enumerator can be referred
> to after the :: scope resolution operator (5.1) applied to a 
> nested-name-speciļ¬er that nominates its class,
> concept map, namespace, or enumeration."
> Note that it says "enumeration" not "scoped enumeration". See also 
> C++03 7.2p11, which gives an example of a qualified-id that refers to 
> an enumerator of an unscoped enumeration type.

Nice! That's good to know.


More information about the cfe-commits mailing list