https://gcc.gnu.org/g:c55694bf08bad9f75d6453cf72bfd8858461fdae

commit c55694bf08bad9f75d6453cf72bfd8858461fdae
Author: Mikael Morin <[email protected]>
Date:   Thu Oct 23 12:29:18 2025 +0200

    fortran: array descriptor: Wrap getter results in a non_lvalue [PR122521]
    
    The getter functions giving access to the individual fields of array
    descriptors return a bare reference to the field.  This makes it possible to
    overuse the result of the getter by assigning a value to it.
    
    This change makes that overuse invalid by wrapping the returned by each
    getter in a non_lvalue expression.  This alone doesn't forbid the usage of
    the value on the left side of an assignment, because the non_lvalue is
    unwrapped by gimplification.  A follow-up change will reject the case before
    that unwrapping happens.
    
    This change requires the dump patterns of the testsuite to allow an optional
    NON_LVALUE_EXPR <...> wrapping, wich causes some churn.  To compensate a bit
    the additional verbosity, brace quotes are used, which reduces the amount of
    escape characters.
    
            PR fortran/122521
    
    gcc/fortran/ChangeLog:
    
            * trans-descriptor.cc (gfc_conv_descriptor_data_get,
            gfc_conv_descriptor_offset_get, gfc_conv_descriptor_dtype_get,
            gfc_conv_descriptor_span_get, gfc_conv_descriptor_rank_get,
            gfc_conv_descriptor_version_get, gfc_conv_descriptor_elem_len_get,
            gfc_conv_descriptor_type_get, gfc_conv_descriptor_dimension_get,
            gfc_conv_descriptor_stride_get, gfc_conv_descriptor_lbound_get,
            gfc_conv_descriptor_ubound_get): Wrap the result in a non_lvalue.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.fortran/allocators-1.f90: Update tree dump
            pattern.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/PR93963.f90: Update tree dump pattern.
            * gfortran.dg/array_reference_3.f90: Likewise.
            * gfortran.dg/bind-c-contiguous-2.f90: Likewise.
            * gfortran.dg/bind_c_array_params_2.f90: Likewise.
            * gfortran.dg/coarray_lib_this_image_1.f90: Likewise.
            * gfortran.dg/coarray_lib_this_image_2.f90: Likewise.
            * gfortran.dg/coarray_lock_7.f90: Likewise.
            * gfortran.dg/contiguous_3.f90: Likewise.
            * gfortran.dg/intrinsic_size_3.f90: Likewise.

Diff:
---
 gcc/fortran/trans-descriptor.cc                    | 29 +++++++++++-----------
 gcc/testsuite/gfortran.dg/PR93963.f90              |  2 +-
 gcc/testsuite/gfortran.dg/array_reference_3.f90    | 10 ++++----
 gcc/testsuite/gfortran.dg/bind-c-contiguous-2.f90  | 12 ++++-----
 .../gfortran.dg/bind_c_array_params_2.f90          |  4 +--
 .../gfortran.dg/coarray_lib_this_image_1.f90       |  2 +-
 .../gfortran.dg/coarray_lib_this_image_2.f90       |  2 +-
 gcc/testsuite/gfortran.dg/coarray_lock_7.f90       | 12 ++++-----
 gcc/testsuite/gfortran.dg/contiguous_3.f90         |  4 +--
 gcc/testsuite/gfortran.dg/intrinsic_size_3.f90     |  2 +-
 libgomp/testsuite/libgomp.fortran/allocators-1.f90 |  4 +--
 11 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index cbb59c6a16fa..e6e3288c3717 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -105,11 +105,12 @@ tree
 gfc_conv_descriptor_data_get (tree desc)
 {
   tree type = TREE_TYPE (desc);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
-    gcc_unreachable ();
+  gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
 
   tree field = conv_descriptor_data (desc);
-  return fold_convert (GFC_TYPE_ARRAY_DATAPTR_TYPE (type), field);
+  tree target_type = GFC_TYPE_ARRAY_DATAPTR_TYPE (type);
+  tree t = fold_convert (target_type, field);
+  return non_lvalue_loc (input_location, t);
 }
 
 /* This provides WRITE access to the data field.  */
