re PR c++/18757 (ICE (on invalid) in get_innermost_template_args)

gcc/cp/ChangeLog:
PR c++/18757
* parser.c (cp_parser_template_id): Don't create a CPP_TEMPLATE_ID
if parsing failed.
gcc/testsuite/ChangeLog:
* g++.dg/parse/typename5.C: Adjust for new error.
* g++.dg/parse/typename7.C: New.

From-SVN: r91935
This commit is contained in:
Alexandre Oliva 2004-12-09 12:33:09 +00:00 committed by Alexandre Oliva
parent d16b59fa0c
commit 354e22e18a
5 changed files with 46 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2004-12-09 Alexandre Oliva <aoliva@redhat.com>
PR c++/18757
* parser.c (cp_parser_template_id): Don't create a CPP_TEMPLATE_ID
if parsing failed.
2004-12-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18073

View File

@ -8416,8 +8416,9 @@ cp_parser_template_id (cp_parser *parser,
should we re-parse the token stream, we will not have to repeat
the effort required to do the parse, nor will we issue duplicate
error messages about problems during instantiation of the
template. */
if (start_of_id)
template. Do so only if parsing succeeded, otherwise we may
silently accept template arguments with syntax errors. */
if (start_of_id && !cp_parser_error_occurred (parser))
{
cp_token *token = cp_lexer_token_at (parser->lexer, start_of_id);

View File

@ -1,3 +1,8 @@
2004-12-09 Alexandre Oliva <aoliva@redhat.com>
* g++.dg/parse/typename5.C: Adjust for new error.
* g++.dg/parse/typename7.C: New.
2004-12-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18073

View File

@ -8,5 +8,5 @@ template <typename> struct A {};
template <typename> struct B
{
typedef A<typename X::Y> C; // { dg-error "declared|invalid|no type" }
typedef A<typename X::Y> C; // { dg-error "declared|invalid|no type|expected" }
};

View File

@ -0,0 +1,31 @@
// { dg-do compile }
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> and
// Alexandre Oliva <aoliva@redhat.com>
// PR c++/18757: ICE in get_innermost_template_args
struct A
{
template<typename> void foo(int);
template<typename T> void bar(T t) {
this->foo<typename T>(t); } // { dg-error "expected" }
template<typename T> void bad(T t) {
foo<typename T>(t); } // { dg-error "expected" }
};
template <typename T>
struct B
{
void bar(T t) {
A().bar<typename T>(t); } // { dg-error "expected" }
void bad(T t) {
B<typename T>::bar(t); } // { dg-error "invalid|not a template" }
};
void baz()
{
A().bar(0);
A().bad(0);
B<int>().bar(0);
}