]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58878 (Template parameter name can be hidden in a template member function...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 25 Oct 2013 16:26:10 +0000 (16:26 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 25 Oct 2013 16:26:10 +0000 (16:26 +0000)
/cp
2013-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58878
* pt.c (check_template_shadow): Don't skip declarations in inline
member templates.

/testsuite
2013-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58878
* g++.dg/template/pr58878.C: New.

From-SVN: r204071

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

index dfe4a3f8f5b6b1496b519b3fd33c4b988c4b452e..297d015a86691df941898e3a62683f022e5f4652 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58878
+       * pt.c (check_template_shadow): Don't skip declarations in inline
+       member templates.
+
 2013-10-25  Tobias Burnus  <burnus@net-b.de>
 
        PR other/33426
index cbb0339a31942ed22c3b8be43b862285ef3fb673..224be8b988d015a2d272256e85d6d3cf5975ebf7 100644 (file)
@@ -3511,7 +3511,8 @@ check_template_shadow (tree decl)
      name inside a class.  We check TPFI to avoid duplicate errors for
      inline member templates.  */
   if (decl == olddecl
-      || TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
+      || (DECL_TEMPLATE_PARM_P (decl)
+         && TEMPLATE_PARMS_FOR_INLINE (current_template_parms)))
     return true;
 
   error ("declaration of %q+#D", decl);
index 044b76b316fff52822df4e2035b9bc38dcc1ec74..ac5ab6d06488398bea3497fe1bff7955460d71ee 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58878
+       * g++.dg/template/pr58878.C: New.
+
 2013-10-25  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.dg/tree-ssa/alias-23.c: New file.
diff --git a/gcc/testsuite/g++.dg/template/pr58878.C b/gcc/testsuite/g++.dg/template/pr58878.C
new file mode 100644 (file)
index 0000000..adad9fe
--- /dev/null
@@ -0,0 +1,61 @@
+// PR c++/58878
+
+// Template-members of non-template class
+struct A
+{
+    template <typename t>    // { dg-error "shadows" }
+        void f()
+        {
+            int t = 1;       // { dg-error "declaration" }
+        }
+
+    template <typename t>
+        void g();
+};
+
+template <typename t>        // { dg-error "shadows" }
+void A::g()
+{
+    int t = 2;               // { dg-error "declaration" }
+}
+
+// (Non-template) Members of template class
+template <typename t>        // { dg-error "shadows" }
+struct B
+{
+    void f()
+    {
+        int t = 3;           // { dg-error "declaration" }
+    }
+
+    void g();
+};
+
+template <typename t>        // { dg-error "shadows" }
+void B<t>::g()
+{
+    int t = 4;               // { dg-error "declaration" }
+}
+
+// Template members of template class
+template <typename t>        // { dg-error "shadows" }
+struct C
+{
+    template <typename s>    // { dg-error "shadows" }
+    void f()
+    {
+        int t = 5;           // { dg-error "declaration" }
+        int s = 6;           // { dg-error "declaration" }
+    }
+
+    template <typename s>
+    void g();
+};
+
+template <typename t>        // { dg-error "shadows" }
+template <typename s>        // { dg-error "shadows" }
+void C<t>::g()
+{
+    int t = 7;               // { dg-error "declaration" }
+    int s = 8;               // { dg-error "declaration" }
+}