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

commit e411ac7793aad403f2ae5bf85e322afad37aefda
Author: Mikael Morin <[email protected]>
Date:   Tue Jul 1 22:20:34 2025 +0200

    fortran: array descriptor: Unify locations in accessors
    
    The different accessor functions have small variations in the way locations
    are set.  Unify them.
    
    gcc/fortran/ChangeLog:
    
            * trans-descriptor.cc (gfc_conv_descriptor_data_get,
            gfc_conv_descriptor_data_set, gfc_conv_descriptor_offset_set,
            gfc_conv_descriptor_span_set, gfc_conv_descriptor_stride_set,
            gfc_conv_descriptor_lbound_set, gfc_conv_descriptor_ubound_set):
            Use an explicit location.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 6e0a5c734064..4b7c3d0700d2 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -113,10 +113,10 @@ gfc_conv_descriptor_data_get (tree desc)
   tree type = TREE_TYPE (desc);
   gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
 
+  location_t loc = input_location;
   tree field = conv_descriptor_data (desc);
   tree target_type = GFC_TYPE_ARRAY_DATAPTR_TYPE (type);
-  tree t = fold_convert (target_type, field);
-  return non_lvalue_loc (input_location, t);
+  return non_lvalue_loc (loc, fold_convert_loc (loc, target_type, field));
 }
 
 /* This provides WRITE access to the data field.  */
@@ -124,8 +124,10 @@ gfc_conv_descriptor_data_get (tree desc)
 void
 gfc_conv_descriptor_data_set (stmtblock_t *block, tree desc, tree value)
 {
+  location_t loc = input_location;
   tree field = conv_descriptor_data (desc);
-  gfc_add_modify (block, field, fold_convert (TREE_TYPE (field), value));
+  gfc_add_modify_loc (loc, block, field,
+                     fold_convert_loc (loc, TREE_TYPE (field), value));
 }
 
 
@@ -144,8 +146,10 @@ gfc_conv_descriptor_offset_get (tree desc)
 void
 gfc_conv_descriptor_offset_set (stmtblock_t *block, tree desc, tree value)
 {
+  location_t loc = input_location;
   tree t = conv_descriptor_offset (desc);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
+  gfc_add_modify_loc (loc, block, t,
+                     fold_convert_loc (loc, TREE_TYPE (t), value));
 }
 
 
@@ -193,8 +197,10 @@ gfc_conv_descriptor_span_get (tree desc)
 void
 gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
 {
+  location_t loc = input_location;
   tree t = gfc_conv_descriptor_span (desc);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
+  gfc_add_modify_loc (loc, block, t,
+                     fold_convert_loc (loc, TREE_TYPE (t), value));
 }
 
 
@@ -505,8 +511,10 @@ void
 gfc_conv_descriptor_stride_set (stmtblock_t *block, tree desc,
                                tree dim, tree value)
 {
+  location_t loc = input_location;
   tree t = get_descriptor_stride (desc, dim);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
+  gfc_add_modify_loc (loc, block, t,
+                     fold_convert_loc (loc, TREE_TYPE (t), value));
 }
 
 
@@ -535,8 +543,10 @@ void
 gfc_conv_descriptor_lbound_set (stmtblock_t *block, tree desc,
                                tree dim, tree value)
 {
+  location_t loc = input_location;
   tree t = get_descriptor_lbound (desc, dim);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
+  gfc_add_modify_loc (loc, block, t,
+                     fold_convert_loc (loc, TREE_TYPE (t), value));
 }
 
 
@@ -565,8 +575,10 @@ void
 gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree desc,
                                tree dim, tree value)
 {
+  location_t loc = input_location;
   tree t = get_descriptor_ubound (desc, dim);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
+  gfc_add_modify_loc (loc, block, t,
+                     fold_convert_loc (loc, TREE_TYPE (t), value));
 }

Reply via email to