From: Kwok Cheung Yeung Date: Thu, 30 May 2019 18:57:00 +0000 (-0700) Subject: Fix for firstprivate-int.f90 test failures X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f513ca2b69d9b7601ff79f518c0c7c842f0adf1f;p=thirdparty%2Fgcc.git 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) --- diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 5fa50356f743..e7f268817548 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2019-05-30 Kwok Cheung Yeung + + * 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 * gimplify.c (gimplify_adjust_omp_clauses_1): Support implied no_alloc diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 0a172719e5df..589e16b18806 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]).