aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-07-19 13:20:40 -0700
committerRichard Henderson <rth@gcc.gnu.org>2005-07-19 13:20:40 -0700
commitaf62f6f9a440d24b135f7d5023173180566a780e (patch)
treefbf02d28bdbfe2df54c4da773d527881c941eba7 /gcc/tree-ssa.c
parentb9b8dde3026d1e54c5bb2c8fa331a7bfd84b671d (diff)
downloadgcc-af62f6f9a440d24b135f7d5023173180566a780e.zip
gcc-af62f6f9a440d24b135f7d5023173180566a780e.tar.gz
gcc-af62f6f9a440d24b135f7d5023173180566a780e.tar.bz2
re PR tree-optimization/22278 (gcc -O2 discards cast to volatile)
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. From-SVN: r102169
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r--gcc/tree-ssa.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index fc1754f..d78a944 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. */