This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Minor improvement to fold_unary_loc


this makes fold_unary_loc fold NON_LVALUE_EXPR if the argument cannot be a 
lvalue (this happens when you're re-fold-building an existing tree) and 
changes the first call to fold_convert_const to use arg0 instead of op0, like 
the other 2 calls just below (this should not change anything if the argument 
is correctly folded, but is more forgiving if it is not).

Tested on x86_64-suse-linux, OK for the mainline?

2014-05-14  Eric Botcazou  <>

	* fold-const (fold_unary_loc) <NON_LVALUE_EXPR>: New case.
	<CASE_CONVERT>: Pass arg0 instead of op0 to fold_convert_const.

Eric Botcazou
Index: fold-const.c
--- fold-const.c	(revision 210410)
+++ fold-const.c	(working copy)
@@ -7850,6 +7850,11 @@ fold_unary_loc (location_t loc, enum tre
 	return fold_convert_loc (loc, type, op0);
       return NULL_TREE;
+    case NON_LVALUE_EXPR:
+      if (!maybe_lvalue_p (op0))
+	return fold_convert_loc (loc, type, op0);
+      return NULL_TREE;
     case FLOAT_EXPR:
     case FIX_TRUNC_EXPR:
@@ -8113,7 +8118,7 @@ fold_unary_loc (location_t loc, enum tre
-      tem = fold_convert_const (code, type, op0);
+      tem = fold_convert_const (code, type, arg0);
       return tem ? tem : NULL_TREE;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]