re PR c++/47198 ([C++0x] ICE: tree check: expected var_decl or function_decl, have template_decl in check_bases_and_members, at cp/class.c:4654 on invalid code)

PR c++/47198
	* parser.c (cp_parser_single_declaration): Just return if
	cp_parser_parse_and_diagnose_invalid_type_name complained.

From-SVN: r170847
This commit is contained in:
Jason Merrill 2011-03-10 10:21:00 -05:00 committed by Jason Merrill
parent 392426866e
commit 4999d9b013
9 changed files with 43 additions and 12 deletions

View file

@ -1,3 +1,9 @@
2011-03-10 Jason Merrill <jason@redhat.com>
PR c++/47198
* parser.c (cp_parser_single_declaration): Just return if
cp_parser_parse_and_diagnose_invalid_type_name complained.
2011-03-09 Jason Merrill <jason@redhat.com>
PR c++/44629

View file

@ -20102,8 +20102,15 @@ cp_parser_single_declaration (cp_parser* parser,
}
/* Complain about missing 'typename' or other invalid type names. */
if (!decl_specifiers.any_type_specifiers_p)
cp_parser_parse_and_diagnose_invalid_type_name (parser);
if (!decl_specifiers.any_type_specifiers_p
&& cp_parser_parse_and_diagnose_invalid_type_name (parser))
{
/* cp_parser_parse_and_diagnose_invalid_type_name calls
cp_parser_skip_to_end_of_block_or_statement, so don't try to parse
the rest of this declaration. */
decl = error_mark_node;
goto out;
}
/* If it's not a template class, try for a template function. If
the next token is a `;', then this declaration does not declare
@ -20137,6 +20144,13 @@ cp_parser_single_declaration (cp_parser* parser,
}
}
/* Look for a trailing `;' after the declaration. */
if (!function_definition_p
&& (decl == error_mark_node
|| !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON)))
cp_parser_skip_to_end_of_block_or_statement (parser);
out:
pop_deferring_access_checks ();
/* Clear any current qualification; whatever comes next is the start
@ -20144,11 +20158,6 @@ cp_parser_single_declaration (cp_parser* parser,
parser->scope = NULL_TREE;
parser->qualifying_scope = NULL_TREE;
parser->object_scope = NULL_TREE;
/* Look for a trailing `;' after the declaration. */
if (!function_definition_p
&& (decl == error_mark_node
|| !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON)))
cp_parser_skip_to_end_of_block_or_statement (parser);
return decl;
}

View file

@ -1,3 +1,12 @@
2011-03-10 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/syntax-err1.C: New.
* g++.dg/parse/error36.C: Adjust expected errors.
* g++.old-deja/g++.pt/ctor2.C: Likewise.
* g++.old-deja/g++.pt/typename3.C: Likewise.
* g++.old-deja/g++.pt/typename4.C: Likewise.
* g++.old-deja/g++.pt/typename6.C: Likewise.
2011-03-09 Jason Merrill <jason@redhat.com>
* g++.dg/template/nontype22.C: New.

View file

@ -0,0 +1,8 @@
// PR c++/47198
// { dg-options -std=c++0x }
struct S
{
template < int > sometype foo (); // { dg-error "sometype. does not name a type" }
S () = default;
};

View file

@ -30,4 +30,3 @@ void g(const A<T>::type &t); // { dg-error "typename" }
// PR c++/18451
template <class T> A<T>::B A<T>::b; // { dg-error "typename" }
// { dg-error "expected" "" { target *-*-* } 32 }

View file

@ -10,4 +10,4 @@ struct A {
template <class T>
A<T>::A<T>() // { dg-error "constructor|qualified name" }
{
} // { dg-error "end of input" }
}

View file

@ -18,4 +18,4 @@ struct B : public A<U>
template <class U>
B<U>::A_Type B<U>::Func() { // { dg-error "typename" } implicit typename
} // { dg-error "expected" }
}

View file

@ -23,4 +23,4 @@ struct C : public B<U>
template <class U>
C<U>::A_Type C<U>::Func() { // { dg-error "typename" } implicit typename
} // { dg-error "expected" }
}

View file

@ -17,4 +17,4 @@ struct B : public A<U>
template <class U>
A<U>::A_Type B<U>::Func() // { dg-error "typename" } function
{
} // { dg-error "expected" }
}