re PR c++/43800 (FAIL: libgomp.c++/for-4.C)

Fix PR c++/43800

gcc/cp/ChangeLog:
	PR c++/43800
	PR c++/43704
	* typeck.c (incompatible_dependent_types_p): If one of the
	compared types if not a typedef then honour their main variant
	equivalence.

gcc/testsuite/ChangeLog:
	PR c++/43800
	PR c++/43704
	* g++.dg/template/typedef32.C: Adjust.
	* g++.dg/template/typedef33.C: New test.

From-SVN: r158571
This commit is contained in:
Dodji Seketeli 2010-04-20 19:23:45 +00:00 committed by Dodji Seketeli
parent 9c4174d853
commit 5a80a1ddff
5 changed files with 53 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2010-04-20 Dodji Seketeli <dodji@redhat.com>
PR c++/43800
PR c++/43704
* typeck.c (incompatible_dependent_types_p): If one of the
compared types if not a typedef then honour their main variant
equivalence.
2010-04-20 Jakub Jelinek <jakub@redhat.com>
* cp-tree.h (TYPE_REF_IS_RVALUE): Remove.

View File

@ -1155,6 +1155,7 @@ static bool
incompatible_dependent_types_p (tree t1, tree t2)
{
tree tparms1 = NULL_TREE, tparms2 = NULL_TREE;
bool t1_typedef_variant_p, t2_typedef_variant_p;
if (!uses_template_parms (t1) || !uses_template_parms (t2))
return false;
@ -1167,10 +1168,22 @@ incompatible_dependent_types_p (tree t1, tree t2)
return true;
}
t1_typedef_variant_p = typedef_variant_p (t1);
t2_typedef_variant_p = typedef_variant_p (t2);
/* Either T1 or T2 must be a typedef. */
if (!typedef_variant_p (t1) && !typedef_variant_p (t2))
if (!t1_typedef_variant_p && !t2_typedef_variant_p)
return false;
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.
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. */
if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
return false;
/* So if we reach this point, it means either T1 or T2 is a typedef variant.
Let's compare their template parameters. */

View File

@ -1,3 +1,10 @@
2010-04-20 Dodji Seketeli <dodji@redhat.com>
PR c++/43800
PR c++/43704
* g++.dg/template/typedef32.C: Adjust.
* g++.dg/template/typedef33.C: New test.
2010-04-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/43227

View File

@ -10,12 +10,13 @@ struct if_
template<class I1>
struct iterator_restrict_traits
{
struct iterator_category {};
};
template<class T>
class matrix
struct matrix
{
class ci {};
struct ci {struct ic {};};
class i {};
};

View File

@ -0,0 +1,21 @@
// Origin PR c++/43800
// { dg-do compile }
template<class T, class U=T>
struct V
{
typedef T t_type;
};
template<class T>
class J
{
typedef typename V<T>::t_type t_type;
const t_type& f(); // #0:
private:
t_type b;
};
template<class T>
const typename V<T>::t_type& J<T>::f() {return b;} // #1