aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-02-16 06:29:26 +0000
committerRichard Stallman <rms@gnu.org>1993-02-16 06:29:26 +0000
commit870cc33b824fd4ca58112fa5090a5a0a1394a59a (patch)
tree82a0b9a7137b23d23afbf492752b9755bb8d853c
parenta73f14a3f91130cd6e4e5a46dfa5d751a4abafef (diff)
downloadgcc-870cc33b824fd4ca58112fa5090a5a0a1394a59a.zip
gcc-870cc33b824fd4ca58112fa5090a5a0a1394a59a.tar.gz
gcc-870cc33b824fd4ca58112fa5090a5a0a1394a59a.tar.bz2
(build_indirect_ref): Avoid *& short-cut if -fvolatile.
From-SVN: r3475
-rw-r--r--gcc/c-typeck.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index c8eb93a..e1a402b 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1109,37 +1109,40 @@ build_indirect_ref (ptr, errorstring)
register tree type = TREE_TYPE (pointer);
if (TREE_CODE (type) == POINTER_TYPE)
- if (TREE_CODE (pointer) == ADDR_EXPR
- && (TREE_TYPE (TREE_OPERAND (pointer, 0))
- == TREE_TYPE (type)))
- return TREE_OPERAND (pointer, 0);
- else
- {
- tree t = TREE_TYPE (type);
- register tree ref = build1 (INDIRECT_REF,
- TYPE_MAIN_VARIANT (t), pointer);
+ {
+ if (TREE_CODE (pointer) == ADDR_EXPR
+ && !flag_volatile
+ && (TREE_TYPE (TREE_OPERAND (pointer, 0))
+ == TREE_TYPE (type)))
+ return TREE_OPERAND (pointer, 0);
+ else
+ {
+ tree t = TREE_TYPE (type);
+ register tree ref = build1 (INDIRECT_REF,
+ TYPE_MAIN_VARIANT (t), pointer);
- if (TYPE_SIZE (t) == 0 && TREE_CODE (t) != ARRAY_TYPE)
- {
- error ("dereferencing pointer to incomplete type");
- return error_mark_node;
- }
- if (TREE_CODE (t) == VOID_TYPE)
- warning ("dereferencing `void *' pointer");
-
- /* We *must* set TREE_READONLY when dereferencing a pointer to const,
- so that we get the proper error message if the result is used
- to assign to. Also, &* is supposed to be a no-op.
- And ANSI C seems to specify that the type of the result
- should be the const type. */
- /* A de-reference of a pointer to const is not a const. It is valid
- to change it via some other pointer. */
- TREE_READONLY (ref) = TYPE_READONLY (t);
- TREE_SIDE_EFFECTS (ref)
- = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer) || flag_volatile;
- TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t) || flag_volatile;
- return ref;
- }
+ if (TYPE_SIZE (t) == 0 && TREE_CODE (t) != ARRAY_TYPE)
+ {
+ error ("dereferencing pointer to incomplete type");
+ return error_mark_node;
+ }
+ if (TREE_CODE (t) == VOID_TYPE)
+ warning ("dereferencing `void *' pointer");
+
+ /* We *must* set TREE_READONLY when dereferencing a pointer to const,
+ so that we get the proper error message if the result is used
+ to assign to. Also, &* is supposed to be a no-op.
+ And ANSI C seems to specify that the type of the result
+ should be the const type. */
+ /* A de-reference of a pointer to const is not a const. It is valid
+ to change it via some other pointer. */
+ TREE_READONLY (ref) = TYPE_READONLY (t);
+ TREE_SIDE_EFFECTS (ref)
+ = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer) || flag_volatile;
+ TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t) || flag_volatile;
+ return ref;
+ }
+ }
else if (TREE_CODE (pointer) != ERROR_MARK)
error ("invalid type argument of `%s'", errorstring);
return error_mark_node;