diff mbox

Fix PR64373

Message ID alpine.LSU.2.11.1501131407250.12482@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Jan. 13, 2015, 1:08 p.m. UTC
The following patch guards LTO against PARM_DECLs without DECL_CONTEXT.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2015-02-13  Richard Biener  <rguenther@suse.de>

	PR lto/64373
	* lto-streamer-out.c (tree_is_indexable): Guard for NULL
	DECL_CONTEXT.

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

Patch

Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 219520)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -154,7 +154,8 @@  tree_is_indexable (tree t)
   /* Parameters and return values of functions of variably modified types
      must go to global stream, because they may be used in the type
      definition.  */
-  if (TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
+  if ((TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
+      && DECL_CONTEXT (t))
     return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE);
   /* IMPORTED_DECL is put into BLOCK and thus it never can be shared.  */
   else if (TREE_CODE (t) == IMPORTED_DECL)
Index: gcc/testsuite/gcc.dg/lto/pr64373_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/pr64373_0.c	(revision 0)
+++ gcc/testsuite/gcc.dg/lto/pr64373_0.c	(working copy)
@@ -0,0 +1,10 @@ 
+/* { dg-lto-do assemble } */
+
+extern void b(int L, float (*data)[L]);
+
+void a(void)
+{
+  float* p = 0;
+  int i = 0;
+  b(10, (float (*)[10])(p + i));
+}