aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKwok Cheung Yeung <kcy@codesourcery.com>2019-05-30 11:57:00 -0700
committerThomas Schwinge <thomas@codesourcery.com>2020-03-03 12:18:05 +0100
commitf513ca2b69d9b7601ff79f518c0c7c842f0adf1f (patch)
treeb219f728721885e1269cc762fd3b795b27099821
parent51615ae84f5a6a6bdc1489aa6c14d4ad12f0d623 (diff)
downloadgcc-f513ca2b69d9b7601ff79f518c0c7c842f0adf1f.zip
gcc-f513ca2b69d9b7601ff79f518c0c7c842f0adf1f.tar.gz
gcc-f513ca2b69d9b7601ff79f518c0c7c842f0adf1f.tar.bz2
Fix for firstprivate-int.f90 test failures
Do not propogate the range when converting from a reference to an integral type. gcc/ * tree-vrp.c (extract_range_from_unary_expr): Set a varying range when a reference is converted to an integral type. (cherry picked from openacc-gcc-9-branch commit 7f78056b7d6ce1ff2d55c03621b29c18dacecacd)
-rw-r--r--gcc/ChangeLog.omp5
-rw-r--r--gcc/tree-vrp.c10
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 5fa5035..e7f2688 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2019-05-30 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * tree-vrp.c (extract_range_from_unary_expr): Set a varying range
+ when a reference is converted to an integral type.
+
2019-05-20 Julian Brown <julian@codesourcery.com>
* gimplify.c (gimplify_adjust_omp_clauses_1): Support implied no_alloc
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 0a17271..589e16b 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2131,6 +2131,16 @@ extract_range_from_unary_expr (value_range_base *vr,
tree inner_type = op0_type;
tree outer_type = type;
+ /* Do not trust the range information when converting from a reference
+ type to a integral type, since the reference might be a type-punned
+ integer that could take the value zero. */
+ if (TREE_CODE (inner_type) == REFERENCE_TYPE
+ && !POINTER_TYPE_P (outer_type))
+ {
+ vr->set_varying ();
+ return;
+ }
+
/* If the expression involves a pointer, we are only interested in
determining if it evaluates to NULL [0, 0] or non-NULL (~[0, 0]).