From b0d75c1eca02f68c259cec2bf1bfba43aafa433b Mon Sep 17 00:00:00 2001 From: Brendan Kehoe Date: Tue, 9 Sep 1997 22:20:47 +0000 Subject: [PATCH] typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to c-typeck.c. * typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to c-typeck.c. From-SVN: r15197 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0bd033ff478..ddadf86eb5a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1997-09-09 Brendan Kehoe + + * typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to + c-typeck.c. + Mon Sep 8 02:33:20 1997 Jody Goldberg * decl.c (current_local_enum): Remove static. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b000efbead5..ecac505dc8b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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; } } -- 2.30.2