OSDN Git Service

PR c++/20208
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Mar 2005 18:35:48 +0000 (18:35 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Mar 2005 18:35:48 +0000 (18:35 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96197 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 7986946..0665b65 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 320cd84..2ad20b3 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 8e35721..fd38a0e 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();
+}