re PR ipa/77905 (ICE at -Os and above in both 32-bit and 64-bit modes on x86_64-linux...
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Dec 2016 08:48:45 +0000 (09:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 Dec 2016 08:48:45 +0000 (09:48 +0100)
PR ipa/77905
* ipa-pure-const.c (cdtor_p): Return true for
DECL_STATIC_{CON,DE}STRUCTOR even when it is
DECL_LOOPING_CONST_OR_PURE_P.

* g++.dg/ipa/pr77905.C: New test.

From-SVN: r243596

gcc/ChangeLog
gcc/ipa-pure-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr77905.C [new file with mode: 0644]

index 95e896637adf8f086834f70bdf6deb076d95b940..5b478a3045e85a549f1dd52e5af46acb229df43c 100644 (file)
@@ -1,3 +1,10 @@
+2016-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR ipa/77905
+       * ipa-pure-const.c (cdtor_p): Return true for
+       DECL_STATIC_{CON,DE}STRUCTOR even when it is
+       DECL_LOOPING_CONST_OR_PURE_P.
+
 2016-12-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/78777
index 9732cbff12e401d183a08678c3f0fad359751430..634decee1e3801e3111fefe342130ae3bdb7a288 100644 (file)
@@ -1195,7 +1195,8 @@ static bool
 cdtor_p (cgraph_node *n, void *)
 {
   if (DECL_STATIC_CONSTRUCTOR (n->decl) || DECL_STATIC_DESTRUCTOR (n->decl))
-    return !TREE_READONLY (n->decl) && !DECL_PURE_P (n->decl);
+    return ((!TREE_READONLY (n->decl) && !DECL_PURE_P (n->decl))
+           || DECL_LOOPING_CONST_OR_PURE_P (n->decl));
   return false;
 }
 
index b4eea7231f3e39b6caeb789f0c5efd9156da909b..ac2a4f509a7a51760cfaa152142a8eacb33677dd 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR ipa/77905
+       * g++.dg/ipa/pr77905.C: New test.
+
 2016-12-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/78777
diff --git a/gcc/testsuite/g++.dg/ipa/pr77905.C b/gcc/testsuite/g++.dg/ipa/pr77905.C
new file mode 100644 (file)
index 0000000..0f73d50
--- /dev/null
@@ -0,0 +1,21 @@
+// PR ipa/77905
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A {
+  A(int);
+};
+struct B : A {
+  B();
+} A;
+struct C : virtual A {
+  C(int);
+};
+A::A(int x) {
+  if (x)
+    A(0);
+}
+
+B::B() : A(1) {}
+
+C::C(int) : A(1) {}