summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-24 03:02:44 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-24 03:02:44 +0000
commitf4d47aeb11c54dcd532e998132fdf22f75d31f01 (patch)
tree3fa78a3f02322b1c8e4ece468c0e107283801ce8
parente67a67ea884547a3da4d2d33b2aeff903d0276cb (diff)
downloadgcc-f4d47aeb11c54dcd532e998132fdf22f75d31f01.tar.gz
* fold-const.c (non_lvalue): Explicitly list the tree codes that
need to be wrapped by NON_LVALUE_EXPR, instead of those that don't. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82195 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c48
2 files changed, 46 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b970d154f03..df40b599375 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-23 Roger Sayle <roger@eyesopen.com>
+
+ * fold-const.c (non_lvalue): Explicitly list the tree codes that
+ need to be wrapped by NON_LVALUE_EXPR, instead of those that don't.
+
2004-05-23 Joseph S. Myers <jsm@polyomino.org.uk>
* doc/gcc.texi, doc/gccint.texi, doc/include/gcc-common.texi:
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ba683ad3f2b..3fa46cafe87 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1993,14 +1993,48 @@ fold_convert (tree type, tree arg)
tree
non_lvalue (tree x)
{
- /* These things are certainly not lvalues. */
- if (TREE_CODE (x) == NON_LVALUE_EXPR
- || TREE_CODE (x) == INTEGER_CST
- || TREE_CODE (x) == REAL_CST
- || TREE_CODE (x) == STRING_CST
- || TREE_CODE (x) == ADDR_EXPR)
+ /* We only need to wrap lvalue tree codes. */
+ switch (TREE_CODE (x))
+ {
+ case VAR_DECL:
+ case PARM_DECL:
+ case RESULT_DECL:
+ case LABEL_DECL:
+ case FUNCTION_DECL:
+ case SSA_NAME:
+
+ case COMPONENT_REF:
+ case INDIRECT_REF:
+ case ARRAY_REF:
+ case BIT_FIELD_REF:
+ case BUFFER_REF:
+ case ARRAY_RANGE_REF:
+ case VTABLE_REF:
+
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case SAVE_EXPR:
+ case UNSAVE_EXPR:
+ case TRY_CATCH_EXPR:
+ case WITH_CLEANUP_EXPR:
+ case COMPOUND_EXPR:
+ case MODIFY_EXPR:
+ case TARGET_EXPR:
+ case COND_EXPR:
+ case BIND_EXPR:
+ case MIN_EXPR:
+ case MAX_EXPR:
+ case RTL_EXPR:
+ break;
+
+ default:
+ /* Assume the worst for front-end tree codes. */
+ if ((int)TREE_CODE (x) >= NUM_TREE_CODES)
+ break;
return x;
-
+ }
return build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x);
}