From: Mark Mitchell Date: Tue, 18 Oct 2005 15:39:12 +0000 (+0000) Subject: re PR c++/23293 (Misleading names in diagnostics for typedefs in functions) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=685e39c289c014c395367c0146e51225e0521b31;p=gcc.git re PR c++/23293 (Misleading names in diagnostics for typedefs in functions) PR c++/23293 * pt.c (convert_template_argument): Use canonical type variants in template specializations. PR c++/23293 * g++.dg/template/error19.C: New test. From-SVN: r105561 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 42dc317095d..4c79e894de7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-10-18 Mark Mitchell + + PR c++/23293 + * pt.c (convert_template_argument): Use canonical type variants in + template specializations. + 2005-10-18 Nathan Sidwell PR c++/21383 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d25130a078d..62db1229b21 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 54122c1dbab..f2123589f84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-10-18 Mark Mitchell + + PR c++/23293 + * g++.dg/template/error19.C: New test. + 2005-10-18 Nathan Sidwell 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 index 00000000000..d533e9a3b98 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error19.C @@ -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" } +} + +int main() +{ + generate_warning< P < S > >(); +}