re PR c++/20208 (No array-to-pointer decay happens for template functions)
authorMark Mitchell <mark@codesourcery.com>
Wed, 9 Mar 2005 18:35:48 +0000 (18:35 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 9 Mar 2005 18:35:48 +0000 (18:35 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array13.C [new file with mode: 0644]

index 7986946e3e291ca467c90f362e62c8c7bef002e7..0665b65f2c02087004e61f28d7d01897ea69e3cb 100644 (file)
@@ -1,3 +1,10 @@
+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    
index 320cd84522b584a61c4dc823663f3b0880160783..2ad20b34aced4986306c6d54f338ea99d69b489a 100644 (file)
@@ -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);
index 8e35721e52151d3878aa6f4682bbd74706996f62..fd38a0ef1c8a91af5ad42987e355c889ead8e95a 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/template/array13.C b/gcc/testsuite/g++.dg/template/array13.C
new file mode 100644 (file)
index 0000000..3bc152c
--- /dev/null
@@ -0,0 +1,14 @@
+// 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();
+}