PR c++/23293
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2005 15:39:12 +0000 (15:39 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2005 15:39:12 +0000 (15:39 +0000)
* pt.c (convert_template_argument): Use canonical type variants in
template specializations.
PR c++/23293
* g++.dg/template/error19.C: New test.

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

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

index 42dc317..4c79e89 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-18  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23293
+       * pt.c (convert_template_argument): Use canonical type variants in
+       template specializations.
+
 2005-10-18  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/21383
index d25130a..62db122 100644 (file)
@@ -3930,6 +3930,13 @@ convert_template_argument (tree parm,
        }
       else
        val = arg;
+      /* We only form one instance of each template specialization.
+        Therefore, if we use a non-canonical variant (i.e., a
+        typedef), any future messages referring to the type will use 
+        the typedef, which is confusing if those future uses do not
+        themselves also use the typedef.  */
+      if (TYPE_P (val))
+       val = canonical_type_variant (val);
     }
   else
     {
index 54122c1..f212358 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-18  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23293
+       * g++.dg/template/error19.C: New test.
+
 2005-10-18  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/21383
diff --git a/gcc/testsuite/g++.dg/template/error19.C b/gcc/testsuite/g++.dg/template/error19.C
new file mode 100644 (file)
index 0000000..d533e9a
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/23293
+
+template < typename > struct P;
+struct S;
+
+void *unrelated_function()
+{
+  typedef S K;
+  P < K > * p;
+  return p;
+}
+
+template < typename U >
+void generate_warning()
+{ 
+  U::x(); // { dg-error "P<S>" }
+}
+
+int main()
+{
+  generate_warning< P < S > >();
+}