aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-05-06 20:41:52 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-05-06 22:41:52 +0200
commitc7cb9f42a8842aba5a14138afb9f4e67067c28fa (patch)
treee650d9b6287e389886337e558d3e9b5cde8fa8a5 /gcc
parentab3426a77573180fe4c36d10a5532f1d45e2102f (diff)
downloadgcc-c7cb9f42a8842aba5a14138afb9f4e67067c28fa.zip
gcc-c7cb9f42a8842aba5a14138afb9f4e67067c28fa.tar.gz
gcc-c7cb9f42a8842aba5a14138afb9f4e67067c28fa.tar.bz2
re PR c++/17395 (Incorrect lookup for parameters)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/call7.C19
4 files changed, 35 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4e1725..ca9c05a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index adea7eb..e100d6b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3764a27..c34a270 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..00a912b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/call7.C
@@ -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);
+}