re PR lto/48437 (LTO crashes with block-local function declarations)
authorRichard Guenther <rguenther@suse.de>
Thu, 8 Dec 2011 08:50:35 +0000 (08:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 8 Dec 2011 08:50:35 +0000 (08:50 +0000)
2011-12-08  Richard Guenther  <rguenther@suse.de>

PR lto/48437
* lto-streamer-out.c (tree_is_indexable): Exclude block-local
extern declarations.

* gcc.dg/lto/20111207-2_0.c: New testcase.
* gcc.dg/guality/pr48437.c: Likewise.

From-SVN: r182100

gcc/ChangeLog
gcc/lto-streamer-out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/pr48437.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/20111207-2_0.c [new file with mode: 0644]

index 5d50a192d9965958e69e0243d7b977211f7d3625..325c1e0763e5508c900de483f60bfa63567fd39d 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-08  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/48437
+       * lto-streamer-out.c (tree_is_indexable): Exclude block-local
+       extern declarations.
+
 2011-12-07  Andrew Pinski  <apinski@cavium.com>
 
        PR middle-end/45416
index 62cf9a1832f10f9872b6b7de7692e056f73b80e8..655cf89bc288b768fb91d5a389b018e7e90af545 100644 (file)
@@ -129,6 +129,16 @@ tree_is_indexable (tree t)
   else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t)
           && !TREE_STATIC (t))
     return false;
+  /* If this is a decl generated for block local externs for
+     debug info generation, stream it unshared alongside BLOCK_VARS.  */
+  else if (VAR_OR_FUNCTION_DECL_P (t)
+          /* ???  The following tests are a literal match on what
+             c-decl.c:pop_scope does.  */
+          && TREE_PUBLIC (t)
+          && DECL_EXTERNAL (t)
+          && DECL_CONTEXT (t)
+          && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
+    return false;
   else
     return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
 }
index 31b2d2e37fc453a88e3b7c5b51f3ef65cd02ae4a..ededf0425f6703bfc23652e0982f9072b62c982d 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-08  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/48437
+       * gcc.dg/lto/20111207-2_0.c: New testcase.
+       * gcc.dg/guality/pr48437.c: Likewise.
+
 2011-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/51401
diff --git a/gcc/testsuite/gcc.dg/guality/pr48437.c b/gcc/testsuite/gcc.dg/guality/pr48437.c
new file mode 100644 (file)
index 0000000..5346baa
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR lto/48437 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+int i __attribute__((used));
+int main()
+{
+  volatile int i;
+  for (i = 3; i < 7; ++i)
+    {
+      extern int i;
+      asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test 14 "i" "0" } } */
+    }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20111207-2_0.c b/gcc/testsuite/gcc.dg/lto/20111207-2_0.c
new file mode 100644 (file)
index 0000000..672db53
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-lto-do run } */
+
+int
+test (void)
+{
+  int f (void);
+  return 0;
+}
+
+int
+main (void)
+{
+  int f (void);
+  int test (void);
+
+  return test ();
+}