Commit 6bd32cb2 by Paolo Carlini Committed by Paolo Carlini

re PR c++/58535 (ICE with virtual template function)

/cp
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58535
	* parser.c (cp_parser_function_specifier_opt): Upon error about
	virtual templates don't set ds_virtual.
	(finish_fully_implicit_template): Reject virtual implicit templates.

/testsuite
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58535
	* g++.dg/parse/crash65.C: New.
	* g++.dg/cpp1y/pr58535.C: Likewise.

From-SVN: r203123
parent 3d9c733e
2013-10-02 Paolo Carlini <paolo.carlini@oracle.com> 2013-10-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58535
* parser.c (cp_parser_function_specifier_opt): Upon error about
virtual templates don't set ds_virtual.
(finish_fully_implicit_template): Reject virtual implicit templates.
2013-10-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58565 PR c++/58565
* semantics.c (potential_constant_expression_1): Handle LABEL_EXPR. * semantics.c (potential_constant_expression_1): Handle LABEL_EXPR.
......
...@@ -11460,6 +11460,7 @@ cp_parser_function_specifier_opt (cp_parser* parser, ...@@ -11460,6 +11460,7 @@ cp_parser_function_specifier_opt (cp_parser* parser,
A member function template shall not be virtual. */ A member function template shall not be virtual. */
if (PROCESSING_REAL_TEMPLATE_DECL_P ()) if (PROCESSING_REAL_TEMPLATE_DECL_P ())
error_at (token->location, "templates may not be %<virtual%>"); error_at (token->location, "templates may not be %<virtual%>");
else
set_and_check_decl_spec_loc (decl_specs, ds_virtual, token); set_and_check_decl_spec_loc (decl_specs, ds_virtual, token);
break; break;
...@@ -29035,6 +29036,14 @@ finish_fully_implicit_template (cp_parser *parser, tree member_decl_opt) ...@@ -29035,6 +29036,14 @@ finish_fully_implicit_template (cp_parser *parser, tree member_decl_opt)
{ {
gcc_assert (parser->fully_implicit_function_template_p); gcc_assert (parser->fully_implicit_function_template_p);
if (member_decl_opt && member_decl_opt != error_mark_node
&& DECL_VIRTUAL_P (member_decl_opt))
{
error_at (DECL_SOURCE_LOCATION (member_decl_opt),
"implicit templates may not be %<virtual%>");
DECL_VIRTUAL_P (member_decl_opt) = false;
}
pop_deferring_access_checks (); pop_deferring_access_checks ();
if (member_decl_opt) if (member_decl_opt)
member_decl_opt = finish_member_template_decl (member_decl_opt); member_decl_opt = finish_member_template_decl (member_decl_opt);
......
2013-10-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58535
* g++.dg/parse/crash65.C: New.
* g++.dg/cpp1y/pr58535.C: Likewise.
2013-10-02 Richard Biener <rguenther@suse.de> 2013-10-02 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ldist-11.c: Adjust. * gcc.dg/tree-ssa/ldist-11.c: Adjust.
......
// PR c++/58535
// { dg-options "-std=gnu++1y" }
struct A
{
virtual void foo(auto); // { dg-error "templates" }
};
// PR c++/58535
struct A
{
template<int> virtual void foo(); // { dg-error "templates" }
};
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