diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-19 20:20:40 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-19 20:20:40 +0000 |
commit | a3986bc0093c3925be3dca4724e5e39b30149013 (patch) | |
tree | fbf02d28bdbfe2df54c4da773d527881c941eba7 | |
parent | e8d0745df96e4d0f620210f349192f65bdd4f5a5 (diff) | |
download | gcc-a3986bc0093c3925be3dca4724e5e39b30149013.tar.gz |
PR tree-opt/22278
* gimplify.c (gimplify_expr): Use main variant type for the temp
destination for a discarded volatile read.
* tree-ssa.c (tree_ssa_useless_type_conversion_1): Don't elide
casts between non-void types that change volatility.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102169 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/gimplify.c | 5 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 9 |
3 files changed, 20 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ec8a08eef0b..d411fc276b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-07-19 Richard Henderson <rth@redhat.com> + + PR tree-opt/22278 + * gimplify.c (gimplify_expr): Use main variant type for the temp + destination for a discarded volatile read. + * tree-ssa.c (tree_ssa_useless_type_conversion_1): Don't elide + casts between non-void types that change volatility. + 2005-07-15 DJ Delorie <dj@redhat.com> * toplev.h: Add comment about the first parameter for warning(). diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 13cf0267fc3..3f06d7a0491 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4411,8 +4411,9 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p, { /* Historically, the compiler has treated a bare reference to a volatile lvalue as forcing a load. */ - tree tmp = create_tmp_var (TREE_TYPE (*expr_p), "vol"); - *expr_p = build (MODIFY_EXPR, TREE_TYPE (tmp), tmp, *expr_p); + tree type = TYPE_MAIN_VARIANT (TREE_TYPE (*expr_p)); + tree tmp = create_tmp_var (type, "vol"); + *expr_p = build (MODIFY_EXPR, type, tmp, *expr_p); } else /* We can't do anything useful with a volatile reference to diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index fc1754f65ff..d78a944209e 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -903,6 +903,15 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type) && TREE_CODE (TREE_TYPE (outer_type)) == VOID_TYPE) return true; + /* Don't lose casts between pointers to volatile and non-volatile + qualified types. Doing so would result in changing the semantics + of later accesses. */ + else if (POINTER_TYPE_P (inner_type) + && POINTER_TYPE_P (outer_type) + && TYPE_VOLATILE (TREE_TYPE (outer_type)) + != TYPE_VOLATILE (TREE_TYPE (inner_type))) + return false; + /* Pointers/references are equivalent if their pointed to types are effectively the same. This allows to strip conversions between pointer types with different type qualifiers. */ |