diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/error15.C | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/error51.C | 13 |
5 files changed, 54 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e4996fb..b9bdf3a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-03 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/14283 + * parser.c (cp_parser_diagnose_invalid_type_name): Improve error + messages for template types and fix column numbers. + 2013-05-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/57132 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2239a07..f87974e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2872,8 +2872,16 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, else if (parser->scope != error_mark_node) { if (TREE_CODE (parser->scope) == NAMESPACE_DECL) - error_at (location, "%qE in namespace %qE does not name a type", - id, parser->scope); + { + if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) + error_at (location_of (id), + "%qE in namespace %qE does not name a template type", + id, parser->scope); + else + error_at (location_of (id), + "%qE in namespace %qE does not name a type", + id, parser->scope); + } else if (CLASS_TYPE_P (parser->scope) && constructor_name_p (id, parser->scope)) { @@ -2890,8 +2898,16 @@ 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 %q#T does not name a type", - id, parser->scope); + { + if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) + error_at (location_of (id), + "%qE in %q#T does not name a template type", + id, parser->scope); + else + error_at (location_of (id), + "%qE in %q#T does not name a type", + id, parser->scope); + } else gcc_unreachable (); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c8dc189..88ac420 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-05-03 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/14283 + * g++.dg/parse/error51.C: New. + * g++.dg/parse/error15.C: Adjust column numbers. + 2013-05-02 Tobias Burnus <burnus@net-b.de> PR fortran/57142 diff --git a/gcc/testsuite/g++.dg/parse/error15.C b/gcc/testsuite/g++.dg/parse/error15.C index 607a1db..deba54a 100644 --- a/gcc/testsuite/g++.dg/parse/error15.C +++ b/gcc/testsuite/g++.dg/parse/error15.C @@ -11,9 +11,9 @@ 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 'struct N::C' does not name a type" } -N::K f6; // { dg-error "1:'K' in namespace 'N' does not name a type" } +N::INVALID f3; // { dg-error "4:'INVALID' in namespace 'N' does not name a type" } +N::C::INVALID f4; // { dg-error "7:'INVALID' in 'struct N::C' does not name a type" } +N::K f6; // { dg-error "4:'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 } // { dg-error "17:invalid type in declaration before ';' token" "17" { target *-*-* } 17 } @@ -21,9 +21,9 @@ typename N::A f7; 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 'struct N::C' does not name a type" } - N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } + N::INVALID f3; // { dg-error "6:'INVALID' in namespace 'N' does not name a type" } + N::C::INVALID f4; // { dg-error "9:'INVALID' in 'struct N::C' does not name a type" } + N::K f6; // { dg-error "6:'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 } }; @@ -32,9 +32,9 @@ template <int> 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 'struct N::C' does not name a type" } - N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } + N::INVALID f3; // { dg-error "6:'INVALID' in namespace 'N' does not name a type" } + N::C::INVALID f4; // { dg-error "9:'INVALID' in 'struct N::C' does not name a type" } + N::K f6; // { dg-error "6:'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" } }; diff --git a/gcc/testsuite/g++.dg/parse/error51.C b/gcc/testsuite/g++.dg/parse/error51.C new file mode 100644 index 0000000..e599304 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error51.C @@ -0,0 +1,13 @@ +// PR c++/14283 + +struct A +{}; + +namespace N +{} + +template <typename> struct C +{ + typedef A::template INVALID<void> X0; // { dg-error "23:'INVALID' in 'struct A' does not name a template type" } + typedef N::template INVALID<void> X1; // { dg-error "23:'INVALID' in namespace 'N' does not name a template type" } +}; |