summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-17 22:01:19 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-17 22:01:19 +0000
commit638a142aa3f33614e5d1cccc7c487e1b8bbc90e3 (patch)
tree5a372b260eab2bfd26de9d6e6aafa95c6719584e
parentd4d51f80e75ebd6bdf077c750d34650e9187b878 (diff)
downloadgcc-638a142aa3f33614e5d1cccc7c487e1b8bbc90e3.tar.gz
2004-10-17 Andrew Pinski <pinskia@physics.uc.edu>
Revert: 2004-10-17 Andrew Pinski <pinskia@physics.uc.edu> * c-typeck.c (default_function_array_conversion): Always create &a[0] for array types. (build_unary_op): Do not fold &a[x] into a + x. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89183 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-typeck.c19
2 files changed, 25 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9bbb498018c..f2d34c62edd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2004-10-17 Andrew Pinski <pinskia@physics.uc.edu>
+ Revert:
+ 2004-10-17 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * c-typeck.c (default_function_array_conversion): Always create
+ &a[0] for array types.
+ (build_unary_op): Do not fold &a[x] into a + x.
+
+2004-10-17 Andrew Pinski <pinskia@physics.uc.edu>
+
PR middle-end/17925
* cfgexpand.c (expand_gimple_cond_expr): Emit line notes for next basic
block if there is a goto with a locus.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 87f585baddb..9e4f0fb1501 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1263,9 +1263,21 @@ default_function_array_conversion (tree exp)
ptrtype = build_pointer_type (restype);
+ if (TREE_CODE (exp) == VAR_DECL)
+ {
+ /* We are making an ADDR_EXPR of ptrtype. This is a valid
+ ADDR_EXPR because it's the best way of representing what
+ happens in C when we take the address of an array and place
+ it in a pointer to the element type. */
+ adr = build1 (ADDR_EXPR, ptrtype, exp);
+ if (!c_mark_addressable (exp))
+ return error_mark_node;
+ TREE_SIDE_EFFECTS (adr) = 0; /* Default would be, same as EXP. */
+ return adr;
+ }
/* This way is better for a COMPONENT_REF since it can
simplify the offset for a component. */
- adr = build_unary_op (ADDR_EXPR, build_array_ref (exp, integer_zero_node), 1);
+ adr = build_unary_op (ADDR_EXPR, exp, 1);
return convert (ptrtype, adr);
}
return exp;
@@ -2619,12 +2631,13 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
return TREE_OPERAND (arg, 0);
}
- /* For &x[y], just return &x[y] */
+ /* For &x[y], return x+y */
if (TREE_CODE (arg) == ARRAY_REF)
{
if (!c_mark_addressable (TREE_OPERAND (arg, 0)))
return error_mark_node;
- return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg);
+ return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
+ TREE_OPERAND (arg, 1), 1);
}
/* Anything not already handled and not a true memory reference