From 9e64af18754df7b9360cb9b693111caf0df8e7a2 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Fri, 11 Dec 2015 12:27:11 +0100 Subject: [PATCH] Add an asssert and testcase for PR 68064 2015-12-11 Martin Jambor PR ipa/68064 * ipa-prop.c (ipa_compute_jump_functions_for_edge): Add checking assert that align is nonzero. testsuite/ * g++.dg/torture/pr68064.C: New test. From-SVN: r231559 --- gcc/ChangeLog | 6 +++++ gcc/ipa-prop.c | 1 + gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/torture/pr68064.C | 35 ++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr68064.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da9e02f247d..6df230bed9e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-11 Martin Jambor + + PR ipa/68064 + * ipa-prop.c (ipa_compute_jump_functions_for_edge): Add checking + assert that align is nonzero. + 2015-12-11 Dominik Vogt * config/s390/s390.c (s390_expand_setmem): Use new expanders. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index f96bf970ee1..72c2fed63ff 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1646,6 +1646,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, && align % BITS_PER_UNIT == 0 && hwi_bitpos % BITS_PER_UNIT == 0) { + gcc_checking_assert (align != 0); jfunc->alignment.known = true; jfunc->alignment.align = align / BITS_PER_UNIT; jfunc->alignment.misalign = hwi_bitpos / BITS_PER_UNIT; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 283da3bbf2d..c1a05791a3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-11 Martin Jambor + + PR ipa/68064 + * g++.dg/torture/pr68064.C: New test. + 2015-12-11 Dominik Vogt * gcc.target/s390/md/setmem_long-1.c: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr68064.C b/gcc/testsuite/g++.dg/torture/pr68064.C new file mode 100644 index 00000000000..59b68973f38 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr68064.C @@ -0,0 +1,35 @@ +// { dg-do compile } + +template class A { +public: + class B; + typedef typename Config::template D::type TypeHandle; + static A *Tagged() { return B::New(B::kTagged); } + static TypeHandle Union(TypeHandle); + static TypeHandle Representation(TypeHandle, typename Config::Region *); + bool Is(); +}; + +template class A::B { + friend A; + enum { kTaggedPointer = 1 << 31, kTagged = kTaggedPointer }; + static A *New(int p1) { return Config::from_bitset(p1); } +}; + +struct C { + typedef int Region; + template struct D { typedef A *type; }; + static A *from_bitset(unsigned); +}; +A *C::from_bitset(unsigned p1) { return reinterpret_cast *>(p1); } + +namespace { +int *a; +void fn1(A *p1) { A::Union(A::Representation(p1, a)); } +} + +void fn2() { + A b; + A *c = b.Is() ? 0 : A::Tagged(); + fn1(c); +} -- 2.30.2