From: dodji Date: Mon, 19 Apr 2010 09:32:16 +0000 (+0000) Subject: Fix PR c++/43704 X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=1cbf0a8454757ac5315d3bebfad4de88b6a75570 Fix PR c++/43704 gcc/cp/ChangeLog: PR c++/43704 * typeck.c (structural_comptypes): Test dependent typedefs incompatibility before testing for their main variant based equivalence. gcc/testsuite/ChangeLog: PR c++/43704 * g++.dg/template/typedef32.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158508 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 208b745cbcb..64a440d3ee3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-04-19 Dodji Seketeli + + PR c++/43704 + * typeck.c (structural_comptypes): Test dependent typedefs + incompatibility before testing for their main variant based + equivalence. + 2010-04-19 Jakub Jelinek * cp-tree.h (SCOPED_ENUM_P, UNSCOPED_ENUM_P, SET_SCOPED_ENUM_P): Use diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 383754bea4d..c43cf331c97 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1236,6 +1236,12 @@ structural_comptypes (tree t1, tree t2, int strict) if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2)) return false; + /* If T1 and T2 are dependent typedefs then check upfront that + the template parameters of their typedef DECLs match before + going down checking their subtypes. */ + if (incompatible_dependent_types_p (t1, t2)) + return false; + /* Allow for two different type nodes which have essentially the same definition. Note that we already checked for equality of the type qualifiers (just above). */ @@ -1244,11 +1250,6 @@ structural_comptypes (tree t1, tree t2, int strict) && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)) return true; - /* If T1 and T2 are dependent typedefs then check upfront that - the template parameters of their typedef DECLs match before - going down checking their subtypes. */ - if (incompatible_dependent_types_p (t1, t2)) - return false; /* Compare the types. Break out if they could be the same. */ switch (TREE_CODE (t1)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 868ce20d31e..8215f8363b8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-19 Dodji Seketeli + + PR c++/43704 + * g++.dg/template/typedef32.C: New test. + 2010-04-19 Ira Rosen PR tree-optimization/37027 diff --git a/gcc/testsuite/g++.dg/template/typedef32.C b/gcc/testsuite/g++.dg/template/typedef32.C new file mode 100644 index 00000000000..b3c4b90228f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef32.C @@ -0,0 +1,45 @@ +// Origin: PR c++/43704 +// { dg-do compile } + +template +struct if_ +{ + typedef T2 type; +}; + +template +struct iterator_restrict_traits +{ +}; + +template +class matrix +{ + class ci {}; + class i {}; +}; + +template +struct triangular_adaptor +{ + typedef typename if_::type ty1; + class iterator2 : iterator_restrict_traits::iterator_category + { + }; +}; + +template +struct banded_adaptor +{ + typedef typename if_::type ty1; + class iterator1 : iterator_restrict_traits::iterator_category + { + }; +}; + +template +struct singular_decomposition +{ + banded_adaptor >::iterator1 it1; +}; +