]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix for firstprivate-int.f90 test failures
authorKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 30 May 2019 18:57:00 +0000 (11:57 -0700)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Mar 2020 11:18:05 +0000 (12:18 +0100)
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)

gcc/ChangeLog.omp
gcc/tree-vrp.c

index 5fa50356f7439f93f034f4d6fd7891bbb7502589..e7f2688175482646a2910ff5785dac047b7ae6af 100644 (file)
@@ -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
index 0a172719e5dfbaf8e5e5bfda5a059b8e96b05e54..589e16b1880646c93c046f185ccea2c52bf613f4 100644 (file)
@@ -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]).