Add an asssert and testcase for PR 68064
authorMartin Jambor <mjambor@suse.cz>
Fri, 11 Dec 2015 11:27:11 +0000 (12:27 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 11 Dec 2015 11:27:11 +0000 (12:27 +0100)
2015-12-11  Martin Jambor  <mjambor@suse.cz>

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
gcc/ipa-prop.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr68064.C [new file with mode: 0644]

index da9e02f247d38c76cf67e68d6a75d16a7294da0a..6df230bed9e8e9910bd1b083b4c1270e868fa0b8 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-11  Martin Jambor  <mjambor@suse.cz>
+
+       PR ipa/68064
+       * ipa-prop.c (ipa_compute_jump_functions_for_edge): Add checking
+       assert that align is nonzero.
+
 2015-12-11  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        * config/s390/s390.c (s390_expand_setmem): Use new expanders.
index f96bf970ee10cfca3654751e83cb4d2cbe4b7e16..72c2fed63ff9efc4dd6648ab741c4c2aff4e08f1 100644 (file)
@@ -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;
index 283da3bbf2d9e017eca4a0bf469fcc487f6f8656..c1a05791a3aa8a2dc520a6911062d82ca25ea88a 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-11  Martin Jambor  <mjambor@suse.cz>
+
+       PR ipa/68064
+       * g++.dg/torture/pr68064.C: New test.
+
 2015-12-11  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        * 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 (file)
index 0000000..59b6897
--- /dev/null
@@ -0,0 +1,35 @@
+// { dg-do compile }
+
+template <class Config> class A {
+public:
+  class B;
+  typedef typename Config::template D<A>::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 Config> class A<Config>::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 <class> struct D { typedef A<C> *type; };
+  static A<C> *from_bitset(unsigned);
+};
+A<C> *C::from_bitset(unsigned p1) { return reinterpret_cast<A<C> *>(p1); }
+
+namespace {
+int *a;
+void fn1(A<C> *p1) { A<C>::Union(A<C>::Representation(p1, a)); }
+}
+
+void fn2() {
+  A<C> b;
+  A<C> *c = b.Is() ? 0 : A<C>::Tagged();
+  fn1(c);
+}