diff mbox

Fix PR61969

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

Commit Message

Richard Biener Oct. 9, 2014, 7:51 a.m. UTC
This fixes an invalid NRV optimization done for returning a
non-automatic var.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-10-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/61969
	* tree-nrv.c (pass_nrv::execute): Properly test for automatic
	variables.
diff mbox

Patch

Index: gcc/tree-nrv.c
===================================================================
--- gcc/tree-nrv.c	(revision 215917)
+++ gcc/tree-nrv.c	(working copy)
@@ -216,8 +216,7 @@  pass_nrv::execute (function *fun)
 		 same type and alignment as the function's result.  */
 	      if (TREE_CODE (found) != VAR_DECL
 		  || TREE_THIS_VOLATILE (found)
-		  || DECL_CONTEXT (found) != current_function_decl
-		  || TREE_STATIC (found)
+		  || !auto_var_in_fn_p (found, current_function_decl)
 		  || TREE_ADDRESSABLE (found)
 		  || DECL_ALIGN (found) > DECL_ALIGN (result)
 		  || !useless_type_conversion_p (result_type,