PATCH: optimization/7145: g++ -O with structure initializer & returnvalue optimization generates bad code

H. J. Lu hjl@lucon.org
Sat Jun 29 08:51:00 GMT 2002


I don't think we can do named return value optimization if the return
value is initialized by "{...}". Here is a patch. Tested on gcc 3.1.1
on Linux/x86 and Linux/alpha.


H.J.
-------------- next part --------------
2002-06-28  H.J. Lu  (hjl@gnu.org)

	* typeck.c (check_return_expr): Don't do named return value
	optimization if the return value is initialized by "{...}".

--- gcc/cp/typeck.c.named	Fri Jun 21 00:36:03 2002
+++ gcc/cp/typeck.c	Sat Jun 29 00:13:46 2002
@@ -6559,6 +6559,8 @@ check_return_expr (retval)
 	  && (current_function_return_value == NULL_TREE
 	      || current_function_return_value == retval)
 	  && TREE_CODE (retval) == VAR_DECL
+	  && (DECL_INITIAL (retval) == NULL_TREE
+	      || TREE_CODE (DECL_INITIAL (retval)) != CONSTRUCTOR)
 	  && DECL_CONTEXT (retval) == current_function_decl
 	  && ! TREE_STATIC (retval)
 	  && (DECL_ALIGN (retval)


More information about the Gcc-patches mailing list