From b60f3408700c850bec15b0735f3955213b384b8a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 25 May 2011 10:35:17 -0400 Subject: [PATCH] re PR c++/48935 ([C++0x] Name lookup error at enum class) PR c++/48935 * parser.c (cp_parser_constructor_declarator_p): Don't check constructor_name_p for enums. (cp_parser_diagnose_invalid_type_name): Correct error message. From-SVN: r174205 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 4 ++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/enum16.C | 6 ++++++ gcc/testsuite/g++.dg/parse/error15.C | 6 +++--- 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/enum16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3de0639bd60..a34926730ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2011-05-25 Jason Merrill + PR c++/48935 + * parser.c (cp_parser_constructor_declarator_p): Don't check + constructor_name_p for enums. + (cp_parser_diagnose_invalid_type_name): Correct error message. + PR c++/45418 * init.c (perform_member_init): Handle list-initialization of array of non-trivial class type. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3493e44496d..db2cb96c613 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2534,7 +2534,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, "%qT is a dependent scope", parser->scope, id, parser->scope); else if (TYPE_P (parser->scope)) - error_at (location, "%qE in class %qT does not name a type", + error_at (location, "%qE in %q#T does not name a type", id, parser->scope); else gcc_unreachable (); @@ -19589,7 +19589,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) /* If we have a class scope, this is easy; DR 147 says that S::S always names the constructor, and no other qualified name could. */ if (constructor_p && nested_name_specifier - && TYPE_P (nested_name_specifier)) + && CLASS_TYPE_P (nested_name_specifier)) { tree id = cp_parser_unqualified_id (parser, /*template_keyword_p=*/false, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e6327e0bad3..bc2eac9529a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-05-25 Jason Merrill + * g++.dg/cpp0x/enum16.C: New. + * g++.dg/parse/error15.C: Adjust. + * g++.dg/cpp0x/initlist50.C: New. * g++.dg/cpp0x/lambda/lambda-conv5.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/enum16.C b/gcc/testsuite/g++.dg/cpp0x/enum16.C new file mode 100644 index 00000000000..ebb48688b18 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum16.C @@ -0,0 +1,6 @@ +// PR c++/48935 +// { dg-options -std=c++0x } + +enum class ENUM { a }; + +ENUM::Type func() { return ENUM::a; } // { dg-error "does not name a type" } diff --git a/gcc/testsuite/g++.dg/parse/error15.C b/gcc/testsuite/g++.dg/parse/error15.C index 2352193bcd6..607a1dbb86c 100644 --- a/gcc/testsuite/g++.dg/parse/error15.C +++ b/gcc/testsuite/g++.dg/parse/error15.C @@ -12,7 +12,7 @@ namespace N N::A f2; // { dg-error "1:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "1:'INVALID' in namespace 'N' does not name a type" } -N::C::INVALID f4; // { dg-error "1:'INVALID' in class 'N::C' does not name a type" } +N::C::INVALID f4; // { dg-error "1:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "1:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "13:invalid use of template-name 'N::A' without an argument list" "13" { target *-*-* } 17 } @@ -22,7 +22,7 @@ struct B { N::A f2; // { dg-error "3:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" } - N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" } + N::C::INVALID f4; // { dg-error "3:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 27 } @@ -33,7 +33,7 @@ struct C { N::A f2; // { dg-error "3:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" } - N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" } + N::C::INVALID f4; // { dg-error "3:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "15:invalid use of template-name 'N::A' without an argument list" } }; -- 2.30.2