@@ -133,7 +134,7 @@ conv_descriptor_offset (tree desc)
 tree
 gfc_conv_descriptor_offset_get (tree desc)
 {
-  return conv_descriptor_offset (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_offset (desc));
 }
 
 void
@@ -159,7 +160,7 @@ conv_descriptor_dtype (tree desc)
 tree
 gfc_conv_descriptor_dtype_get (tree desc)
 {
-  return conv_descriptor_dtype (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_dtype (desc));
 }
 
 /* Add code to BLOCK setting to VALUE the dtype field of the array descriptor
@@ -186,7 +187,7 @@ conv_descriptor_span (tree desc)
 tree
 gfc_conv_descriptor_span_get (tree desc)
 {
-  return conv_descriptor_span (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_span (desc));
 }
 
 void
@@ -218,7 +219,7 @@ conv_descriptor_rank (tree desc)
 tree
 gfc_conv_descriptor_rank_get (tree desc)
 {
-  return conv_descriptor_rank (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_rank (desc));
 }
 
 /* Add code to BLOCK setting to VALUE the rank of the array descriptor DESC.  
*/
@@ -262,7 +263,7 @@ conv_descriptor_version (tree desc)
 tree
 gfc_conv_descriptor_version_get (tree desc)
 {
-  return conv_descriptor_version (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_version (desc));
 }
 
 /* Add code to BLOCK setting to VALUE the descriptor DESC's format version.  */
