Commit 542f8eb9 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/34089 (Segfault on specialization using struct instead of template function.)

	PR c++/34089
	* parser.c (cp_parser_class_head): Reject function template ids.

	* g++.dg/template/crash74.C: New test.

From-SVN: r130316
parent 8ef62eeb
2007-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/34089
* parser.c (cp_parser_class_head): Reject function template ids.
PR c++/28879
* tree.c (build_cplus_array_type_1): Don't pass any VLA types
when processing_template_decl to build_array_type.
......
......@@ -14536,8 +14536,18 @@ cp_parser_class_head (cp_parser* parser,
/* Look up the type. */
if (template_id_p)
{
type = TREE_TYPE (id);
type = maybe_process_partial_specialization (type);
if (TREE_CODE (id) == TEMPLATE_ID_EXPR
&& (DECL_FUNCTION_TEMPLATE_P (TREE_OPERAND (id, 0))
|| TREE_CODE (TREE_OPERAND (id, 0)) == OVERLOAD))
{
error ("function template %qD redeclared as a class template", id);
type = error_mark_node;
}
else
{
type = TREE_TYPE (id);
type = maybe_process_partial_specialization (type);
}
if (nested_name_specifier)
pushed_scope = push_scope (nested_name_specifier);
}
......
2007-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/34089
* g++.dg/template/crash74.C: New test.
2007-11-20 Richard Guenther <rguenther@suse.de>
* gcc.c-torture/execute/20071120-1.c: New testcase.
// PR c++/34089
// { dg-do compile }
// { dg-options "" }
template<typename F> void foo () { }
template<typename F> struct foo<F> { }; // { dg-error "redeclared as" }
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