re PR c++/34271 (ICE in invalid initialization of static template member)

PR c++/34271
	* semantics.c (finish_decltype_type): For SCOPE_REF issue an
	error instead of assertion failure.
	* parser.c (cp_parser_decltype): If closing paren is not found,
	return error_mark_node.

	* g++.dg/cpp0x/decltype9.C: New test.
	* g++.dg/cpp0x/decltype10.C: New test.

From-SVN: r130619
This commit is contained in:
Jakub Jelinek 2007-12-05 11:45:21 +01:00 committed by Jakub Jelinek
parent c0742514bd
commit 91929b4dee
6 changed files with 41 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2007-12-05 Jakub Jelinek <jakub@redhat.com>
PR c++/34271
* semantics.c (finish_decltype_type): For SCOPE_REF issue an
error instead of assertion failure.
* parser.c (cp_parser_decltype): If closing paren is not found,
return error_mark_node.
2007-12-04 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34101

View file

@ -8602,8 +8602,11 @@ cp_parser_decltype (cp_parser *parser)
/* Parse to the closing `)'. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"))
cp_parser_skip_to_closing_parenthesis (parser, true, false,
/*consume_paren=*/true);
{
cp_parser_skip_to_closing_parenthesis (parser, true, false,
/*consume_paren=*/true);
return error_mark_node;
}
return finish_decltype_type (expr, id_expression_or_member_access_p);
}

View file

@ -4164,7 +4164,8 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p)
break;
default:
gcc_assert (TYPE_P (expr) || DECL_P (expr));
gcc_assert (TYPE_P (expr) || DECL_P (expr)
|| TREE_CODE (expr) == SCOPE_REF);
error ("argument to decltype must be an expression");
return error_mark_node;
}

View file

@ -1,3 +1,9 @@
2007-12-05 Jakub Jelinek <jakub@redhat.com>
PR c++/34271
* g++.dg/cpp0x/decltype9.C: New test.
* g++.dg/cpp0x/decltype10.C: New test.
2007-12-05 Samuel Tardieu <sam@rfc1149.net>
PR ada/21489

View file

@ -0,0 +1,10 @@
// PR c++/34271
// { dg-do compile }
// { dg-options "-std=c++0x" }
template<int> struct A
{
static int i;
};
template<int N> int A<N>::i(decltype (A::i; // { dg-error "expected primary-expression before" }

View file

@ -0,0 +1,10 @@
// PR c++/34271
// { dg-do compile }
// { dg-options "-std=c++0x" }
template<int> struct A
{
static int i;
};
template<int N> int A<N>::i(decltype (A::i)); // { dg-error "member function|must be an expression" }