@@ -299,7 +300,7 @@ conv_descriptor_elem_len (tree desc)
 tree
 gfc_conv_descriptor_elem_len_get (tree desc)
 {
-  return conv_descriptor_elem_len (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_elem_len (desc));
 }
 
 /* Add code to BLOCK setting to VALUE the descriptor DESC's size (in bytes) of
@@ -336,7 +337,7 @@ conv_descriptor_type (tree desc)
 tree
 gfc_conv_descriptor_type_get (tree desc)
 {
-  return conv_descriptor_type (desc);
+  return non_lvalue_loc (input_location, conv_descriptor_type (desc));
 }
 
 /* Add code to BLOCK setting to VALUE the type discriminator of the array
@@ -426,7 +427,7 @@ conv_descriptor_dimension (tree desc, tree dim)
 tree
 gfc_conv_descriptor_dimension_get (tree desc, tree dim)
 {
-  return conv_descriptor_dimension (desc, dim);
+  return non_lvalue_loc (input_location, conv_descriptor_dimension (desc, 
dim));
 }
 
 /* Return the value of the array access information of the (zero-based)
@@ -526,7 +527,7 @@ gfc_conv_descriptor_stride_get (tree desc, tree dim)
          || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT))
     return gfc_index_one_node;
 
-  return conv_descriptor_stride (desc, dim);
+  return non_lvalue_loc (input_location, conv_descriptor_stride (desc, dim));
 }
 
 /* Add code to BLOCK setting to VALUE the stride for the (zero-based) dimension
@@ -558,7 +559,7 @@ conv_descriptor_lbound (tree desc, tree dim)
 tree
 gfc_conv_descriptor_lbound_get (tree desc, tree dim)
 {
-  return conv_descriptor_lbound (desc, dim);
+  return non_lvalue_loc (input_location, conv_descriptor_lbound (desc, dim));
 }
 
 /* Add code to BLOCK setting to VALUE the lower bound for the (zero-based)
@@ -590,7 +591,7 @@ conv_descriptor_ubound (tree desc, tree dim)
 tree
 gfc_conv_descriptor_ubound_get (tree desc, tree dim)
 {
-  return conv_descriptor_ubound (desc, dim);
+  return non_lvalue_loc (input_location, conv_descriptor_ubound (desc, dim));
 }
 
 /* Add code to BLOCK setting to VALUE the upper bound for the (zero-based)
diff --git a/gcc/testsuite/gfortran.dg/PR93963.f90 
b/gcc/testsuite/gfortran.dg/PR93963.f90
index 6769d7fe0610..22092b224124 100644
--- a/gcc/testsuite/gfortran.dg/PR93963.f90
+++ b/gcc/testsuite/gfortran.dg/PR93963.f90
@@ -194,4 +194,4 @@ end program selr_p
 
 ! Special code for assumed rank - but only if not allocatable/pointer
 ! Thus, expect it only once for subroutine rank_o but not for rank_a or rank_p
-! { dg-final { scan-tree-dump-times "ubound != -1" 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?:NON_LVALUE_EXPR <)?ubound>? != -1} 1 
"original" } }
diff --git a/gcc/testsuite/gfortran.dg/array_reference_3.f90 
b/gcc/testsuite/gfortran.dg/array_reference_3.f90
index 85fa3317d985..9a0093e82eb1 100644
--- a/gcc/testsuite/gfortran.dg/array_reference_3.f90
+++ b/gcc/testsuite/gfortran.dg/array_reference_3.f90
@@ -65,7 +65,7 @@ contains
     call ccfis(x)
     if (any(x /= 13)) stop 13
     ! The cfi descriptor’s dim array is referenced with array indexing.
-    ! { dg-final { scan-tree-dump-times 
"cfi_descriptor->dim\\\[idx.\\d+\\\]\\.ubound = 
_cfi_descriptor->dim\\\[idx.\\d+\\\]\\.extent \\+ 
\\(cfi_descriptor->dim\\\[idx.\\d+\\\]\\.lbound \\+ -1\\);" 1 "original" } }
+    ! { dg-final { scan-tree-dump-times 
{cfi_descriptor->dim\[idx.\d+\]\.ubound = 
_cfi_descriptor->dim\[idx.\d+\]\.extent \+ \((?:NON_LVALUE_EXPR 
<)?cfi_descriptor->dim\[idx.\d+\]\.lbound>? \+ -1\);} 1 "original" } }
   end subroutine check_cfi_dim
   subroutine css(c) bind(c)
     character :: c
@@ -87,7 +87,7 @@ contains
     ptr_x(4) = 16
     if (any(ptr_x /= (/ 0, 0, 0, 16, 0, 0, 0 /))) stop 16
     ! pointers are referenced with pointer arithmetic.
-    ! { dg-final { scan-tree-dump-times "\\*\\(integer\\(kind=4\\) \\*\\) 
\\(ptr_x\\.data \\+ \\(sizetype\\) \\(\\(ptr_x\\.offset \\+ 
ptr_x\\.dim\\\[0\\\]\\.stride \\* 4\\) \\* ptr_x\\.span\\)\\) = 16;" 1 
"original" } }
+    ! { dg-final { scan-tree-dump-times {\*\(integer\(kind=4\) \*\) 
\(ptr_x\.data \+ \(sizetype\) \(\((?:NON_LVALUE_EXPR <)?ptr_x\.offset>? \+ 
(?:NON_LVALUE_EXPR <)?ptr_x\.dim\[0\]\.stride>? \* 4\) \* (?:NON_LVALUE_EXPR 
<)?ptr_x\.span>?\)\) = 16;} 1 "original" } }
   end subroutine check_ptr_elem
   subroutine check_ptr_scalarized
     integer, target :: y(8)
@@ -97,7 +97,7 @@ contains
     ptr_y = 17
     if (any(ptr_y /= 17)) stop 17
     ! pointers are referenced with pointer arithmetic.
-    ! { dg-final { scan-tree-dump-times "\\*\\(\\(integer\\(kind=4\\) \\*\\) 
D.\\d+ \\+ \\(sizetype\\) \\(\\(S.\\d+ \\* D.\\d+ \\+ D.\\d+\\) \\* 
ptr_y\\.span\\)\\) = 17;" 1 "original" } }
+    ! { dg-final { scan-tree-dump-times {\*\(\(integer\(kind=4\) \*\) D.\d+ \+ 
\(sizetype\) \(\(S.\d+ \* D.\d+ [+-] D.\d+\) \* (?:NON_LVALUE_EXPR 
<)?ptr_y\.span>?\)\) = 17;} 1 "original" } }
   end subroutine check_ptr_scalarized
   subroutine check_explicit_shape_elem
     integer :: explicit_shape_x(9)
@@ -129,7 +129,7 @@ contains
     allocatable_x(2) = 20
     if (any(allocatable_x /= (/ 0, 20, 0, 0 /))) stop 20
     ! Allocatable arrays are referenced with array indexing.
-    ! { dg-final { scan-tree-dump-times 
"\\(\\*\\(integer\\(kind=4\\)\\\[0:\\\] \\* restrict\\) 
allocatable_x\\.data\\)\\\[allocatable_x\\.offset \\+ 2\\\] = 20;" 1 "original" 
} }
+    ! { dg-final { scan-tree-dump-times {\*\(integer\(kind=4\)\[0:\] \* 
restrict\) allocatable_x\.data\)\[(?:NON_LVALUE_EXPR <)?allocatable_x\.offset>? 
\+ 2\] = 20;} 1 "original" } }
   end subroutine check_allocatable_array_elem
   subroutine check_allocatable_array_scalarized
     integer, allocatable :: allocatable_y(:)
@@ -152,7 +152,7 @@ contains
     call cares(x)
     if (any(x /= (/ 0, 0, 22, 0, 0, 0 /))) stop 22
     ! Assumed rank arrays are referenced with pointer arithmetic.
-    ! { dg-final { scan-tree-dump-times "\\*\\(\\(integer\\(kind=4\\) \\*\\) 
__tmp_INTEGER_4_rank_1\\.data \\+ \\(sizetype\\) 
\\(\\(__tmp_INTEGER_4_rank_1\\.offset \\+ 
__tmp_INTEGER_4_rank_1\\.dim\\\[0\\\]\\.stride \\* 3\\) \\* 4\\)\\) = 22;" 1 
"original" } }
+    ! { dg-final { scan-tree-dump-times {\*\(\(integer\(kind=4\) \*\) 
__tmp_INTEGER_4_rank_1\.data \+ \(sizetype\) \(\((?:NON_LVALUE_EXPR 
<)?__tmp_INTEGER_4_rank_1\.offset>? \+ (?:NON_LVALUE_EXPR 
<)?__tmp_INTEGER_4_rank_1\.dim\[0\]\.stride>? \* 3\) \* 4\)\) = 22;} 1 
"original" } }
   end subroutine check_assumed_rank_elem
   subroutine carss(assumed_rank_y)
     integer :: assumed_rank_y(..)
diff --git a/gcc/testsuite/gfortran.dg/bind-c-contiguous-2.f90 
b/gcc/testsuite/gfortran.dg/bind-c-contiguous-2.f90
index 5b546800e7ff..38e60ba897f3 100644
--- a/gcc/testsuite/gfortran.dg/bind-c-contiguous-2.f90
+++ b/gcc/testsuite/gfortran.dg/bind-c-contiguous-2.f90
@@ -60,12 +60,12 @@ end
 
 ! Copy in + out
 
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) 
xx->data \\+ xx->dtype.elem_len \\* arrayidx.\[0-9\]+, _xx->base_addr \\+ 
shift.\[0-9\]+, xx->dtype.elem_len\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(\(void \*\) xx->data 
\+ (?:NON_LVALUE_EXPR <)?xx->dtype\.elem_len>? \* arrayidx.[0-9]+, 
_xx->base_addr \+ shift.[0-9]+, (?:NON_LVALUE_EXPR <)?xx->dtype.elem_len>?\);} 
1 "original" } }
 ! { dg-final { scan-tree-dump-times "xx->data = \\(void \\* restrict\\) 
_xx->base_addr;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) 
xx->data \\+ xx->dtype.elem_len \\* arrayidx.\[0-9\]+, _xx->base_addr \\+ 
shift.\[0-9\]+, xx->dtype.elem_len\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) 
yy->data \\+ yy->dtype.elem_len \\* arrayidx.\[0-9\]+, _yy->base_addr \\+ 
shift.\[0-9\]+, yy->dtype.elem_len\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(\(void \*\) xx->data 
\+ (?:NON_LVALUE_EXPR <)?xx->dtype\.elem_len>? \* arrayidx.[0-9]+, 
_xx->base_addr \+ shift.[0-9]+, (?:NON_LVALUE_EXPR <)?xx->dtype.elem_len>?\);} 
1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(\(void \*\) yy->data 
\+ (?:NON_LVALUE_EXPR <)?yy->dtype\.elem_len>? \* arrayidx.[0-9]+, 
_yy->base_addr \+ shift.[0-9]+, (?:NON_LVALUE_EXPR <)?yy->dtype.elem_len>?\);} 
1 "original" } }
 ! { dg-final { scan-tree-dump-times "yy->data = \\(void \\* restrict\\) 
_yy->base_addr;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(_yy->base_addr \\+ 
shift.\[0-9\]+, \\(void \\*\\) yy->data \\+ yy->dtype.elem_len \\* 
arrayidx.\[0-9\]+, yy->dtype.elem_len\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(_yy->base_addr \+ 
shift.[0-9]+, \(void \*\) yy->data \+ (?:NON_LVALUE_EXPR 
<)?yy->dtype\.elem_len>? \* arrayidx.[0-9]+, (?:NON_LVALUE_EXPR 
<)?yy->dtype.elem_len>?\);} 1 "original" } }
 
 ! { dg-final { scan-tree-dump-times "zz = 
\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:zz.\[0-9\]+\\\] \\* restrict\\) 
_zz->base_addr;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) zz \\+ 
_zz->elem_len \\* arrayidx.\[0-9\]+, _zz->base_addr \\+ shift.\[0-9\]+, 
_zz->elem_len\\);" 1 "original" } }
@@ -73,10 +73,10 @@ end
 
 ! Copy in only
 
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) 
aa->data \\+ aa->dtype.elem_len \\* arrayidx.\[0-9\]+, _aa->base_addr \\+ 
shift.\[0-9\]+, aa->dtype.elem_len\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(\(void \*\) aa->data 
\+ (?:NON_LVALUE_EXPR <)?aa->dtype\.elem_len>? \* arrayidx.[0-9]+, 
_aa->base_addr \+ shift.[0-9]+, (?:NON_LVALUE_EXPR <)?aa->dtype.elem_len>?\);} 
1 "original" } }
 
 ! { dg-final { scan-tree-dump-times "aa->data = \\(void \\* restrict\\) 
_aa->base_addr;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) 
bb->data \\+ bb->dtype.elem_len \\* arrayidx.\[0-9\]+, _bb->base_addr \\+ 
shift.\[0-9\]+, bb->dtype.elem_len\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {__builtin_memcpy \(\(void \*\) bb->data 
\+ (?:NON_LVALUE_EXPR <)?bb->dtype\.elem_len>? \* arrayidx.[0-9]+, 
_bb->base_addr \+ shift.[0-9]+, (?:NON_LVALUE_EXPR <)?bb->dtype.elem_len>?\);} 
1 "original" } }
 ! { dg-final { scan-tree-dump-times "bb->data = \\(void \\* restrict\\) 
_bb->base_addr;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "cc = 
\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:cc.\[0-9\]+\\\] \\* restrict\\) 
_cc->base_addr;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "__builtin_memcpy \\(\\(void \\*\\) cc \\+ 
_cc->elem_len \\* arrayidx.\[0-9\]+, _cc->base_addr \\+ shift.\[0-9\]+, 
_cc->elem_len\\);" 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 
b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
index aa6a37b48504..7d79d9b44ac0 100644
--- a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
+++ b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
@@ -46,8 +46,8 @@ end
 
 ! { dg-final { scan-tree-dump "if \\(idx.. <= 1\\) goto L..;" "original" } }
 ! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].lower_bound = 0;" 
"original" } }
-! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].extent = 
\\(parm...dim\\\[idx..\\\].ubound - parm...dim\\\[idx..\\\].lbound\\) \\+ 1;" 
"original" } }
-! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].sm = 
parm...dim\\\[idx..\\\].stride \\* parm...span;" "original" } }
+! { dg-final { scan-tree-dump {cfi..\.dim\[idx..\].extent = 
\((?:NON_LVALUE_EXPR <)?parm..\.dim\[idx..\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?parm..\.dim\[idx..\]\.lbound>?\) \+ 1;} "original" } }
+! { dg-final { scan-tree-dump {cfi..\.dim\[idx..\].sm = (?:NON_LVALUE_EXPR 
<)?parm...dim\[idx..\].stride>? \* (?:NON_LVALUE_EXPR <)?parm..\.span>?;} 
"original" } }
 ! { dg-final { scan-tree-dump "idx.. = idx.. \\+ 1;" "original" } }
 
 ! { dg-final { scan-tree-dump "test \\(&cfi..\\);" "original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_this_image_1.f90 
b/gcc/testsuite/gfortran.dg/coarray_lib_this_image_1.f90
index 7939a797501a..6f46c4c5243e 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lib_this_image_1.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lib_this_image_1.f90
@@ -19,7 +19,7 @@ end
 ! { dg-final { scan-tree-dump-times "bar \\(real\\(kind=4\\)\\\[2\\\] \\* 
restrict x, void \\* restrict caf_token.., integer\\(kind=\[48\]\\) 
caf_offset..\\)" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mylcobound = 5;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "parm...dim\\\[1\\\].lbound = 5;" 1 
"original" } }
-! { dg-final { scan-tree-dump-times "myucobound =\[^\n\r\]* 
parm...dim\\\[1\\\].lbound \\+ \[^\n\r]*_gfortran_caf_num_images \\(0B, 0B\\).? 
\\+ -?\[0-9\]+\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {myucobound =[^\n\r]* (?:NON_LVALUE_EXPR 
<)?parm..\.dim\[1\].lbound>? \+ [^\n\r]*_gfortran_caf_num_images \(0B, 0B\).? 
\+ -?[0-9]+\);} 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mylbound = 1;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mythis_image = _gfortran_caf_this_image 
\\(0B\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "bar \\(x, caf_token.., 0\\);" 1 
"original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_this_image_2.f90 
b/gcc/testsuite/gfortran.dg/coarray_lib_this_image_2.f90
index 31a7677ed0e1..e23bc5e6e38d 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lib_this_image_2.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lib_this_image_2.f90
@@ -19,7 +19,7 @@ end
 ! { dg-final { scan-tree-dump-times "bar \\(struct array02_real\\(kind=4\\) & 
restrict x, void \\* restrict caf_token.., integer\\(kind=\[48\]\\) 
caf_offset..\\)" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mylcobound = 5;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "parm...dim\\\[1\\\].lbound = 5;" 1 
"original" } }
-! { dg-final { scan-tree-dump-times "myucobound =\[^\n\r\]* 
parm...dim\\\[1\\\].lbound \\+ \[^\n\r\]*_gfortran_caf_num_images \\(0B, 
0B\\).? \\+ -?\[0-9\]+\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {myucobound =[^\n\r]* (?:NON_LVALUE_EXPR 
<)?parm..\.dim\[1\]\.lbound>? \+ [^\n\r]*_gfortran_caf_num_images \(0B, 0B\).? 
\+ -?[0-9]+\);} 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mylbound = 1;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "mythis_image = _gfortran_caf_this_image 
\\(0B\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "bar \\(&parm.\[0-9\]+, 
caf_token.\[0-9\]+, \\(integer\\(kind=\[48\]\\)\\) parm.\[0-9\]+.data - 
\\(integer\\(kind=\[48\]\\)\\) x\\);" 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90 
b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
index 4f4bdde856d9..cf1a3276bd32 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
@@ -35,12 +35,12 @@ end
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 0, 0, 
0B, 0B, 0B, 0\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 0, 
0, 0B, 0B, 0\\);" 1 "original" } }
 
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 
.*\\(\\(3 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR 
<parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) 
\\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 
0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - 
parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound 
- parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - 
parm.\\d+.dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 
.*\\(\\(2 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR 
<parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) 
\\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 
0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - 
parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound 
- parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - 
parm.\\d+.dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_lock \(caf_token.., .*\(\(3 
- (?:NON_LVALUE_EXPR <)?parm.\d+\.dim\[0\]\.lbound>?\) \+ 
\(\((?:NON_LVALUE_EXPR <)?parm.\d+\.dim\[0\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?\) \+ 1\) \* \(3 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[1\]\.lbound>?\)\), 0, 0B, &ii, 0B, 0\);|_gfortran_caf_lock 
\(caf_token.1, \(.*?\) \(\(3 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?\) \+ \(MAX_EXPR <(?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?, -1> \+ 1\) \* \(3 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[1\]\.lbound>?\)\), 0, 0B, &ii, 0B, 0\);} 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_unlock \(caf_token.., 
.*\(\(2 - (?:NON_LVALUE_EXPR <)?parm.\d+\.dim\[0\]\.lbound>?\) \+ 
\(\(parm.\d+\.dim\[0\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?\) \+ 1\) \* \(3 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[1\]\.lbound>?\)\), 0, &ii, 0B, 0\);|_gfortran_caf_unlock 
\(caf_token.., \(.*?\) \(\(2 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?\) \+ \(MAX_EXPR <(?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[0\]\.lbound>?, -1> \+ 1\) \* \(3 - (?:NON_LVALUE_EXPR 
<)?parm.\d+\.dim\[1\]\.lbound>?\)\), 0, &ii, 0B, 0\);} 1 "original" } }
 
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, 
\\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), 
&acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - 
three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, 
\\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 
0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, 
&ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_lock \(three.token, 0, 
\(integer\(kind=4\)\) \(5 - (?:NON_LVALUE_EXPR <)?three.dim\[0\].lbound>?\), 
&acquired.[0-9]+, 0B, 0B, 0\);|_gfortran_caf_lock \(three.token, 0, 5 - 
(?:NON_LVALUE_EXPR <)?three.dim\[0\].lbound>?, &acquired.[0-9]+, 0B, 0B, 0\);} 
1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_unlock \(three.token, 0, 
\(integer\(kind=4\)\) \(8 - (?:NON_LVALUE_EXPR <)?three.dim\[0\].lbound>?\), 
&ii, 0B, 0\);|_gfortran_caf_unlock \(three.token, 0, 8 - (?:NON_LVALUE_EXPR 
<)?three.dim\[0\].lbound>?, &ii, 0B, 0\);} 1 "original" } }
 
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(four.token, .*\\(1 
- four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(7 - 
four.dim\\\[1\\\].lbound\\), &acquired.\[0-9\]+, &ii, 0B, 
0\\);|_gfortran_caf_lock \\(four.token, \[^\n\r]*1 - 
four.dim\\\[0\\\].lbound\\)?, 7 - four.dim\\\[1\\\].lbound, &acquired.\[0-9\]+, 
&ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(four.token, 
.*\\(2 - four.dim\\\[0\\\].lbound\\), \\(integer\\(kind=4\\)\\) \\(8 - 
four.dim\\\[1\\\].lbound\\), 0B, 0B, 0\\);|_gfortran_caf_unlock \\(four.token, 
\[^\n\r]*2 - four.dim\\\[0\\\].lbound\\)?, 8 - four.dim\\\[1\\\].lbound, 0B, 
0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_lock \(four.token, .*\(1 - 
(?:NON_LVALUE_EXPR <)?four.dim\[0\].lbound>?\), \(integer\(kind=4\)\) \(7 - 
(?:NON_LVALUE_EXPR <)?four.dim\[1\].lbound>?\), &acquired.[0-9]+, &ii, 0B, 
0\);|_gfortran_caf_lock \(four.token, [^\n\r]*1 - (?:NON_LVALUE_EXPR 
<)?four.dim\[0\].lbound>?\)?, 7 - (?:NON_LVALUE_EXPR <)?four.dim\[1\].lbound>?, 
&acquired.[0-9]+, &ii, 0B, 0\);} 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_unlock \(four.token, .*\(2 
- (?:NON_LVALUE_EXPR <)?four.dim\[0\].lbound>?\), \(integer\(kind=4\)\) \(8 - 
(?:NON_LVALUE_EXPR <)?four.dim\[1\].lbound>?\), 0B, 0B, 
0\);|_gfortran_caf_unlock \(four.token, \[^\n\r]*2 - (?:NON_LVALUE_EXPR 
<)?four.dim\[0\].lbound>?\)?, 8 - four.dim\[1\].lbound, 0B, 0B, 0\);} 1 
"original" } }
 
diff --git a/gcc/testsuite/gfortran.dg/contiguous_3.f90 
b/gcc/testsuite/gfortran.dg/contiguous_3.f90
index ba0ccce8f9ee..05bd785be464 100644
--- a/gcc/testsuite/gfortran.dg/contiguous_3.f90
+++ b/gcc/testsuite/gfortran.dg/contiguous_3.f90
@@ -35,8 +35,8 @@ end subroutine t2
 
 ! { dg-final { scan-tree-dump-times "= a1->dim.0..stride;" 0 "original" } }
 ! { dg-final { scan-tree-dump-times "= b1->dim.0..stride;" 0 "original" } }
-! { dg-final { scan-tree-dump-times "= c2->dim.0..stride;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "= d2->dim.0..stride;" 1 "original" } }
+! { dg-final { scan-tree-dump-times {= (?:NON_LVALUE_EXPR 
<)?c2->dim\[0\]\.stride>?;} 1 "original" } }
+! { dg-final { scan-tree-dump-times {= (?:NON_LVALUE_EXPR 
<)?d2->dim\[0\]\.stride>?;} 1 "original" } }
 
 
 subroutine test3()
diff --git a/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90 
b/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
index afdf9b34d4bc..593296c0a7e6 100644
--- a/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
+++ b/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
@@ -22,4 +22,4 @@ program bug
   stop
 end program bug
 
-! { dg-final { scan-tree-dump-times "iszs = \\(integer\\(kind=2\\)\\) MAX_EXPR 
<\\(a.dim.0..ubound - a.dim.0..lbound\\) \\+ 1, 0>;" 1 "original" } }
+! { dg-final { scan-tree-dump-times {iszs = \(integer\(kind=2\)\) MAX_EXPR 
<\((?:NON_LVALUE_EXPR <)?a\.dim\[0\]\.ubound>? - (?:NON_LVALUE_EXPR 
<)?a\.dim\[0\]\.lbound>?\) \+ 1, 0>;} 1 "original" } }
diff --git a/libgomp/testsuite/libgomp.fortran/allocators-1.f90 
b/libgomp/testsuite/libgomp.fortran/allocators-1.f90
index 935a37cd9594..f1d81d58677a 100644
--- a/libgomp/testsuite/libgomp.fortran/allocators-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/allocators-1.f90
@@ -48,8 +48,8 @@ end
 ! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) 
__builtin_GOMP_alloc \\(512, 20, D\\.\[0-9\]+\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) 
__builtin_GOMP_alloc \\(4, 28, 0B\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "a.dtype.version = 1;" 2 "original" } }
-! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) 
\\(a.dtype.version == 1 \\? __builtin_omp_realloc \\(\\(void \\*\\) a.data, 4, 
0B, 0B\\) : __builtin_realloc \\(\\(void \\*\\) a.data, 4\\)\\);" 2 "original" 
} }
-! { dg-final { scan-tree-dump-times "if \\(a.dtype.version == 1\\)" 3 
"original" } }
+! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) 
\\((?:NON_LVALUE_EXPR <)?a.dtype.version>? == 1 \\? __builtin_omp_realloc 
\\(\\(void \\*\\) a.data, 4, 0B, 0B\\) : __builtin_realloc \\(\\(void \\*\\) 
a.data, 4\\)\\);" 2 "original" } }
+! { dg-final { scan-tree-dump-times "if \\((?:NON_LVALUE_EXPR 
<)?a.dtype.version>? == 1\\)" 3 "original" } }
 ! { dg-final { scan-tree-dump-times "__builtin_GOMP_free 
\\(\\(integer\\(kind=4\\)\\\[0:\\\] \\* restrict\\) a.data, 0B\\);" 3 
"original" } }
 ! { dg-final { scan-tree-dump-times "a.dtype.version = 0;" 3 "original" } }

Reply via email to