This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR c++/60994 gcc does not recognize hidden/shadowed enumeration as valid nested-name-specifier


Hello,

gcc version 4.10.0 20140428 (experimental) (GCC)

Compiling (with c++ -c -std=c++11 b.cc) the following program

enum struct A
{
  n = 3
};

int
foo()
{
  int A;
  return A::n;
}

results in the error:

b.cc: In function 'int foo()':
b.cc:10:10: error: 'A' is not a class, namespace, or enumeration
   return A::n;
          ^
According to the C++11 Standard, [basic.lookup.qual] #1

"If a :: scope resolution operator in a nested-name-specifier is not
preceded by a decltype-specifier, lookup of the name preceding that ::
considers only namespaces, types, and templates whose specializations
are types."

GCC ought not to resolve "A" to the local variable, but to the
enumeration type. This is very similar to the example in the standard

struct A
{
  static int n;
};

int
foo()
{
  int A;
  return A::n;
}

which is compiled correctly by GCC, though.


Please, review this proposed fix. Bootstrapped/regtested for C/C++ on
x86_64-unknown-linux-gnu.

~chill

Attachment: scoped-enum-nested-name-specifier.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]