[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Use default arguments instead of overloads [PR122521]

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:40df2b0d071f5885af847596913a063e841a4ec2

commit 40df2b0d071f5885af847596913a063e841a4ec2
Author: Mikael Morin <[email protected]>
Date:   Tue Aug 18 12:03:42 2026 +0200

    fortran: array descriptor: Use default arguments instead of overloads [PR122521]
    
    Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
    
    -- >8 --
    
    There are two gfc_set_descriptor_from_scalar overloads, the second one
    forwarding to the first with default argument values.  Add default arguments
    to the first one and remove the second.
    
    gcc/fortran/ChangeLog:
    
            * trans-descriptor.h (gfc_set_descriptor_from_scalar): Add
            default argument values, and remove overload declaration.
            * trans-descriptor.cc (gfc_set_descriptor_from_scalar): Remove
            overload.
            (gfc_set_descriptor_from_scalar_class): Skip argument values
            matching the default ones.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 15 +--------------
 gcc/fortran/trans-descriptor.h  |  4 ++--
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 8f0ee7c58f47..f7b33e4c7642 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -883,18 +883,6 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar,
 }
 
 
-/* Add code to BLOCK initializing the scalar descriptor DESCR, so that it
-   represents the same data as the scalar expression SCALAR.  This is used to
-   implement the argument association between the actual argument SCALAR_EXPR
-   and an assumed-rank dummy argument.  */
-
-void
-gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar)
-{
-  gfc_set_descriptor_from_scalar (block, descr, scalar, NULL_TREE, NULL_TREE);
-}
-
-
 /* Add code to BLOCK initializing the scalar descriptor DESCR, so that it
    represents the same data as the middle-end scalar class descriptor SCALAR
    corresponding to the front-end scalar polymorphic expression SCALAR_EXPR.
@@ -905,8 +893,7 @@ void
 gfc_set_descriptor_from_scalar_class (stmtblock_t *block, tree descr,
 				      tree scalar)
 {
-  tree tmp = gfc_class_data_get (scalar);
-  gfc_set_descriptor_from_scalar (block, descr, tmp, NULL_TREE, NULL_TREE);
+  gfc_set_descriptor_from_scalar (block, descr, gfc_class_data_get (scalar));
 }
 
 
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 9ccae12e11c6..a8eb3a6a207a 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -73,8 +73,8 @@ tree gfc_create_unallocated_library_result_descriptor (stmtblock_t *, tree,
 tree gfc_create_null_actual_descriptor (stmtblock_t *, gfc_typespec *,
 					symbol_attribute, int);
 
-void gfc_set_descriptor_from_scalar (stmtblock_t *, tree, tree, tree, tree);
-void gfc_set_descriptor_from_scalar (stmtblock_t *, tree, tree);
+void gfc_set_descriptor_from_scalar (stmtblock_t *, tree, tree,
+				     tree = NULL_TREE, tree = NULL_TREE);
 void gfc_set_descriptor_from_scalar_class (stmtblock_t *, tree, tree);
 
 tree gfc_conv_descriptor_size (tree, int);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.