From: dodji Date: Mon, 6 Sep 2010 18:44:23 +0000 (+0000) Subject: Patch PR c++/45200 X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=04eabee7c415cc7f7e940483d06093920cd97850 Patch PR c++/45200 Fix PR c++/45200, c++/45293, c++/45558 gcc/cp/Changelog: PR c++/45200 PR c++/45293 PR c++/45558 * tree.c (strip_typedefs): Strip typedefs from the context of TYPENAME_TYPEs. gcc/testsuite/ChangeLog: PR c++/45200 PR c++/45293 PR c++/45558 * g++.dg/template/typedef34.C: New test. * g++.dg/template/typedef35.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163929 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 99c720cad3d..f777ae9a23f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2010-09-06 Dodji Seketeli + + PR c++/45200 + PR c++/45293 + PR c++/45558 + * tree.c (strip_typedefs): Strip typedefs from the context of + TYPENAME_TYPEs. + 2010-09-06 Mark Mitchell * typeck.c (cp_build_binary_op): Call do_warn_double_promotion. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index af5a82f80cc..ea01d1f4677 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1047,6 +1047,11 @@ strip_typedefs (tree t) TYPE_RAISES_EXCEPTIONS (t)); } break; + case TYPENAME_TYPE: + result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t)), + TYPENAME_TYPE_FULLNAME (t), + typename_type, tf_none); + break; default: break; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e96272fd7cc..0ac95d05b69 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1220,7 +1220,7 @@ incompatible_dependent_types_p (tree t1, tree t2) if (!t1_typedef_variant_p || !t2_typedef_variant_p) /* Either T1 or T2 is not a typedef so we cannot compare the - the template parms of the typedefs of T1 and T2. + template parms of the typedefs of T1 and T2. At this point, if the main variant type of T1 and T2 are equal it means the two types can't be incompatible, from the perspective of this function. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f989ce70866..4805390bf25 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2010-09-06 Dodji Seketeli + + PR c++/45200 + PR c++/45293 + PR c++/45558 + * g++.dg/template/typedef34.C: New test. + * g++.dg/template/typedef35.C: New test. + 2010-09-06 Uros Bizjak PR target/22152 diff --git a/gcc/testsuite/g++.dg/template/typedef34.C b/gcc/testsuite/g++.dg/template/typedef34.C new file mode 100644 index 00000000000..a82e155e266 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef34.C @@ -0,0 +1,37 @@ +// Origin PR c++/45200 +// { dg-do compile } + +template +struct remove_reference +{ + typedef T type; +}; + +template +struct forward_as_lref +{ +}; + +template +struct apply1 +{ + typedef typename remove_reference::type seq; + typedef forward_as_lref type; //#0 +}; + +template +struct apply +{ + typedef forward_as_lref::type::seq_type> type; //#1 +}; + +struct reverse_view +{ + typedef int seq_type; +}; + +int +main() +{ + apply::type a2; +} diff --git a/gcc/testsuite/g++.dg/template/typedef35.C b/gcc/testsuite/g++.dg/template/typedef35.C new file mode 100644 index 00000000000..2dddf0966ab --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef35.C @@ -0,0 +1,41 @@ +// Origin c++/45558 +// { dg-do compile } + +template +struct C +{ + template + struct B + { + template + struct E + { + explicit E(const W &x) : w(x) {} + const W &w; + }; + }; +}; + +struct F; +template +struct D +{ + D() {} +}; + +const D g; +template +struct A +{ + template + struct B : C::template B + { + typedef typename C::template B V; + static const D > > a; + }; +}; + +template +template +const D::template B::template E > > +A::B::a = typename C::template B::template E >(g);