re PR c++/14283 (Diagnostic for invalid template-id could be improved)

/cp
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.

/testsuite
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.

From-SVN: r198572
This commit is contained in:
Paolo Carlini 2013-05-03 09:02:15 +00:00 committed by Paolo Carlini
parent 79d944d296
commit c067d9fe14
5 changed files with 54 additions and 13 deletions

View File

@ -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

View File

@ -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 ();
}

View File

@ -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

View File

@ -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" }
};

View File

@ -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" }
};