From: Jason Merrill Date: Fri, 7 Dec 2012 04:53:59 +0000 (-0500) Subject: re PR c++/55058 (Unexpected invalid type conversion error) X-Git-Tag: releases/gcc-4.8.0~1503 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e243cfcede8e46b6d1a1548a1e6248df23bae3a;p=thirdparty%2Fgcc.git re PR c++/55058 (Unexpected invalid type conversion error) PR c++/55058 * pt.c (tsubst): Keep the quals when looking through a typedef. From-SVN: r194282 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 22bdb505942d..a92ebe147c9a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-12-06 Jason Merrill + PR c++/55058 + * pt.c (tsubst): Keep the quals when looking through a typedef. + PR c++/55249 * tree.c (build_vec_init_elt): Use the type of the initializer. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 87cd33760c25..33044e0f61ce 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11013,8 +11013,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) return r; } else - /* We don't have an instantiation yet, so drop the typedef. */ - t = DECL_ORIGINAL_TYPE (decl); + { + /* We don't have an instantiation yet, so drop the typedef. */ + int quals = cp_type_quals (t); + t = DECL_ORIGINAL_TYPE (decl); + t = cp_build_qualified_type_real (t, quals, + complain | tf_ignore_bad_quals); + } } if (type diff --git a/gcc/testsuite/g++.dg/template/typedef40.C b/gcc/testsuite/g++.dg/template/typedef40.C new file mode 100644 index 000000000000..1d8be358a202 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef40.C @@ -0,0 +1,21 @@ +// PR c++/55058 + +template +struct A { }; + +template +struct B { + B(const A T::* p); + typedef A D; +}; + +template +B::B(const D T::* p) { } + +struct C { + C() : e() {}; + + const A e; +}; + +B g(&C::e);