Patchwork Fix parts of gcc.dg/guality/vla-1.c

login
register
mail settings
Submitter Richard Guenther
Date March 16, 2011, 4:50 p.m.
Message ID <alpine.LNX.2.00.1103161748460.25982@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/87280/
State New
Headers show

Comments

Richard Guenther - March 16, 2011, 4:50 p.m.
With -fwhole-program (or -flto) f1 gets promoted to const and the
call to it is optimized away.  The following avoids this by
making use of its return value.

Tested on x86_64-unknown-linux-gnu with and without -fwhole-program,
applied.

Richard.

2011-03-16  Richard Guenther  <rguenther@suse.de>

	* gcc.dg/guality/vla-1.c (main): Use result of f1 to avoid
	optimizing it away if promoted to const.

Patch

Index: gcc/testsuite/gcc.dg/guality/vla-1.c
===================================================================
--- gcc/testsuite/gcc.dg/guality/vla-1.c	(revision 171048)
+++ gcc/testsuite/gcc.dg/guality/vla-1.c	(working copy)
@@ -28,9 +28,10 @@  f2 (int i)
 int
 main ()
 {
+  volatile int j;
   int i = 5;
   asm volatile ("" : "=r" (i) : "0" (i));
-  f1 (i);
+  j = f1 (i);
   f2 (i);
   return 0;
 }