ipa-inline.c (ipa_inline): Check that function is defined before flattening.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 13 Nov 2019 13:29:27 +0000 (14:29 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 13 Nov 2019 13:29:27 +0000 (13:29 +0000)
* ipa-inline.c (ipa_inline): Check that function is defined before
flattening.
* gcc.c-torture/compile/flatten.c: New testcase.

From-SVN: r278139

gcc/ChangeLog
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/flatten.c [new file with mode: 0644]

index 0e5560e1f87d23427d36b8f0080c62f295e36e05..f637442f5233c99535a7fea89e82db778dacdfac 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-13  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-inline.c (ipa_inline): Check that function is defined before
+       flattening.
+
 2019-11-13  Andrew Stubbs  <ams@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>
 
index df6f991ad79b23b61a64abd7882aa1460bd5824a..f3e880c3e93f6616e12e0d41156a19f5be0bd838 100644 (file)
@@ -2564,8 +2564,9 @@ ipa_inline (void)
   for (i = nnodes - 1, j = i; i >= 0; i--)
     {
       node = order[i];
-      if (lookup_attribute ("flatten",
-                           DECL_ATTRIBUTES (node->decl)) != NULL)
+      if (node->definition
+         && lookup_attribute ("flatten",
+                              DECL_ATTRIBUTES (node->decl)) != NULL)
        order[j--] = order[i];
     }
 
index 1727bf0eac77b65809b3b68bedffbef7b5882a74..cd38237ab3b3b5542f5b913468a0963b618ef73e 100644 (file)
@@ -1,3 +1,7 @@
+2019-11-13  Jan Hubicka  <hubicka@ucw.cz>
+
+       * gcc.c-torture/compile/flatten.c: New testcase.
+
 2019-11-13  Tobias Burnus  <tobias@codesourcery.com>
 
        PR fortran/92470
diff --git a/gcc/testsuite/gcc.c-torture/compile/flatten.c b/gcc/testsuite/gcc.c-torture/compile/flatten.c
new file mode 100644 (file)
index 0000000..73042be
--- /dev/null
@@ -0,0 +1,5 @@
+int you_shall_not_flatten_me () __attribute__ ((flatten));
+main()
+{
+  you_shall_not_flatten_me ();
+}