Commit 2c05d05e by Mark Mitchell Committed by Mark Mitchell

re PR c++/29733 (ICE on initialization of function type)

	PR c++/29733
	* pt.c (tsubst_decl): Disallow variables of function type.
	PR c++/29733
	* g++.dg/template/crash61.C: New test.

From-SVN: r119500
parent 7b5d1e27
2006-12-04 Mark Mitchell <mark@codesourcery.com>
PR c++/29733
* pt.c (tsubst_decl): Disallow variables of function type.
PR c++/29632
* call.c (add_builtin_candidate): Do not permit NULL pointer
constants to be compared with template parameters.
......
......@@ -6954,6 +6954,27 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
type = tsubst (TREE_TYPE (t), args, complain, in_decl);
if (type == error_mark_node)
return error_mark_node;
if (TREE_CODE (type) == FUNCTION_TYPE)
{
/* It may seem that this case cannot occur, since:
typedef void f();
void g() { f x; }
declares a function, not a variable. However:
typedef void f();
template <typename T> void g() { T t; }
template void g<f>();
is an attempt to declare a variable with function
type. */
error ("variable %qD has function type",
/* R is not yet sufficiently initialized, so we
just use its name. */
DECL_NAME (r));
return error_mark_node;
}
type = complete_type (type);
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (r)
= DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (t);
......
2006-12-04 Mark Mitchell <mark@codesourcery.com>
PR c++/29733
* g++.dg/template/crash61.C: New test.
PR c++/29632
* g++.dg/template/error23.C: New test.
// PR c++/29733
template<typename T> void foo()
{
T t = 0; // { dg-error "function type" }
}
void bar()
{
foo<int()>();
}
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