re PR c++/26122 (Pure specifiers for templates causing trouble)

PR c++/26122
	* decl2.c (check_member_template): Remove checks for virtual
	functions.
	* parser.c (cp_parser_function_specifier_opt): Complain about
	virtual templates.
	(cp_parser_pure_specifier): Likewise.
	PR c++/26122
	* g++.old-deja/g++.oliva/template9.C: Remove XFAIL.

From-SVN: r113873
This commit is contained in:
Mark Mitchell 2006-05-17 21:39:07 +00:00 committed by Mark Mitchell
parent c89833429b
commit ceacde632a
5 changed files with 33 additions and 17 deletions

View File

@ -1,5 +1,12 @@
2006-05-17 Mark Mitchell <mark@codesourcery.com>
PR c++/26122
* decl2.c (check_member_template): Remove checks for virtual
functions.
* parser.c (cp_parser_function_specifier_opt): Complain about
virtual templates.
(cp_parser_pure_specifier): Likewise.
PR c++/26068
* parser.c (cp_parser_set_storage_class): Check for
invalid uses of storage classes on unbraced linkage

View File

@ -452,16 +452,9 @@ check_member_template (tree tmpl)
error ("invalid declaration of member template %q#D in local class",
decl);
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
{
/* 14.5.2.3 [temp.mem]
A member function template shall not be virtual. */
error
("invalid use of %<virtual%> in template declaration of %q#D",
decl);
DECL_VIRTUAL_P (decl) = 0;
}
/* The parser rejects any use of virtual in a function template. */
gcc_assert (!(TREE_CODE (decl) == FUNCTION_DECL
&& DECL_VIRTUAL_P (decl)));
/* The debug-information generating code doesn't know what to do
with member templates. */

View File

@ -7664,7 +7664,12 @@ cp_parser_function_specifier_opt (cp_parser* parser,
break;
case RID_VIRTUAL:
if (decl_specs)
/* 14.5.2.3 [temp.mem]
A member function template shall not be virtual. */
if (PROCESSING_REAL_TEMPLATE_DECL_P ())
error ("templates may not be %<virtual%>");
else if (decl_specs)
++decl_specs->specs[(int) ds_virtual];
break;
@ -13864,12 +13869,20 @@ cp_parser_pure_specifier (cp_parser* parser)
/* Look for the `0' token. */
token = cp_lexer_consume_token (parser->lexer);
/* c_lex_with_flags marks a single digit '0' with PURE_ZERO. */
if (token->type == CPP_NUMBER && (token->flags & PURE_ZERO))
return integer_zero_node;
if (token->type != CPP_NUMBER || !(token->flags & PURE_ZERO))
{
cp_parser_error (parser,
"invalid pure specifier (only `= 0' is allowed)");
cp_parser_skip_to_end_of_statement (parser);
return error_mark_node;
}
if (PROCESSING_REAL_TEMPLATE_DECL_P ())
{
error ("templates may not be %<virtual%>");
return error_mark_node;
}
cp_parser_error (parser, "invalid pure specifier (only `= 0' is allowed)");
cp_parser_skip_to_end_of_statement (parser);
return error_mark_node;
return integer_zero_node;
}
/* Parse a constant-initializer.

View File

@ -1,5 +1,8 @@
2006-05-17 Mark Mitchell <mark@codesourcery.com>
PR c++/26122
* g++.old-deja/g++.oliva/template9.C: Remove XFAIL.
PR c++/26068
* g++.dg/opt/pr17697-3.C: Remove invalid extern specifier.
* g++.dg/parse/linkage1.C: New test.

View File

@ -7,5 +7,5 @@
struct foo {
template <class>
void bar() = 0; // { dg-error "" "" { xfail *-*-* } } invalid initializer -
void bar() = 0; // { dg-error "virtual" }
};