Commit 354e22e1 by Alexandre Oliva Committed by Alexandre Oliva

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
parent d16b59fa
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
......
......@@ -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);
......
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
......
......@@ -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" }
};
// { 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment