Commit 02bab9db by Mark Mitchell Committed by Mark Mitchell

re PR c++/20208 (No array-to-pointer decay happens for template functions)

	PR c++/20208
	* pt.c (tsubst_decl): Apply array-to-pointer and
	function-to-pointer conversions to function arguments.
	(regenerate_decl_from_template): Likewise.

	PR c++/20208
	* g++.dg/template/array13.C: New test.

From-SVN: r96197
parent a35da91f
2005-03-09 Mark Mitchell <mark@codesourcery.com>
PR c++/20208
* pt.c (tsubst_decl): Apply array-to-pointer and
function-to-pointer conversions to function arguments.
(regenerate_decl_from_template): Likewise.
2005-03-09 Paolo Carlini <pcarlini@suse.de>
PR c++/16859
......
......@@ -6515,6 +6515,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
SET_DECL_TEMPLATE_PARM_P (r);
type = tsubst (TREE_TYPE (t), args, complain, in_decl);
type = type_decays_to (type);
TREE_TYPE (r) = type;
cp_apply_type_quals_to_decl (cp_type_quals (type), r);
......@@ -11136,6 +11137,7 @@ regenerate_decl_from_template (tree decl, tree tmpl)
DECL_NAME (decl_parm) = DECL_NAME (pattern_parm);
parm_type = tsubst (TREE_TYPE (pattern_parm), args, tf_error,
NULL_TREE);
parm_type = type_decays_to (parm_type);
if (!same_type_p (TREE_TYPE (decl_parm), parm_type))
TREE_TYPE (decl_parm) = parm_type;
decl_parm = TREE_CHAIN (decl_parm);
......
2005-03-09 Mark Mitchell <mark@codesourcery.com>
PR c++/20208
* g++.dg/template/array13.C: New test.
2005-03-09 Paolo Carlini <pcarlini@suse.de>
PR c++/16859
......
// PR c++/20208
// { dg-do run }
// { dg-options "-O2" }
extern "C" void abort();
template <typename T>
inline void *Foo (T arg) { return &arg[0]; }
int main () {
int bry[2];
if (Foo<int[2]>(bry) != bry)
abort();
}
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