OSDN Git Service

* typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to
authorbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 1997 22:20:47 +0000 (22:20 +0000)
committerbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 1997 22:20:47 +0000 (22:20 +0000)
        c-typeck.c.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15197 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 0bd033f..ddadf86 100644 (file)
@@ -1,3 +1,8 @@
+1997-09-09  Brendan Kehoe  <brendan@lisa.cygnus.com>
+
+       * typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to
+       c-typeck.c.
+
 Mon Sep  8 02:33:20 1997  Jody Goldberg  <jodyg@idt.net>
 
        * decl.c (current_local_enum): Remove static.
index b000efb..ecac505 100644 (file)
@@ -2048,6 +2048,7 @@ build_indirect_ref (ptr, errorstring)
   if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
     {
       if (TREE_CODE (pointer) == ADDR_EXPR
+         && !flag_volatile
          && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (pointer, 0)))
              == TYPE_MAIN_VARIANT (TREE_TYPE (type)))
          && (TREE_READONLY (TREE_OPERAND (pointer, 0))
@@ -2061,10 +2062,13 @@ build_indirect_ref (ptr, errorstring)
          register tree ref = build1 (INDIRECT_REF,
                                      TYPE_MAIN_VARIANT (t), 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.  */
          TREE_READONLY (ref) = TYPE_READONLY (t);
-         TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
          TREE_SIDE_EFFECTS (ref)
-           = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
+           = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer) || flag_volatile;
+         TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
          return ref;
        }
     }