[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:563d4bdc20233c0797c8b38639240ee18fc90837

commit 563d4bdc20233c0797c8b38639240ee18fc90837
Author: Mikael Morin <[email protected]>
Date:   Mon Aug 10 22:21:00 2026 +0200

    fortran: array descriptor: Use default arguments instead of overloads [PR122521]
    
    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 | 10 +---------
 gcc/fortran/trans-descriptor.h  |  4 ++--
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 8c959ed0852b..35293c8848f7 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -868,19 +868,11 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar,
 }
 
 
-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);
-}
-
-
 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.