re PR c++/17395 (Incorrect lookup for parameters)
authorDodji Seketeli <dodji@redhat.com>
Wed, 6 May 2009 20:41:52 +0000 (20:41 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 6 May 2009 20:41:52 +0000 (22:41 +0200)
2009-05-06  Dodji Seketeli  <dodji@redhat.com>

    gcc/cp/ChangeLog:
     PR c++/17395
     * pt.c (tsubst_copy) <case PARM_DECL>: We don't want to tsubst the
     whole list of PARM_DECLs, just the current one.

    gcc/testsuite/ChangeLog:
     PR c++/17395
     * g++.dg/template/call7.C: New test.

From-SVN: r147201

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

index a4e1725c0d94a1168c1235a8c9d8885787a9f1ab..ca9c05af9f837e211cee96c7bd7cee14a358d3a2 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-06  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/17395
+       * pt.c (tsubst_copy) <case PARM_DECL>: We don't want to tsubst the
+       whole list of PARM_DECLs, just the current one.
+
 2009-05-05  Shujing Zhao  <pearly.zhao@oracle.com>
 
        * cp-tree.h:
index adea7eb46ef3ee6ed1eb55f722872db9d3d1894d..e100d6b116c78d1866bdccad3b82a4a18561c090 100644 (file)
@@ -10020,11 +10020,15 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
       if (r == NULL)
        {
+         tree c;
          /* This can happen for a parameter name used later in a function
             declaration (such as in a late-specified return type).  Just
             make a dummy decl, since it's only used for its type.  */
          gcc_assert (skip_evaluation);   
-         r = tsubst_decl (t, args, complain);
+         /* We copy T because want to tsubst the PARM_DECL only,
+            not the following PARM_DECLs that are chained to T.  */
+         c = copy_node (t);
+         r = tsubst_decl (c, args, complain);
          /* Give it the template pattern as its context; its true context
             hasn't been instantiated yet and this is good enough for
             mangling.  */
index 3764a2706c145b79eb41c9dc85cd21ded4ed2749..c34a2701bc84e7c529e00fa3db7f523ede9a5ebb 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-06  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/17395
+       * g++.dg/template/call7.C: New test.
+
 2009-05-06  Diego Novillo  <dnovillo@google.com>
 
        * lib/plugin-support.exp: Do not prefix $GMPINC with -I.
diff --git a/gcc/testsuite/g++.dg/template/call7.C b/gcc/testsuite/g++.dg/template/call7.C
new file mode 100644 (file)
index 0000000..00a912b
--- /dev/null
@@ -0,0 +1,19 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/17395
+// { dg-do "compile" }
+
+template<int> struct X { };
+
+void fu(int a, X<sizeof(a)>) { }
+
+template<class T>
+void bhar(T a, X<sizeof(a)>) { }
+
+int
+main()
+{
+  int x;
+  X<sizeof(int)> y;
+  fu(x, y);
+  bhar(x, y);
+}