]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR ipa/77905 (ICE at -Os and above in both 32-bit and 64-bit modes on...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:51:12 +0000 (09:51 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:51:12 +0000 (09:51 +0200)
Backported from mainline
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.

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

From-SVN: r248634

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

index 1a43a0e96d22103f724767f790fb51a88570b7fc..29623a10457a4162588a8e66474784a93a42e42d 100644 (file)
@@ -1,6 +1,13 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-14  Wilco Dijkstra  <wdijkstr@arm.com>
                    Jakub Jelinek  <jakub@redhat.com>
 
index f86d6fbbc40719bb1f3ad1335a8cd3ed76e1e972..a8af21ecae35e0974447065dbce2ad3d5ee8a8fb 100644 (file)
@@ -1190,7 +1190,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 4734c07d052a6a8197ff776cc05880289b3f8365..4969e956b5f06867f0387ad3d70d007ccdc07757 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR ipa/77905
+       * g++.dg/ipa/pr77905.C: New test.
+
        2016-12-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/78796
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) {}