aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog32
-rw-r--r--libgfortran/Makefile.am1
-rw-r--r--libgfortran/Makefile.in13
-rwxr-xr-xlibgfortran/configure129
-rw-r--r--libgfortran/gfortran.map1
-rw-r--r--libgfortran/io/format.c1
-rw-r--r--libgfortran/libgfortran.h5
-rw-r--r--libgfortran/runtime/deep_copy.c125
8 files changed, 237 insertions, 70 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index c4a8b8e..dd20782 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,35 @@
+2025-11-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/90374
+ PR libfortran/90374
+ * io/format.c (parse_format_list): Set exponent width to unspecified.
+
+2025-11-09 Mark Wielaard <mark@klomp.org>
+
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate.
+
+2025-11-08 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/121628
+ * Makefile.in: Keep continuation indentation within 80 columns.
+ * aclocal.m4: Regenerate.
+ * libgfortran.h: Drop unused forward declaration.
+
+2025-11-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/121628
+ * Makefile.am: Add runtime/deep_copy.c to source files.
+ * Makefile.in: Regenerate.
+ * gfortran.map: Export _gfortran_cfi_deep_copy_array symbol.
+ * libgfortran.h: Add prototype for internal_deep_copy_array.
+ * runtime/deep_copy.c: New file implementing runtime deep copy
+ helper for recursive allocatable array components.
+
+2025-11-03 Sam James <sam@gentoo.org>
+
+ * configure: Regenerate.
+
2025-10-05 Sam James <sam@gentoo.org>
* Makefile.in: Regenerate.
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index 4f3b303..46e7df5 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -218,6 +218,7 @@ endif
gfor_src= \
runtime/bounds.c \
runtime/compile_options.c \
+runtime/deep_copy.c \
runtime/memory.c \
runtime/string.c \
runtime/select.c
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index ce828b2..63c880c 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -231,8 +231,8 @@ libgfortran_la_LIBADD =
@LIBGFOR_MINIMAL_FALSE@ runtime/fpu.lo runtime/main.lo \
@LIBGFOR_MINIMAL_FALSE@ runtime/pause.lo runtime/stop.lo
am__objects_3 = runtime/bounds.lo runtime/compile_options.lo \
- runtime/memory.lo runtime/string.lo runtime/select.lo \
- $(am__objects_1) $(am__objects_2)
+ runtime/deep_copy.lo runtime/memory.lo runtime/string.lo \
+ runtime/select.lo $(am__objects_1) $(am__objects_2)
am__objects_4 = generated/matmul_i1.lo generated/matmul_i2.lo \
generated/matmul_i4.lo generated/matmul_i8.lo \
generated/matmul_i16.lo generated/matmul_r4.lo \
@@ -1013,9 +1013,9 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
@IEEE_SUPPORT_TRUE@ieee/ieee_exceptions.F90 \
@IEEE_SUPPORT_TRUE@ieee/ieee_features.F90
-gfor_src = runtime/bounds.c runtime/compile_options.c runtime/memory.c \
- runtime/string.c runtime/select.c $(am__append_6) \
- $(am__append_7)
+gfor_src = runtime/bounds.c runtime/compile_options.c \
+ runtime/deep_copy.c runtime/memory.c runtime/string.c \
+ runtime/select.c $(am__append_6) $(am__append_7)
i_matmul_c = \
generated/matmul_i1.c \
generated/matmul_i2.c \
@@ -1981,6 +1981,8 @@ runtime/bounds.lo: runtime/$(am__dirstamp) \
runtime/$(DEPDIR)/$(am__dirstamp)
runtime/compile_options.lo: runtime/$(am__dirstamp) \
runtime/$(DEPDIR)/$(am__dirstamp)
+runtime/deep_copy.lo: runtime/$(am__dirstamp) \
+ runtime/$(DEPDIR)/$(am__dirstamp)
runtime/memory.lo: runtime/$(am__dirstamp) \
runtime/$(DEPDIR)/$(am__dirstamp)
runtime/string.lo: runtime/$(am__dirstamp) \
@@ -4490,6 +4492,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/bounds.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/compile_options.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/convert_char.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/deep_copy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/environ.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/fpu.Plo@am__quote@
diff --git a/libgfortran/configure b/libgfortran/configure
index c6b00a9..5cf3bf6 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -7815,15 +7815,7 @@ rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $clang_cv_is_clang" >&5
$as_echo "$clang_cv_is_clang" >&6; }
- plugin_file=
- if test $clang_cv_is_clang = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang plugin file" >&5
-$as_echo_n "checking for clang plugin file... " >&6; }
- plugin_names="LLVMgold.so"
- for plugin in $plugin_names; do
- plugin_file=`${CC} ${CFLAGS} --print-file-name $plugin`
- if test x$plugin_file = x$plugin; then
- if test -n "$ac_tool_prefix"; then
+ if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}llvm-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}llvm-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -7915,22 +7907,31 @@ else
LLVM_CONFIG="$ac_cv_prog_LLVM_CONFIG"
fi
- if test "$?" != 0; then
- as_fn_error $? "Required tool 'llvm-config' not found on PATH." "$LINENO" 5
- fi
- clang_lib_dir=`$LLVM_CONFIG --libdir`
- if test -f $clang_lib_dir/$plugin; then
- plugin_file=$clang_lib_dir/$plugin
- fi
- if test x$plugin_file != x$plugin; then
+ plugin_file=
+ if test $clang_cv_is_clang = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang plugin file" >&5
+$as_echo_n "checking for clang plugin file... " >&6; }
+ plugin_names="LLVMgold.so"
+ for plugin in $plugin_names; do
+ plugin_file=`${CC} ${CFLAGS} --print-file-name $plugin`
+ if test "$plugin_file" != "$plugin"; then
+ break;
+ fi
+ if test -n "${LLVM_CONFIG}"; then
+ plugin_file=`${LLVM_CONFIG} --libdir`/$plugin
+ if test -f "$plugin_file"; then
break;
fi
fi
+ plugin_file=
done
- if test -z $plugin_file; then
- as_fn_error $? "Couldn't find clang plugin file for $CC." "$LINENO" 5
- fi
- if test -n "$ac_tool_prefix"; then
+ if test -z "$plugin_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_file" >&5
+$as_echo "$plugin_file" >&6; }
+ if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -8022,42 +8023,26 @@ else
AR="$ac_cv_prog_AR"
fi
- if test "${AR}" = "" ; then
- as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
- fi
- plugin_option="--plugin $plugin_file"
- touch conftest.c
- ${AR} $plugin_option rc conftest.a conftest.c
- if test "$?" != 0; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+ if test -z "${AR}"; then
+ as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+ fi
+ plugin_option="--plugin $plugin_file"
+ touch conftest.c
+ ${AR} $plugin_option rc conftest.a conftest.c
+ if test "$?" != 0; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
- plugin_file=
+ plugin_file=
+ fi
+ rm -f conftest.*
fi
- rm -f conftest.*
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_file" >&5
-$as_echo "$plugin_file" >&6; }
fi
plugin_file="$plugin_file"
if test -n "$plugin_file"; then
plugin_option="--plugin $plugin_file"
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
-$as_echo_n "checking for -plugin option... " >&6; }
-
-plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
-plugin_option=
-for plugin in $plugin_names; do
- plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
- if test x$plugin_so = x$plugin; then
- plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
- fi
- if test x$plugin_so != x$plugin; then
- plugin_option="--plugin $plugin_so"
- break
- fi
-done
-if test -n "$ac_tool_prefix"; then
+ if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -8149,25 +8134,39 @@ else
AR="$ac_cv_prog_AR"
fi
-if test "${AR}" = "" ; then
+if test -z "${AR}"; then
as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
fi
-touch conftest.c
-${AR} $plugin_option rc conftest.a conftest.c
-if test "$?" != 0; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
-$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
- plugin_option=
-fi
-rm -f conftest.*
-if test -n "$plugin_option"; then
- plugin_option="$plugin_option"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
-$as_echo "$plugin_option" >&6; }
-else
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
+$as_echo_n "checking for -plugin option... " >&6; }
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+plugin_option=
+for plugin in $plugin_names; do
+ plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+ if test x$plugin_so = x$plugin; then
+ plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+ fi
+ if test x$plugin_so != x$plugin; then
+ plugin_option="--plugin $plugin_so"
+ break
+ fi
+done
+if test -z "$plugin_option"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
+$as_echo "$plugin_option" >&6; }
+ touch conftest.c
+ ${AR} $plugin_option rc conftest.a conftest.c
+ if test "$?" != 0; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+ plugin_option=
+ fi
+ rm -f conftest.*
fi
+plugin_option="$plugin_option"
fi
if test -n "$ac_tool_prefix"; then
@@ -13222,7 +13221,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13225 "configure"
+#line 13224 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13328,7 +13327,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13331 "configure"
+#line 13330 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map
index 98808dc..fc01665 100644
--- a/libgfortran/gfortran.map
+++ b/libgfortran/gfortran.map
@@ -2037,4 +2037,5 @@ GFORTRAN_16 {
global:
_gfortran_string_split;
_gfortran_string_split_char4;
+ _gfortran_cfi_deep_copy_array;
} GFORTRAN_15.2;
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c
index 87e21a9..b125b47 100644
--- a/libgfortran/io/format.c
+++ b/libgfortran/io/format.c
@@ -945,6 +945,7 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd)
goto finished;
}
tail->u.real.w = 0;
+ tail->u.real.e = -1;
/* Look for the dot seperator. */
u = format_lex (fmt);
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 25c3cb6..f4c66d4 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -914,6 +914,11 @@ internal_proto(xcalloc);
extern void *xrealloc (void *, size_t);
internal_proto(xrealloc);
+extern void cfi_deep_copy_array (gfc_array_void *,
+ gfc_array_void *,
+ void (*copy_element) (void *, void *));
+export_proto(cfi_deep_copy_array);
+
/* environ.c */
extern void init_variables (void);
diff --git a/libgfortran/runtime/deep_copy.c b/libgfortran/runtime/deep_copy.c
new file mode 100644
index 0000000..6567400
--- /dev/null
+++ b/libgfortran/runtime/deep_copy.c
@@ -0,0 +1,125 @@
+/* Deep copy support for allocatable components in derived types.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "libgfortran.h"
+#include <string.h>
+
+/* Runtime helper for deep copying allocatable array components when the
+ element type contains nested allocatable components. The front end handles
+ allocation and deallocation; this helper performs element-wise copies using
+ the compiler-generated element copier so that recursion takes place at
+ runtime. */
+
+static inline size_t
+descriptor_elem_size (gfc_array_void *desc)
+{
+ size_t size = GFC_DESCRIPTOR_SIZE (desc);
+ return size == 0 ? 1 : size;
+}
+
+void
+cfi_deep_copy_array (gfc_array_void *dest, gfc_array_void *src,
+ void (*copy_element) (void *, void *))
+{
+ int rank;
+ size_t src_elem_size;
+ size_t dest_elem_size;
+ index_type extent[GFC_MAX_DIMENSIONS];
+ index_type src_stride_bytes[GFC_MAX_DIMENSIONS];
+ index_type dest_stride_bytes[GFC_MAX_DIMENSIONS];
+ index_type count[GFC_MAX_DIMENSIONS];
+ char *src_ptr;
+ char *dest_ptr;
+
+ if (src == NULL || dest == NULL)
+ return;
+
+ if (GFC_DESCRIPTOR_DATA (src) == NULL)
+ {
+ if (GFC_DESCRIPTOR_DATA (dest) != NULL)
+ internal_error (NULL, "cfi_deep_copy_array: destination must be "
+ "deallocated when source is not allocated");
+ return;
+ }
+
+ if (GFC_DESCRIPTOR_DATA (dest) == NULL)
+ internal_error (NULL, "cfi_deep_copy_array: destination not allocated");
+
+ rank = GFC_DESCRIPTOR_RANK (src);
+ src_elem_size = descriptor_elem_size (src);
+ dest_elem_size = descriptor_elem_size (dest);
+
+ if (rank <= 0)
+ {
+ memcpy (GFC_DESCRIPTOR_DATA (dest), GFC_DESCRIPTOR_DATA (src),
+ src_elem_size);
+ if (copy_element != NULL)
+ copy_element (GFC_DESCRIPTOR_DATA (dest),
+ GFC_DESCRIPTOR_DATA (src));
+ return;
+ }
+
+ for (int dim = 0; dim < rank; dim++)
+ {
+ extent[dim] = GFC_DESCRIPTOR_EXTENT (src, dim);
+ if (extent[dim] <= 0)
+ return;
+
+ src_stride_bytes[dim]
+ = GFC_DESCRIPTOR_STRIDE (src, dim) * src_elem_size;
+ dest_stride_bytes[dim]
+ = GFC_DESCRIPTOR_STRIDE (dest, dim) * dest_elem_size;
+ count[dim] = 0;
+ }
+
+ src_ptr = (char *) GFC_DESCRIPTOR_DATA (src);
+ dest_ptr = (char *) GFC_DESCRIPTOR_DATA (dest);
+
+ while (true)
+ {
+ memcpy (dest_ptr, src_ptr, src_elem_size);
+ if (copy_element != NULL)
+ copy_element (dest_ptr, src_ptr);
+
+ dest_ptr += dest_stride_bytes[0];
+ src_ptr += src_stride_bytes[0];
+ count[0]++;
+
+ int dim = 0;
+ while (count[dim] == extent[dim])
+ {
+ count[dim] = 0;
+ dest_ptr -= dest_stride_bytes[dim] * extent[dim];
+ src_ptr -= src_stride_bytes[dim] * extent[dim];
+ dim++;
+ if (dim == rank)
+ return;
+ count[dim]++;
+ dest_ptr += dest_stride_bytes[dim];
+ src_ptr += src_stride_bytes[dim];
+ }
+ }
+}
+
+export_proto(cfi_deep_copy_array);