diff mbox

Fix PR59323

Message ID alpine.LNX.2.00.1311281300160.8615@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 28, 2013, 12:02 p.m. UTC
This fixes PR59323 - we were unifying TYPE_DECLs used in different
BLOCK_VARS - ultimately because they were errorneously put into
the global indexed decls.  Fixed by including some more kinds that,
when having function context, are not indexed.

This is the minimal set of kinds to fix the testcase (intentionally
I refrained from adding other stuff that makes "sense" at this point).

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-11-28  Richard Biener  <rguenther@suse.de>

	PR lto/59323
	* lto-streamer-out.c (tree_is_indexable): TYPE_DECLs and
	CONST_DECLs in function context are not indexable.

	* gcc.dg/lto/pr59323_0.c: New testcase.
diff mbox

Patch

Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 205447)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -135,8 +135,10 @@  tree_is_indexable (tree t)
      definition.  */
   if (TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
     return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE);
-  else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t)
-	   && !TREE_STATIC (t))
+  else if (((TREE_CODE (t) == VAR_DECL && !TREE_STATIC (t))
+	    || TREE_CODE (t) == TYPE_DECL
+	    || TREE_CODE (t) == CONST_DECL)
+	   && decl_function_context (t))
     return false;
   else if (TREE_CODE (t) == DEBUG_EXPR_DECL)
     return false;
Index: gcc/testsuite/gcc.dg/lto/pr59323_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/pr59323_0.c	(revision 0)
+++ gcc/testsuite/gcc.dg/lto/pr59323_0.c	(revision 0)
@@ -0,0 +1,37 @@ 
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -O2 -g -flto } } } */
+/* { dg-extra-ld-options { -r -nostdlib } } */
+
+extern void bar(void);
+
+int main(int argc, char **argv)
+{
+  int i;
+
+  if (argc == 1) {
+    enum { X };
+
+    bar();
+
+    {
+      enum { X };
+
+      asm goto ("" : : : : lab);
+lab:
+      ;
+    }
+  }
+
+  {
+    enum { X };
+
+    int foo(void)
+    {
+      return argv[0][0];
+    }
+
+    i = foo();
+  }
+
+  return i;
+}