From: Richard Guenther Date: Wed, 16 May 2012 13:11:01 +0000 (+0000) Subject: re PR tree-optimization/53364 (Wrong code generation) X-Git-Tag: upstream/12.2.0~76250 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a952cc068c5df10333be537e9283e1aebc24c55d;p=platform%2Fupstream%2Fgcc.git re PR tree-optimization/53364 (Wrong code generation) 2012-05-16 Richard Guenther PR tree-optimization/53364 * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Properly detect a view-conversion of the decl. * g++.dg/torture/pr53364.C: New testcase. From-SVN: r187590 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a0d816..a7d0b3e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-05-16 Richard Guenther + + PR tree-optimization/53364 + * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Properly + detect a view-conversion of the decl. + 2012-05-16 Dodji Seketeli PR preprocessor/7263 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d1efffc..299ece5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-05-16 Richard Guenther + + PR tree-optimization/53364 + * g++.dg/torture/pr53364.C: New testcase. + 2012-05-16 Georg-Johann Lay PR testsuite/52641 diff --git a/gcc/testsuite/g++.dg/torture/pr53364.C b/gcc/testsuite/g++.dg/torture/pr53364.C new file mode 100644 index 0000000..36bb083 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr53364.C @@ -0,0 +1,37 @@ +// { dg-do run } + +extern "C" void abort (void); + +template +inline const _Tp& +min(const _Tp& __a, const _Tp& __b) +{ + if (__b < __a) + return __b; + return __a; +} + +struct A +{ + int m_x; + + explicit A(int x) : m_x(x) {} + operator int() const { return m_x; } +}; + +struct B : public A +{ +public: + explicit B(int x) : A(x) {} +}; + +int data = 1; + +int main() +{ + B b = B(10); + b = min(b, B(data)); + if (b != 1) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index ec1bbbe..540850f 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -850,8 +850,7 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, /* If either reference is view-converted, give up now. */ if (same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) != 1 - || same_type_for_tbaa (TREE_TYPE (dbase2), - TREE_TYPE (reference_alias_ptr_type (dbase2))) != 1) + || same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (base2)) != 1) return true; /* If both references are through the same type, they do not alias