]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agofortran: Fix debug info for unsigned(kind=1) and unsigned(kind=4) [PR120193]
Jakub Jelinek [Sat, 10 May 2025 19:20:09 +0000 (21:20 +0200)] 
fortran: Fix debug info for unsigned(kind=1) and unsigned(kind=4) [PR120193]

As the following testcase shows, debug info for unsigned(kind=1)
and unsigned(kind=4) vars is wrong while unsigned(kind=2), unsigned(kind=8)
and unsigned(kind=16) look right.
Instead of objects having unsigned(kind=1) type they have character(kind=1)
and instead of unsigned(kind=4) they have character(kind=4).
This means in gdb e.g. unsigned(kind=1) :: a(2) variable initialized to
97 will print as 'aa' rather than (97, 97) etc.
While there can be just one unsigned_char_type_node and one
unsigned_type_node type, each can have arbitrary number of variants
(e.g. consider C
typedef unsigned char uc;
where uc is a variant type to unsigned char) or even distinct types
with different TYPE_MAIN_VARIANT.

The following patch uses a variant of the character(kind=4) type
for unsigned(kind=4) and a distinct type based on character(kind=1)
type for unsigned(kind=1).  The reason for the latter is that
unsigned_char_type_node has TYPE_STRING_FLAG set on it, so it has
DW_AT_encoding DW_ATE_unsigned_char rather than DW_ATE_unsigned and
so the debugger then likes to print it as characters rather than numbers.
That is IMHO in Fortran desirable for character(kind=1) but not for
unsigned(kind=1).  I've made sure TYPE_CANONICAL of the unsigned(kind=1)
type is still character(kind=1), so they are considered compatible by
the middle-end also e.g. for aliasing etc.

2025-05-10  Jakub Jelinek  <jakub@redhat.com>

PR fortran/120193
* trans-types.cc (gfc_init_types): For flag_unsigned use
build_distinct_type_copy or build_variant_type_copy from
gfc_character_types[index_char] if index_char > -1 instead of
gfc_character_types[index_char] or
gfc_build_unsigned_type (&gfc_unsigned_kinds[index]).

* gfortran.dg/guality/pr120193.f90: New test.

(cherry picked from commit 512371d786e70d27dbaef38d60e9036c11f458c6)

2 months agoFortran: Fix handling of parsed format strings.
Jerry DeLisle [Sat, 31 May 2025 15:57:22 +0000 (08:57 -0700)] 
Fortran: Fix handling of parsed format strings.

Previously parsed strings with errors were being cached such
that subsequent use of the format string were not being
checked for errors.

PR libfortran/119856

libgfortran/ChangeLog:

* io/format.c (parse_format_list): Set the fmt->error
message for missing comma.
(parse_format): Do not cache the parsed format string
if a previous error ocurred.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr119856.f90: New test.

(cherry picked from commit 5ff48aabf76c8913c013f233d3f42bb217a16e7b)

2 months agoFortran: Adjust handling of optional comma in FORMAT.
Jerry DeLisle [Wed, 28 May 2025 14:56:12 +0000 (07:56 -0700)] 
Fortran: Adjust handling of optional comma in FORMAT.

This change adjusts the error messages for optional commas
in format strings to give a warning at compile time unless
-std=legacy is used. This is more consistant with the
runtime library. A missing comma separator should not be
encouraged as it is non-standard fortran.

PR fortran/119856

gcc/fortran/ChangeLog:

* io.cc: Set missing comma error checks to STD_STD_LEGACY.

gcc/testsuite/ChangeLog:

* gfortran.dg/comma_format_extension_1.f: Update dg-options to
"-std=legacy".
* gfortran.dg/comma_format_extension_3.f: Likewise.
* gfortran.dg/continuation_13.f90: Likewise.

(cherry picked from commit e2bf0b3910de7e65363435f0a7fa606e2448a677)

2 months agoDaily bump.
GCC Administrator [Mon, 2 Jun 2025 00:22:54 +0000 (00:22 +0000)] 
Daily bump.

2 months agolibstdc++: Compare keys and values separately in flat_map::operator==
Patrick Palka [Thu, 29 May 2025 14:12:23 +0000 (10:12 -0400)] 
libstdc++: Compare keys and values separately in flat_map::operator==

Instead of effectively doing a zipped comparison of the keys and values,
compare them separately to leverage the underlying containers' optimized
equality implementations.

libstdc++-v3/ChangeLog:

* include/std/flat_map (_Flat_map_impl::operator==): Compare
keys and values separately.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit ad96f0344adfc847874b34b43f30371979ae9963)

2 months agolibstdc++: Fix tuple/pair confusion with std::erase_if(flat_map) [PR120465]
Patrick Palka [Thu, 29 May 2025 14:11:57 +0000 (10:11 -0400)] 
libstdc++: Fix tuple/pair confusion with std::erase_if(flat_map) [PR120465]

std::erase_if for flat_map/multimap is implemented via ranges::erase_if
over a zip_view of the keys and values, the value_type of which is a
tuple, but the given predicate needs to be called with a pair (flat_map's
value_type).  So use a projection to convert the tuple into a suitable
pair.

PR libstdc++/120465

libstdc++-v3/ChangeLog:

* include/std/flat_map (_Flat_map_impl::_M_erase_if): Use a
projection with ranges::remove_if to pass a pair instead of
a tuple to the predicate.
* testsuite/23_containers/flat_map/1.cc (test07): Strengthen
to expect the argument passed to the predicate is a pair.
* testsuite/23_containers/flat_multimap/1.cc (test07): Likewise.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 589b27ec5769410e036df57645ff1eb7c765f692)

2 months agoDaily bump.
GCC Administrator [Sun, 1 Jun 2025 00:24:48 +0000 (00:24 +0000)] 
Daily bump.

2 months agoFortran: Fix c_associated argument checks.
Jerry DeLisle [Tue, 20 May 2025 02:41:16 +0000 (19:41 -0700)] 
Fortran: Fix c_associated argument checks.

PR fortran/120049

gcc/fortran/ChangeLog:

* check.cc (gfc_check_c_associated): Use new helper functions.
Only call check_c_ptr_1 if optional c_ptr_2 tests succeed.
(check_c_ptr_1): Handle only c_ptr_1 checks.
(check_c_ptr_2): Expand checks for c_ptr_2 and handle cases
where there is no derived pointer in the gfc_expr and check
the inmod_sym_id only if it exists. Rephrase error message.
* misc.cc (gfc_typename): Handle the case for BT_VOID rather
than throw an internal error.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr120049_a.f90: Update test directives.
* gfortran.dg/pr120049_b.f90: Update test directives
* gfortran.dg/pr120049_2.f90: New test.
* gfortran.dg/c_f_pointer_tests_6.f90: Adjust dg-error
directive.

Co-Authored-By: Steve Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 42983ffde6612b7f8a4e7ab3e76fa8b0d136e854)

2 months agoType mismatch for passed external function
Thomas Koenig [Fri, 30 May 2025 11:31:58 +0000 (13:31 +0200)] 
Type mismatch for passed external function

This obvious and simple patch fixes a 15/16 regression where the
typespec of a global function was in the RESULT clause and not
in the symbol itself.

gcc/fortran/ChangeLog:

PR fortran/120355
* interface.cc (compare_parameter): If the global function has a
result clause, take typespec from there for the comparison against
the dummy argument.

gcc/testsuite/ChangeLog:

PR fortran/120355
* gfortran.dg/interface_62.f90: New test.

(cherry picked from commit 0e77309047a7b479c89f03dcaf2994e050d0f33e)

2 months agoDaily bump.
GCC Administrator [Sat, 31 May 2025 00:24:57 +0000 (00:24 +0000)] 
Daily bump.

2 months agoOpenMP: Fix ICE and other issues in C/C++ metadirective error recovery.
Sandra Loosemore [Mon, 26 May 2025 19:21:48 +0000 (19:21 +0000)] 
OpenMP: Fix ICE and other issues in C/C++ metadirective error recovery.

The new testcase included in this patch used to ICE in gcc after
diagnosing the first error, and in g++ it only diagnosed the error in
the first metadirective, ignoring the second one.  The solution is to
make error recovery in the C front end more like that in the C++ front
end, and remove the code in both front ends that previously tried to
skip all the way over the following statement (instead of just to the
end of the metadirective pragma) after an error.

gcc/c/ChangeLog
* c-parser.cc (c_parser_skip_to_closing_brace): New, copied from
the equivalent function in the C++ front end.
(c_parser_skip_to_end_of_block_or_statement): Pass false to
the error flag.
(c_parser_omp_context_selector): Immediately return error_mark_node
after giving an error that the integer trait property is invalid,
similarly to C++ front end.
(c_parser_omp_context_selector_specification): Likewise handle
error return from c_parser_omp_context_selector similarly to C++.
(c_parser_omp_metadirective): Do not call
c_parser_skip_to_end_of_block_or_statement after an error.

gcc/cp/ChangeLog
* parser.cc (cp_parser_omp_metadirective): Do not call
cp_parser_skip_to_end_of_block_or_statement after an error.

gcc/testsuite/ChangeLog
* c-c++-common/gomp/declare-variant-2.c: Adjust patterns now that
C and C++ now behave similarly.
* c-c++-common/gomp/metadirective-error-recovery.c: New.

(cherry picked from commit 33b65e4d1c83808b54cd6b3fc97ebacc522b125d)

2 months agoOpenMP: Fix ICE in metadirective recovery after error [PR120180]
Sandra Loosemore [Sat, 24 May 2025 03:21:18 +0000 (03:21 +0000)] 
OpenMP: Fix ICE in metadirective recovery after error [PR120180]

It's not clear whether a metadirective in a loop nest is supposed to
be valid, but GCC certainly shouldn't be ICE'ing after diagnosing it
as an error.

gcc/c/ChangeLog
PR c/120180
* c-parser.cc (c_parser_omp_metadirective): Only consume the
token if it is the expected close paren.

gcc/cp/ChangeLog
PR c/120180
* parser.cc (cp_parser_omp_metadirective): Only consume the
token if it is the expected close paren.

gcc/testsuite/ChangeLog
PR c/120180
* c-c++-common/gomp/pr120180.c: New.

(cherry picked from commit 65e0ed2310a1b0d1a3255583bbfb8a8d86c5aea5)

2 months agotestsuite: Add testcase for GCC 13 branch s390 bug [PR120480]
Jakub Jelinek [Fri, 30 May 2025 12:35:12 +0000 (14:35 +0200)] 
testsuite: Add testcase for GCC 13 branch s390 bug [PR120480]

This got broken with r13-9727 and fixed with either of
r13-9729 or r13-9728.

2025-05-30  Jakub Jelinek  <jakub@redhat.com>

PR target/120480
* gcc.dg/pr120480.c: New test.

(cherry picked from commit c13d5b939fee565047394475952878dc5394fb74)

2 months agoDaily bump.
GCC Administrator [Fri, 30 May 2025 00:24:31 +0000 (00:24 +0000)] 
Daily bump.

2 months agoaarch64: Enable newly implemented features for FUJITSU-MONAKA
Yuta Mukai [Fri, 23 May 2025 04:51:11 +0000 (04:51 +0000)] 
aarch64: Enable newly implemented features for FUJITSU-MONAKA

This patch enables newly implemented features in GCC (FAMINMAX, FP8FMA,
FP8DOT2, FP8DOT4, LUT) for FUJITSU-MONAKA
processor (-mcpu=fujitsu-monaka).

2025-05-23  Yuta Mukai  <mukai.yuta@fujitsu.com>

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (fujitsu-monaka): Update ISA
features.

(cherry picked from commit 33ee574a7444b238005d89fdfdf2f21f50b1fc6e)

2 months agoDaily bump.
GCC Administrator [Thu, 29 May 2025 00:23:48 +0000 (00:23 +0000)] 
Daily bump.

2 months agolibgomp.fortran/metadirective-1.f90: Expect 'error:' for nvptx compile [PR118694]
Tobias Burnus [Wed, 28 May 2025 13:14:14 +0000 (15:14 +0200)] 
libgomp.fortran/metadirective-1.f90: Expect 'error:' for nvptx compile [PR118694]

This should have been part of commit r16-838-gb3d07ec7ac2ccd or
r16-883-g5d6ed6d604ff94 - all showing the same issue:
'!$omp target' followed by a metadirective with 'teams'; if
the metadirective cannot be early resolved, a diagnostic
error is shown about using directives between 'target' and
'teams'.

While the message is misleading, the problem is that the
host invokes 'target' differently when 'teams' is present;
in this case, host fallback + amdgcn offload require the
no-teams case, nvptx offload the teams case such that it
only can be resolved at runtime.

Mark the error as 'dg-bogus + xfail' to silence the FAIL,
when nvptx offloading is compiled for. (If not, the
metadirective can be resolved early during compilation.)

libgomp/ChangeLog:

PR middle-end/118694
* testsuite/libgomp.fortran/metadirective-1.f90: xfail when
compiling (also) for nvptx offloading as an error is then expected.

(cherry picked from commit 5b2e7afb135aa10e17e51b891d4b2c85ee541ade)

2 months agoDaily bump.
GCC Administrator [Wed, 28 May 2025 00:24:39 +0000 (00:24 +0000)] 
Daily bump.

2 months agoFix IPA-SRA issue with reverse SSO on specific pattern
Eric Botcazou [Tue, 27 May 2025 17:42:17 +0000 (19:42 +0200)] 
Fix IPA-SRA issue with reverse SSO on specific pattern

IPA-SRA generally works fine in the presence of reverse Scalar_Storage_Order
by propagating the relevant flag onto the newly generated MEM_REFs.  However
we have been recently faced with a specific Ada pattern that it does not
handle correctly: the 'Valid attribute applied to a floating-point component
of an aggregate type with reverse Scalar_Storage_Order.

The attribute is implemented by a call to a specific routine of the runtime
that expects a pointer to the object so, in the case of a component with
reverse SSO, the compiler first loads it from the aggregate to get back the
native storage order, but it does the load using an array of bytes instead
of the floating-point type to prevent the FPU from fiddling with the value,
which yields in the .original dump file:

  *(character[1:4] *) &F2b = VIEW_CONVERT_EXPR<character[1:4]>(item.f);

Of course that's a bit convoluted, but it does not seem that another method
would be simpler or even work, and using VIEW_CONVERT_EXPR to toggle the SSO
is supposed to be supported in any case (unlike aliasing or type punning).

The attached patch makes it work.  While the call to storage_order_barrier_p
from IPA-SRA is quite natural (the regular SRA has it too), the tweak to the
predicate itself is needed to handle the scalar->aggregate conversion, which
is admittedly awkward but again without clear alternative.

gcc/
* ipa-sra.cc (scan_expr_access): Also disqualify storage order
barriers from splitting.
* tree.h (storage_order_barrier_p): Also return false if the
operand of the VIEW_CONVERT_EXPR has reverse storage order.

gcc/testsuite/
* gnat.dg/sso19.adb: New test.
* gnat.dg/sso19_pkg.ads, gnat.dg/sso19_pkg.adb: New helper.

2 months agodoc: Fix typo in description of nonstring attribute
Jonathan Wakely [Tue, 27 May 2025 08:11:58 +0000 (09:11 +0100)] 
doc: Fix typo in description of nonstring attribute

gcc/ChangeLog:

* doc/extend.texi (Common Variable Attributes): Fix typo in
description of nonstring.

(cherry picked from commit 351e60095cfaa73b5ac69222d00e0cd4ae5725d4)

2 months agolibstdc++: Fix PSTL test iterators
Jonathan Wakely [Tue, 20 May 2025 12:18:52 +0000 (13:18 +0100)] 
libstdc++: Fix PSTL test iterators

These were fixed upstream by:
https://github.com/uxlfoundation/oneDPL/pull/534
https://github.com/uxlfoundation/oneDPL/pull/546

libstdc++-v3/ChangeLog:

* testsuite/util/pstl/test_utils.h (ForwardIterator::operator++):
Fix return type.
(BidirectionalIterator::operator++): Likewise.
(BidirectionalIterator::operator--): Likewise.

(cherry picked from commit c0a2526f099dfa52df5daa1432ff583ae6af0d5f)

2 months agolibstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]
Jonathan Wakely [Wed, 21 May 2025 14:29:02 +0000 (15:29 +0100)] 
libstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]

Because this constructor delegates to vector(a) the object has been
fully constructed and the destructor will run if an exception happens.
That means we need to set _M_finish == _M_start so that the destructor
doesn't try to destroy any elements.

libstdc++-v3/ChangeLog:

PR libstdc++/120367
* include/bits/stl_vector.h (_M_range_initialize): Initialize
_M_impl._M_finish.
* testsuite/23_containers/vector/cons/from_range.cc: Check with
a type that throws on construction.
exceptions during construction.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
(cherry picked from commit 04f2be72b1deecd6c6d454e000cfc0cb16db957c)

2 months agoAVR: target/120442 - Support f7_fdim / fdiml in LibF7.
Georg-Johann Lay [Tue, 27 May 2025 10:03:13 +0000 (12:03 +0200)] 
AVR: target/120442 - Support f7_fdim / fdiml in LibF7.

Add Support for fdiml.
PR target/120442
libgcc/config/avr/libf7/
* libf7-common.mk (LIBF_C_PARTS, m_ddd): Add fdim.
* libf7.h (f7_fdim): New proto.
* libf7.c (f7_fdim): New function.
* f7renames.sh (f7_fdim): Add rename.
* f7-wraps.h: Rebuild
* f7-renames.h: Rebuild

(cherry picked from commit 6045de6596d09f3cf7ae3f552b56d7e5df17a899)

2 months agoAVR: target/120441 - Fix f7_exp for |x| ≥ 512.
Georg-Johann Lay [Tue, 27 May 2025 07:43:57 +0000 (09:43 +0200)] 
AVR: target/120441 - Fix f7_exp for |x| ≥ 512.

f7_exp limited exponents to 512, but 1023 * ln2 ≈ 709,
hence 1024 is a correct limit.

libgcc/config/avr/libf7/
PR target/120441
* libf7.c (f7_exp): Limit aa->expo to 10 (not to 9).

(cherry picked from commit 672569cee76a1927d14b5eb754a5ff0b9cee1bc8)

2 months agoDaily bump.
GCC Administrator [Tue, 27 May 2025 00:26:29 +0000 (00:26 +0000)] 
Daily bump.

2 months agoc-c++-common/gomp/{attrs-,}metadirective-3.c: Fix expected result [PR118694]
Tobias Burnus [Mon, 26 May 2025 17:50:40 +0000 (19:50 +0200)] 
c-c++-common/gomp/{attrs-,}metadirective-3.c: Fix expected result [PR118694]

With compilation for nvptx enabled, two issues showed up:
(a) "error: 'target' construct with nested 'teams' construct contains
     directives outside of the 'teams' construct"
    See PR comment 9 why this is difficult to fix.
Solution: Add dg-bogus and accept/expect the error for 'target offload_nvptx'.

(b) The assumptions about the dump for 'target offload_nvptx' were wrong
    as the metadirective was already expanded to a OMP_NEXT_VARIANT
    construct such that no 'omp metadirective' was left in either case.
Solution: Check that no 'omp metadirective' is left; additionally, expect
either OMP_NEXT_VARIANT (when offload_nvptx is available) or no 'teams'
directive at all (if not).

gcc/testsuite/ChangeLog:

PR middle-end/118694
* c-c++-common/gomp/attrs-metadirective-3.c: Change to never
expect 'omp metadirective' in the dump. If !offload_nvptx, check
that no 'teams' shows up in the dump; for offload_nvptx, expect
OMP_NEXT_VARIANT and an error about directive between 'target'
and 'teams'.
* c-c++-common/gomp/metadirective-3.c: Likewise.

(cherry picked from commit 5d6ed6d604ff949b650e48fa4eaed3ec8b6489c1)

2 months agolibgomp.c-c++-common/metadirective-1.c: Expect 'error:' for nvptx compile [PR118694]
Tobias Burnus [Fri, 23 May 2025 09:30:48 +0000 (11:30 +0200)] 
libgomp.c-c++-common/metadirective-1.c: Expect 'error:' for nvptx compile [PR118694]

OpenMP's 'target teams' is strictly coupled with 'teams'; if the latter
exists, the kernel is launched in directly with multiple teams. Thus,
the host has to know whether the teams construct exists or not. For

   #pragma omp target
     #pragma omp metadirective when (device={arch("nvptx")}: teams loop)

it is simple when 'nvptx' offloading is not supported, otherwise it depends
on the default device at runtime as the user code asks for a single team for
host fallback and gcn offload and multiple for nvptx offload.

In any case, this commit ensures that no FAIL is printed, whatever a
future solution might look like. Instead of a dg-bogus combined with an
'xfail offload_target_nvptx', one an also argue that a dg-error for
'target offload_target_nvptx' would be more appropriate.

libgomp/ChangeLog:

PR middle-end/118694
* testsuite/libgomp.c-c++-common/metadirective-1.c: xfail when
compiling (also) for nvptx offloading as an error is then expected.

(cherry picked from commit b3d07ec7ac2ccd935a79b29e1a0e2eb16225286a)

2 months agoOpenMP/C++: Avoid ICE for BIND_EXPR with empty BIND_EXPR_BLOCK [PR120413]
Tobias Burnus [Mon, 26 May 2025 15:58:07 +0000 (17:58 +0200)] 
OpenMP/C++: Avoid ICE for BIND_EXPR with empty BIND_EXPR_BLOCK [PR120413]

PR c++/120413

gcc/cp/ChangeLog:

* semantics.cc (finish_omp_target_clauses_r): Handle
BIND_EXPR with empty BIND_EXPR_BLOCK.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/target-4.C: New test.

(cherry picked from commit 45b849d05b733a25ec7ce612229084b8f4b86d3d)

2 months agoDaily bump.
GCC Administrator [Mon, 26 May 2025 00:23:39 +0000 (00:23 +0000)] 
Daily bump.

2 months agoMicroBlaze does not support speculative execution (CVE-2017-5753)
Michael J. Eager [Sun, 25 May 2025 16:25:27 +0000 (09:25 -0700)] 
MicroBlaze does not support speculative execution (CVE-2017-5753)

gcc/
PR target/86772
Tracking CVE-2017-5753
* config/microblaze/microblaze.cc (TARGET_HAVE_SPECULATION_SAFE_VALUE):
Define to speculation_save_value_not_needed

2 months agoDaily bump.
GCC Administrator [Sun, 25 May 2025 00:24:49 +0000 (00:24 +0000)] 
Daily bump.

2 months agoDaily bump.
GCC Administrator [Sat, 24 May 2025 00:23:11 +0000 (00:23 +0000)] 
Daily bump.

2 months agoc++/modules: Fix merge of TLS init functions [PR120363]
Nathaniel Shead [Thu, 22 May 2025 12:16:22 +0000 (22:16 +1000)] 
c++/modules: Fix merge of TLS init functions [PR120363]

The PR notes that we missed setting DECL_CONTEXT on the TLS init
function; we missed this initially because this function is not created
in header units, only named modules.

I also noticed that 'DECL_CONTEXT (fn) = DECL_CONTEXT (var)' was
incorrect: for class members, this ends up having the modules merging
machinery treat the decl as a member function, which breaks when
attempting to dedup against an existing completed class type.  Instead
we can just use the global_namespace as the context, because the name of
the function is already mangled appropriately so that we'll match the
correct duplicates.

PR c++/120363

gcc/cp/ChangeLog:

* decl2.cc (get_tls_init_fn): Set context as global_namespace.
(get_tls_wrapper_fn): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr113292_a.H: Move to...
* g++.dg/modules/tls-1_a.H: ...here.
* g++.dg/modules/pr113292_b.C: Move to...
* g++.dg/modules/tls-1_b.C: ...here.
* g++.dg/modules/pr113292_c.C: Move to...
* g++.dg/modules/tls-1_c.C: ...here.
* g++.dg/modules/tls-2_a.C: New test.
* g++.dg/modules/tls-2_b.C: New test.
* g++.dg/modules/tls-2_c.C: New test.
* g++.dg/modules/tls-3.h: New test.
* g++.dg/modules/tls-3_a.H: New test.
* g++.dg/modules/tls-3_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 66e9a4f3083356b064cc64651edad466a56f762b)

2 months agoc++/modules: Fix stream-in of member using-decls [PR120414]
Nathaniel Shead [Fri, 23 May 2025 14:51:49 +0000 (00:51 +1000)] 
c++/modules: Fix stream-in of member using-decls [PR120414]

When streaming in a reference to a data member, we have an oversight
where we did not consider USING_DECLs, despite otherwise handling them
here the same as fields.  This patch corrects that mistake.

PR c++/120414

gcc/cp/ChangeLog:

* module.cc (trees_in::tree_node): Allow reading a USING_DECL
when streaming tt_data_member.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-31_a.C: New test.
* g++.dg/modules/using-31_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 43dddeef7a870ce4db7407f73660504b67a0a919)

2 months agoDaily bump.
GCC Administrator [Fri, 23 May 2025 00:24:13 +0000 (00:24 +0000)] 
Daily bump.

2 months agoFortran: default-initialization and functions returning derived type [PR85750]
Harald Anlauf [Thu, 15 May 2025 19:07:07 +0000 (21:07 +0200)] 
Fortran: default-initialization and functions returning derived type [PR85750]

Functions with non-pointer, non-allocatable result and of derived type did
not always get initialized although the type had default-initialization,
and a derived type component had the allocatable or pointer attribute.
Rearrange the logic when to apply default-initialization.

PR fortran/85750

gcc/fortran/ChangeLog:

* resolve.cc (resolve_symbol): Reorder conditions when to apply
default-initializers.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts.
* gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings.
* gfortran.dg/alloc_comp_class_4.f03: Likewise.
* gfortran.dg/allocate_with_source_14.f03: Adjust scan count.
* gfortran.dg/derived_constructor_comps_6.f90: Likewise.
* gfortran.dg/derived_result_5.f90: New test.

(cherry picked from commit d31ab498b12ebbe4f50acb2aa240ff92c73f310c)

2 months agoDaily bump.
GCC Administrator [Thu, 22 May 2025 00:23:47 +0000 (00:23 +0000)] 
Daily bump.

2 months agoDaily bump.
GCC Administrator [Wed, 21 May 2025 00:24:51 +0000 (00:24 +0000)] 
Daily bump.

2 months agoFortran: fix passing of inquiry ref of complex array to TRANSFER [PR102891]
Harald Anlauf [Tue, 6 May 2025 18:59:48 +0000 (20:59 +0200)] 
Fortran: fix passing of inquiry ref of complex array to TRANSFER [PR102891]

PR fortran/102891

gcc/fortran/ChangeLog:

* dependency.cc (gfc_ref_needs_temporary_p): Within an array
reference, inquiry references of complex variables generally
need a temporary.

gcc/testsuite/ChangeLog:

* gfortran.dg/transfer_array_subref.f90: New test.

(cherry picked from commit 94fa992b60e53dcf807fc7055ab606d828b931d8)

2 months agotree-sra: Do not create stores into const aggregates (PR111873)
Martin Jambor [Wed, 14 May 2025 10:08:24 +0000 (12:08 +0200)] 
tree-sra: Do not create stores into const aggregates (PR111873)

This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates.  It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.

I have used testcases from duplicates because the original test-case
no longer reproduces for me.

gcc/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/111873
* tree-sra.cc (sra_modify_expr): When processing a load which has
a type-incompatible replacement, do not store the contents of the
replacement into the original aggregate when that aggregate is
const.

gcc/testsuite/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/pr120044-1.c: New test.
* gcc.dg/ipa/pr120044-2.c: Likewise.
* gcc.dg/tree-ssa/pr114864.c: Likewise.

(cherry picked from commit 9d039eff453f777c58642ff16178c1ce2a4be6ab)

2 months agoipa: Dump cgraph_node UID instead of order into ipa-clones dump file
Martin Jambor [Fri, 16 May 2025 15:13:51 +0000 (17:13 +0200)] 
ipa: Dump cgraph_node UID instead of order into ipa-clones dump file

Since starting from GCC 15 the order is not unique for any
symtab_nodes but m_uid is, I believe we ought to dump the latter in
the ipa-clones dump, if only so that people can reliably match entries
about new clones to those about removed nodes (if any).

This patch also contains a fixes to a few other places where we have
so far dumped order to our ordinary dumps and which have been
identified by Michal Jires.

gcc/ChangeLog:

2025-05-16  Martin Jambor  <mjambor@suse.cz>

* cgraph.h (symtab_node): Make member function get_uid const.
* cgraphclones.cc (dump_callgraph_transformation): Dump m_uid of the
call graph nodes instead of order.
* cgraph.cc (cgraph_node::remove): Likewise.
* ipa-cp.cc (ipcp_lattice<valtype>::print): Likewise.
* ipa-sra.cc (ipa_sra_summarize_function): Likewise.
* symtab.cc (symtab_node::dump_base): Likewise.

Co-Authored-By: Michal Jires <mjires@suse.cz>
(cherry picked from commit 9fa534f0831892393885e64596a0d6ca8c4078b6)

2 months agolibstdc++: Fix incorrect links to archived SGI STL docs
Jonathan Wakely [Tue, 20 May 2025 09:53:41 +0000 (10:53 +0100)] 
libstdc++: Fix incorrect links to archived SGI STL docs

In r8-7777-g25949ee33201f2 I updated some URLs to point to copies of the
SGI STL docs in the Wayback Machine, because the original pags were no
longer hosted on sgi.com. However, I incorrectly assumed that if one
archived page was at https://web.archive.org/web/20171225062613/... then
all the other pages would be too. Apparently that's not how the Wayback
Machine works, and each page is archived on a different date. That meant
that some of our links were redirecting to archived copies of the
announcement that the SGI STL docs have gone away.

This fixes each URL to refer to a correctly archived copy of the
original docs.

libstdc++-v3/ChangeLog:

* doc/xml/faq.xml: Update URL for archived SGI STL docs.
* doc/xml/manual/containers.xml: Likewise.
* doc/xml/manual/extensions.xml: Likewise.
* doc/xml/manual/using.xml: Likewise.
* doc/xml/manual/utilities.xml: Likewise.
* doc/html/*: Regenerate.

(cherry picked from commit 501e6e786652748ff0ad9a322f74b9b47970031f)

2 months agoc++/modules: Fix ICE on merge of instantiation with partial spec [PR120013]
Nathaniel Shead [Sat, 17 May 2025 13:51:07 +0000 (23:51 +1000)] 
c++/modules: Fix ICE on merge of instantiation with partial spec [PR120013]

When we import a pending instantiation that matches an existing partial
specialisation, we don't find the slot in the entity map because for
partial specialisations we register the TEMPLATE_DECL but for normal
implicit instantiations we instead register the inner TYPE_DECL.

Because the DECL_MODULE_ENTITY_P flag is set we correctly realise that
it is in the entity map, but ICE when attempting to use that slot in
partition handling.

This patch fixes the issue by detecting this case and instead looking
for the slot for the TEMPLATE_DECL.  It doesn't matter that we never add
a slot for the inner decl because we're about to discard it anyway.

PR c++/120013

gcc/cp/ChangeLog:

* module.cc (trees_in::install_entity): Handle re-registering
the inner TYPE_DECL of a partial specialisation.

gcc/testsuite/ChangeLog:

* g++.dg/modules/partial-8.h: New test.
* g++.dg/modules/partial-8_a.C: New test.
* g++.dg/modules/partial-8_b.C: New test.
* g++.dg/modules/partial-8_c.C: New test.
* g++.dg/modules/partial-8_d.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit b0de7297f2b5670386472229ab795a577c288ecf)

2 months agoc++/modules: Always mark tinfo vars as TREE_ADDRESSABLE [PR120350]
Nathaniel Shead [Mon, 19 May 2025 13:17:16 +0000 (23:17 +1000)] 
c++/modules: Always mark tinfo vars as TREE_ADDRESSABLE [PR120350]

We need to mark type info decls as addressable if we take them by
reference; this is done by walking the declaration during parsing and
marking the decl as needed.

However, with modules we don't stream tinfo decls directly; rather we
stream just their name and type and reconstruct them in the importer
directly.  This means that any addressable flags are not propagated, and
we error because TREE_ADDRESSABLE is not set despite taking its address.

But tinfo decls should always have TREE_ADDRESSABLE set, as any attempt
to use the tinfo decl will go through build_address anyway.  So this
patch fixes the issue by eagerly marking the constructed decl as
TREE_ADDRESSABLE so that modules gets this flag correctly set as well.

PR c++/120350

gcc/cp/ChangeLog:

* rtti.cc (get_tinfo_decl_direct): Mark TREE_ADDRESSABLE.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tinfo-3_a.H: New test.
* g++.dg/modules/tinfo-3_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 9a6e5a437f0416627ee516f6ef5929cb30c5e498)

2 months agoDaily bump.
GCC Administrator [Tue, 20 May 2025 00:25:44 +0000 (00:25 +0000)] 
Daily bump.

2 months agolibstdc++: Fix some Clang -Wsystem-headers warnings in <ranges>
Jonathan Wakely [Fri, 16 May 2025 10:54:46 +0000 (11:54 +0100)] 
libstdc++: Fix some Clang -Wsystem-headers warnings in <ranges>

libstdc++-v3/ChangeLog:

* include/std/ranges (_ZipTransform::operator()): Remove name of
unused parameter.
(chunk_view::_Iterator, stride_view::_Iterator): Likewise.
(join_with_view): Declare _Iterator and _Sentinel as class
instead of struct.
(repeat_view): Declare _Iterator as class instead of struct.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 1197f896ae5558f27baa929a10f66447aaafb681)

2 months agolibstdc++: Fix std::format of chrono::local_days with {} [PR120293]
Jonathan Wakely [Thu, 15 May 2025 18:32:01 +0000 (19:32 +0100)] 
libstdc++: Fix std::format of chrono::local_days with {} [PR120293]

Formatting of chrono::local_days with an empty chrono-specs should be
equivalent to inserting it into an ostream, which should use the
overload for inserting chrono::sys_days into an ostream. The
implementation of empty chrono-specs in _M_format_to_ostream takes some
short cuts, and that wasn't being done correctly for chrono::local_days.

libstdc++-v3/ChangeLog:

PR libstdc++/120293
* include/bits/chrono_io.h (_M_format_to_ostream): Add special
case for local_time convertible to local_days.
* testsuite/std/time/clock/local/io.cc: Check formatting of
chrono::local_days.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 1ed7585bf60ba9940ca5dc6d2c72dba86eea7b4d)

2 months agolibstdc++: Fix dangling pointer in fs::path::operator+=(*this) [PR120029]
Jonathan Wakely [Wed, 30 Apr 2025 16:31:01 +0000 (17:31 +0100)] 
libstdc++: Fix dangling pointer in fs::path::operator+=(*this) [PR120029]

When concatenating a path we reallocate the left operand's storage to
make room for the new components being added. When the two operands are
the same object, or the right operand is one of the components of the
left operand, the reallocation invalidates the pointers that refer
into the right operand's storage.

The solution in this commit is to detect these aliasing cases and just
do the concatenation in terms of the contained string, as that code
already handles the case where the string aliases the path. The standard
specifies the concatenation in terms of the native() string, so all this
change does is disable the optimized implementation of concatenation for
path objects which attempts to avoid re-parsing the path from the
concatenated string.

The potential loss of performance for this case isn't likely to be an
issue, because concatenating a path with itself (or one of its existing
components) probably isn't a common use case.

The Filesystem TS implementation doesn't have the optimized form of
concatenation and always does it in terms of the native string and
reparsing the whole thing, so doesn't have this bug. A test is added to
confirm that anyway (that test has some slightly different results due
to different behaviour for trailing slashes and implicit "." filenames
in the TS spec).

libstdc++-v3/ChangeLog:

PR libstdc++/120029
* src/c++17/fs_path.cc (path::operator+=(const path&)): Handle
parameters that alias the path or one of its components.
* testsuite/27_io/filesystem/path/concat/120029.cc: New test.
* testsuite/experimental/filesystem/path/concat/120029.cc: New
test.

(cherry picked from commit a067cbcdcc5f599a2b7d607e89674533d23c652d)

2 months agolibstdc++: Fix std::format_kind primary template for Clang [PR120190]
Jonathan Wakely [Thu, 15 May 2025 10:01:05 +0000 (11:01 +0100)] 
libstdc++: Fix std::format_kind primary template for Clang [PR120190]

Although Clang trunk has been adjusted to handle our std::format_kind
definition (because they need to be able to compile the GCC 15.1.0
release), it's probably better to not rely on something that they might
start diagnosing again in future.

Define the primary template in terms of an immediately invoked function
expression, so that we can put a static_assert(false) in the body.

libstdc++-v3/ChangeLog:

PR libstdc++/120190
* include/std/format (format_kind): Adjust primary template to
not depend on itself.
* testsuite/std/format/ranges/format_kind_neg.cc: Adjust
expected errors. Check more invalid specializations.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Daniel Krügler <daniel.kruegler@gmail.com>
(cherry picked from commit c65725eccbabf3b9b5965f27fff2d3b9f6c75930)

2 months agoOpenMP/Fortran: Fix allocatable-component mapping of derived-type array comps
Tobias Burnus [Thu, 15 May 2025 07:15:21 +0000 (09:15 +0200)] 
OpenMP/Fortran: Fix allocatable-component mapping of derived-type array comps

The check whether the location expression in map clause has allocatable
components was failing for some derived-type array expressions such as
  map(var%tiles(1))
as the compiler produced
  _4 = var.tiles;
  MEMREF(_4, _5);
This commit now also handles this case.

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_omp_deep_mapping_do): Handle SSA_NAME if
a def_stmt is available.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/alloc-comp-4.f90: New test.

(cherry picked from commit f99017c3125f4400cf6a098cf5b33d32fe3e6645)

2 months agoOpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0
Tobias Burnus [Wed, 14 May 2025 18:06:49 +0000 (20:06 +0200)] 
OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0

For map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION
and it is permitted that 'ptr' does not exist. 'ptr' is set to the device
pointee if it exists or to the host value otherwise.

For map(ptr[:3]), the variable is first mapped and then ptr is updated to point
to the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.

For map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n == 0, it
was failing with:
   "pointer target not mapped for attach"

The solution is not to fail but first to check whether it was mapped before.
It turned out that for the mapping part, GCC adds a run-time check whether
n == 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.
Thus, we just have to check whether there such a mapping for the address
for which the GOMP_MAP_ATTACH. was requested. And, if there was, the
error diagnostic can be skipped.

Unsurprisingly, this issue occurs in real-world code; it was detected in
a code that distributes work via MPI and for some processes, some bounds
ended up to be zero.

libgomp/ChangeLog:

* target.c (gomp_attach_pointer): Return bool; accept additional
bool to optionally silence the fatal pointee-not-found error.
(gomp_map_vars_internal): If the pointee could not be found,
check whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.
* libgomp.h (gomp_attach_pointer): Update prototype.
* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update
calls.
* testsuite/libgomp.c/target-map-zero-sized.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.

(cherry picked from commit 814e29e390b1e9253f9a38e0d84f5ebe5de0c13e)

2 months agolibgomp.{c,fortran}/interop-{hip,cuda}: Fix dg-run target selection
Tobias Burnus [Fri, 9 May 2025 08:57:44 +0000 (10:57 +0200)] 
libgomp.{c,fortran}/interop-{hip,cuda}: Fix dg-run target selection

While the tests checked whether the CUDA/HIP runtime is available
before processing them, the execution was then done unconditionally,
leading to FAIL when the default device was the host (or the wrong
offload device).

Now the test is only executed ('run') when the default device is an
Nvidia or AMD GPU (depending on the test case, cf. the test file name).
Otherwise, only a 'link' test is done. (Except when the effective-target
check cannot find the runtime lib - then the test is skipped [as before].)

Note: The cublas/hipblas tests use variant functions and iterate over
all devices, such that the cublas or hipblas, respectively, is only
called when the active device is an AMD or Nvidia device, respectively,
while for the host and other device types the fallback is called.

libgomp/ChangeLog:

* testsuite/libgomp.c/interop-cuda-full.c: Use 'link' instead
of 'run' when the default device is "! offload_device_nvptx".
* testsuite/libgomp.c/interop-cuda-libonly.c: Likewise.
* testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
* testsuite/libgomp.c/interop-hip-nvidia-no-headers.c: Likewise.
* testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c: Likewise.
* testsuite/libgomp.fortran/interop-hip-nvidia-full.F90: Likewise.
* testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90: Likewise.
* testsuite/libgomp.c/interop-hip-amd-full.c: Use 'link' instead
of 'run' when the default device is "! offload_device_gcn".
* testsuite/libgomp.c/interop-hip-amd-no-hip-header.c: Likewise.
* testsuite/libgomp.fortran/interop-hip-amd-full.F90: Likewise.
* testsuite/libgomp.fortran/interop-hip-amd-no-module.F90: Likewise.

(cherry picked from commit 94e63410474a36655e1800387eabd73a6f930048)

2 months agolibgomp.fortran/map-alloc-comp-9{,-usm}.f90: Add unified_shared_memory variant
Tobias Burnus [Wed, 7 May 2025 11:46:51 +0000 (13:46 +0200)] 
libgomp.fortran/map-alloc-comp-9{,-usm}.f90: Add unified_shared_memory variant

When host memory is device accessible - independent whether mapping is done or
not (i.e. self map), the 'vtab' pointer becomes accessible, which stores the
dynamic type's type and size information.

In principle, we want to test: USM available but mapping is still done, but
as there is no simple + reliable not-crashing way to test for this, those
checks are skipped in the (pre)existing test file map-alloc-comp-9.f90.

Or rather: those are only active with self-maps, which is currently only true
for the host.

This commit adds map-alloc-comp-9-usm.f90 which runs the same test with
'omp requires unified_shared_memory'.  While OpenMP permits both actual
mapping and self maps with this flag, it in theory covers the missing cases.
However, currently, GCC always uses self maps with USM. Still, having a
device-run self-maps check is better than nothing, even if it misses the
most interesting case.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/map-alloc-comp-9.f90: Process differently
when USE_USM_REQUIREMENT is set.
* testsuite/libgomp.fortran/map-alloc-comp-9-usm.f90: New test.

(cherry picked from commit 9565076f9b810541aeb63cb621d694326aa12216)

2 months ago'libgomp.c/interop-hsa.c': GCN offloading only
Thomas Schwinge [Mon, 5 May 2025 08:19:30 +0000 (10:19 +0200)] 
'libgomp.c/interop-hsa.c': GCN offloading only

Fix-up for commit 8d84ea28510054fbbb8a2b7441916bd75e29163f
"OpenMP, GCN: Add interop-hsa testcase", which added 'libgomp.c/interop-hsa.c'.
If nvptx offloading compilation is enabled in addition to GCN, the former ICEs:

    during RTL pass: final
    [...]/libgomp.c/interop-hsa.c: In function 'get_kernel_ptr':
    [...]/libgomp.c/interop-hsa.c:34:1: internal compiler error: RTL check: expected code 'subreg', have 'reg' in nvptx_print_operand, at config/nvptx/nvptx.cc:3082
    0x1ccdb96 internal_error(char const*, ...)
            [...]/gcc/diagnostic-global-context.cc:517
    0x7446c3 rtl_check_failed_code1(rtx_def const*, rtx_code, char const*, int, char const*)
            [...]/gcc/rtl.cc:770
    0x7fa533 nvptx_print_operand
            [...]/gcc/config/nvptx/nvptx.cc:3082
    0xb25f34 output_operand(rtx_def*, int)
            [...]/gcc/final.cc:3641
    0xb26f07 output_asm_insn(char const*, rtx_def**)
            [...]/gcc/final.cc:3534
    0xb29d91 output_asm_insn(char const*, rtx_def**)
            [...]/gcc/final.cc:2639
    0xb29d91 final_scan_insn_1
            [...]/gcc/final.cc:2642
    0xb2a59f final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
            [...]/gcc/final.cc:2892
    0xb2a68c final_1
            [...]/gcc/final.cc:1983
    0xb2b378 rest_of_handle_final
            [...]/gcc/final.cc:4250
    0xb2b378 execute
            [...]/gcc/final.cc:4328

Regardless of the issue that nvptx offloading compilation probably shouldn't
ICE, the 'asm' insert clearly is valid for GCN only.

libgomp/
* testsuite/libgomp.c/interop-hsa.c: GCN offloading only.

(cherry picked from commit 85ad0d84fcec720c1d94b9bda9a617ced70ba5d2)

2 months agoOpenMP: Restore lost Fortran testcase for 'omp allocate'
Tobias Burnus [Thu, 1 May 2025 15:39:42 +0000 (15:39 +0000)] 
OpenMP: Restore lost Fortran testcase for 'omp allocate'

This testcase, which is present on the OG13 and OG14 branches, was
overlooked when the Fortran support for 'omp allocate' was added to
mainline (commit d4b6d147920b93297e621124a99ed01e7e310d92 from
December 2023).

libgomp/ChangeLog

* testsuite/libgomp.fortran/allocate-8a.f90: New test.

(cherry picked from commit 08ce1b9f6707e00089c4d77d2bb82963d531bb1d)

2 months agoOpenMP, GCN: Add interop-hsa testcase
Andrew Stubbs [Thu, 24 Apr 2025 16:50:08 +0000 (16:50 +0000)] 
OpenMP, GCN: Add interop-hsa testcase

This testcase ensures that the interop HSA support is sufficient to run
a kernel manually on the same device.

libgomp/ChangeLog:

* testsuite/libgomp.c/interop-hsa.c: New test.

(cherry picked from commit 8d84ea28510054fbbb8a2b7441916bd75e29163f)

2 months agolibgomp/testsuite: Fix hip_header_nvidia check, add workaround to test
Tobias Burnus [Thu, 24 Apr 2025 16:26:30 +0000 (18:26 +0200)] 
libgomp/testsuite: Fix hip_header_nvidia check, add workaround to test

This is all about using the AMD's HIP header files with
__HIP_PLATFORM_NVIDIA__ defined, i.e. HIP with Nvidia/CUDA; in that case,
HIP is a thin layer on top of CUDA.

First, the check_effective_target_gomp_hip_header_nvidia check failed;
to fix it, -Wno-deprecated-declarations was added - and likewise to the
two affected testcases that actually used the HIP headers on Nvidia.

Doing so, the HIP tested was successful but the HIP-BLAS one showed two
issues:

* One seems to be related to include search paths as the HIP header uses
  #include "library_types.h" to include that CUDA header. Seemingly, it
  tried to included (again) the HIP header hip/library_types.h, not the
  CUDA one. I guess, some tweaking of -isystem vs. -I could have
  prevented this, but the simpler workaround was to just explicitly
  include the CUDA one before the HIP header files.

* Once done, everything compiled but linking failed as the association
  between three HIP-BLAS functions and their CUDA-BLAS ones did not
  work. Solution: Just add three #define for mapping them.

libgomp/ChangeLog:

* testsuite/lib/libgomp.exp
(check_effective_target_gomp_hip_header_nvidia): Compile with
"-Wno-deprecated-declarations".
* testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
* testsuite/libgomp.c/interop-hipblas-nvidia-full.c: Likewise.
* testsuite/libgomp.c/interop-hipblas.h: Add workarounds
when using the HIP headers with __HIP_PLATFORM_NVIDIA__.

(cherry picked from commit 8ef0518bce489c4c0c252a0e0c44193c5f7cf777)

2 months agolibgomp: Add additional OpenMP interop runtime tests
Tobias Burnus [Thu, 24 Apr 2025 12:36:37 +0000 (14:36 +0200)] 
libgomp: Add additional OpenMP interop runtime tests

Add checks for nowait/depend and for checks that the returned
CUDA, CUDA_DRIVER and HIP interop objects actually work.

While the CUDA/CUDA_DRIVER ones are only for Nvidia GPUs, HIP
works on both AMD and Nvidia GPUs; on Nvidia GPUs, it is a
very thin wrapper around CUDA.

For Fortran, only a HIP test has been added - using hipfort.

While libgomp.c-c++-common/interop-2.c always works - even without
GPU - and checks for depend / nowait, all others require that
runtime libraries are found at link (and execution) time:
For Nvidia GPUs, libcuda + libcudart or libcublas,
For AMD GPUs, libamdhip64 or libhipblas.

The header files and hipfort modules do not need to be present as a
fallback has been implemented, but if they are, they get used.

Due to the combinations, the basic 1x C/C++, 4x C and 1x Fortran tests
yield 1x C/C++, 14x C and 4 Fortran run-test files.

libgomp/ChangeLog:

* testsuite/lib/libgomp.exp (check_effective_target_openacc_cublas,
check_effective_target_openacc_cudart): Update description as
the check requires more.
(check_effective_target_openacc_libcuda,
check_effective_target_openacc_libcublas,
check_effective_target_openacc_libcudart,
check_effective_target_gomp_hip_header_amd,
check_effective_target_gomp_hip_header_nvidia,
check_effective_target_gomp_hipfort_module,
check_effective_target_gomp_libamdhip64,
check_effective_target_gomp_libhipblas): New.
* testsuite/libgomp.c-c++-common/interop-2.c: New test.
* testsuite/libgomp.c/interop-cublas-full.c: New test.
* testsuite/libgomp.c/interop-cublas-libonly.c: New test.
* testsuite/libgomp.c/interop-cuda-full.c: New test.
* testsuite/libgomp.c/interop-cuda-libonly.c: New test.
* testsuite/libgomp.c/interop-hip-amd-full.c: New test.
* testsuite/libgomp.c/interop-hip-amd-no-hip-header.c: New test.
* testsuite/libgomp.c/interop-hip-nvidia-full.c: New test.
* testsuite/libgomp.c/interop-hip-nvidia-no-headers.c: New test.
* testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c: New test.
* testsuite/libgomp.c/interop-hip.h: New test.
* testsuite/libgomp.c/interop-hipblas-amd-full.c: New test.
* testsuite/libgomp.c/interop-hipblas-amd-no-hip-header.c: New test.
* testsuite/libgomp.c/interop-hipblas-nvidia-full.c: New test.
* testsuite/libgomp.c/interop-hipblas-nvidia-no-headers.c: New test.
* testsuite/libgomp.c/interop-hipblas-nvidia-no-hip-header.c: New test.
* testsuite/libgomp.c/interop-hipblas.h: New test.
* testsuite/libgomp.fortran/interop-hip-amd-full.F90: New test.
* testsuite/libgomp.fortran/interop-hip-amd-no-module.F90: New test.
* testsuite/libgomp.fortran/interop-hip-nvidia-full.F90: New test.
* testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90: New test.
* testsuite/libgomp.fortran/interop-hip.h: New test.

(cherry picked from commit 515d9be7944e89f5ec4363f9816ad4031ab6394b)

2 months agoOpenMP: Add libgomp.fortran/target-enter-data-8.f90
Tobias Burnus [Wed, 23 Apr 2025 07:03:00 +0000 (09:03 +0200)] 
OpenMP: Add libgomp.fortran/target-enter-data-8.f90

Add another testcase for Fortran deep mapping of allocatable components.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-enter-data-8.f90: New test.

(cherry picked from commit c9a8f2f9d39a317ed67fb47157a995ea03c182d4)

2 months agoDaily bump.
GCC Administrator [Mon, 19 May 2025 00:23:06 +0000 (00:23 +0000)] 
Daily bump.

2 months agoDaily bump.
GCC Administrator [Sun, 18 May 2025 00:23:11 +0000 (00:23 +0000)] 
Daily bump.

2 months agoFortran: Fix ICE with use of c_associated.
Jerry DeLisle [Tue, 6 May 2025 03:05:22 +0000 (20:05 -0700)] 
Fortran: Fix ICE with use of c_associated.

PR fortran/120049

gcc/fortran/ChangeLog:

* check.cc (gfc_check_c_associated): Modify checks to avoid
ICE and allow use, intrinsic :: iso_c_binding from a separate
module file.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr120049_a.f90: New test.
* gfortran.dg/pr120049_b.f90: New test.

(cherry picked from commit d0571638a6bad932b226ada98b167fa47a47d838)

2 months agoDaily bump.
GCC Administrator [Sat, 17 May 2025 00:23:30 +0000 (00:23 +0000)] 
Daily bump.

2 months agoUpdate cpplib es.po
Joseph Myers [Fri, 16 May 2025 18:41:15 +0000 (18:41 +0000)] 
Update cpplib es.po

* es.po: Update.

2 months agoAlpha: Fix base block alignment calculation regression
Maciej W. Rozycki [Fri, 16 May 2025 16:18:53 +0000 (17:18 +0100)] 
Alpha: Fix base block alignment calculation regression

In determination of base block alignment we only examine a COMPONENT_REF
tree node at hand without ever checking if its ultimate alignment has
been reduced by the combined offset going back to the outermost object.
Consequently cases have been observed where quadword accesses have been
produced for a memory location referring a nested struct member only
aligned to the longword boundary, causing emulation to trigger.

Address this issue by recursing into COMPONENT_REF tree nodes until the
outermost one has been reached, which is supposed to be a MEM_REF one,
accumulating the offset as we go, fixing a commit e0dae4da4c45 ("Alpha:
Also use tree information to get base block alignment") regression.

Bail out and refrain from using tree information for alignment if we end
up at something different or we are unable to calculate the offset at
any point.

gcc/
* config/alpha/alpha.cc
(alpha_get_mem_rtx_alignment_and_offset): Recurse into
COMPONENT_REF nodes.

gcc/testsuite/
* gcc.target/alpha/memcpy-nested-offset-long.c: New file.
* gcc.target/alpha/memcpy-nested-offset-quad.c: New file.

(cherry picked from commit 1dd769b3d0d9251649dcb645d7ed6c4ba2202306)

2 months agoDaily bump.
GCC Administrator [Fri, 16 May 2025 00:25:41 +0000 (00:25 +0000)] 
Daily bump.

2 months agoc++: unifying specializations of non-primary tmpls [PR120161]
Patrick Palka [Thu, 15 May 2025 15:07:53 +0000 (11:07 -0400)] 
c++: unifying specializations of non-primary tmpls [PR120161]

Here unification of P=Wrap<int>::type, A=Wrap<long>::type wrongly
succeeds ever since r14-4112 which made the RECORD_TYPE case of unify
no longer recurse into template arguments for non-primary templates
(since they're a non-deduced context) and so the int/long mismatch that
makes the two types distinct goes unnoticed.

In the case of (comparing specializations of) a non-primary template,
unify should still go on to compare the types directly before returning
success.

PR c++/120161

gcc/cp/ChangeLog:

* pt.cc (unify) <case RECORD_TYPE>: When comparing specializations
of a non-primary template, still perform a type comparison.

gcc/testsuite/ChangeLog:

* g++.dg/template/unify13.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 0c430503f2849ebb20105695b8ad40d43d797c7b)

2 months agoUpdate gcc zh_CN.po
Joseph Myers [Thu, 15 May 2025 18:04:00 +0000 (18:04 +0000)] 
Update gcc zh_CN.po

* zh_CN.po: Update.

2 months agoFix explicit arrays with non-constant size for -fc-prototypes.
Thomas Koenig [Wed, 14 May 2025 18:11:48 +0000 (20:11 +0200)] 
Fix explicit arrays with non-constant size for -fc-prototypes.

gcc/fortran/ChangeLog:

PR fortran/120139
* dump-parse-tree.cc (get_c_type_name): If no constant
size of an array exists, output an asterisk.

(cherry picked from commit 4f9c7b5258f2af89bba8e954c277981d2e2ee1ef)

2 months agoDo not dump non-interoperable types with -fc-prototypes.
Thomas Koenig [Tue, 13 May 2025 17:02:06 +0000 (19:02 +0200)] 
Do not dump non-interoperable types with -fc-prototypes.

gcc/fortran/ChangeLog:

PR fortran/120107
* dump-parse-tree.cc (write_type): Do not dump non-interoperable
types.

(cherry picked from commit fa0dff8e99e81bc7a3db1dc57d4fc340e0525b1d)

2 months agoUpdate cpplib zh_CN.po
Joseph Myers [Thu, 15 May 2025 17:20:54 +0000 (17:20 +0000)] 
Update cpplib zh_CN.po

* zh_CN.po: Update.

2 months agoDaily bump.
GCC Administrator [Thu, 15 May 2025 00:26:03 +0000 (00:26 +0000)] 
Daily bump.

2 months agoUpdate gcc sv.po
Joseph Myers [Wed, 14 May 2025 21:12:34 +0000 (21:12 +0000)] 
Update gcc sv.po

* sv.po: Update.

2 months agoUpdate cpplib es.po
Joseph Myers [Wed, 14 May 2025 20:26:22 +0000 (20:26 +0000)] 
Update cpplib es.po

* es.po: Update.

2 months agodwarf2out: Propagate dtprel into the .debug_addr table in resolve_addr_in_expr
Kyle Huey [Wed, 14 May 2025 03:26:26 +0000 (20:26 -0700)] 
dwarf2out: Propagate dtprel into the .debug_addr table in resolve_addr_in_expr

For a debugger to display statically-allocated[0] TLS variables the compiler
must communicate information[1] that can be used in conjunction with knowledge
of the runtime enviroment[2] to calculate a location for the variable for
each thread. That need gives rise to dw_loc_dtprel in dwarf2out, a flag tracking
whether the location description is dtprel, or relative to the
"dynamic thread pointer". Location descriptions in the .debug_info section for
TLS variables need to be relocated by the static linker accordingly, and
dw_loc_dtprel controls emission of the needed relocations.

This is further complicated by -gsplit-dwarf. -gsplit-dwarf is designed to allow
as much debugging information as possible to bypass the static linker to improve
linking performance. One of the ways that is done is by introducing a layer of
indirection for relocatable values[3]. That gives rise to addr_index_table which
ultimately results in the .debug_addr section.

While the code handling addr_index_table clearly contemplates the existence of
dtprel entries[4] resolve_addr_in_expr does not, and the result is that when
using -gsplit-dwarf the DWARF for TLS variables contains an address[5] rather
than an offset, and debuggers can't work with that.

This is visible on a trivial example. Compile

```
static __thread int tls_var;

int main(void) {
  tls_var = 42;
  return 0;
}
```

with -g and -g -gsplit-dwarf. Run the program under gdb. When examining the
value of tls_var before and after the assignment, -g behaves as one would
expect but -g -gsplit-dwarf does not. If the user is lucky and the miscalculated
address is not mapped, gdb will print "Cannot access memory at address ...".
If the user is unlucky and the miscalculated address is mapped, gdb will simply
give the wrong value. You can further confirm that the issue is the address
calculation by asking gdb for the address of tls_var and comparing that to what
one would expect.[6]

Thankfully this is trivial to fix by modifying resolve_addr_in_expr to propagate
the dtprel character of the location where necessary. gdb begins working as
expected and the diff in the generated assembly is clear.

```
        .section        .debug_addr,"",@progbits
        .long   0x14
        .value  0x5
        .byte   0x8
        .byte   0
 .Ldebug_addr0:
-       .quad   tls_var
+       .long   tls_var@dtpoff, 0
        .quad   .LFB0
```

[0] Referring to e.g. __thread as statically-allocated vs. e.g. a
    dynamically-allocated pthread_key_create() call.
[1] Generally an offset in a TLS block.
[2] With glibc, provided by libthread_db.so.
[3] Relocatable values are moved to a table in the .debug_addr section, those
    values in .debug_info are replaced with special values that look up indexes
    in that table, and then the static linker elsewhere assigns a single per-CU
    starting index in the .debug_addr section, allowing those special values to
    remain permanently fixed and the resulting data to be ignored by the linker.
[4] ate_kind_rtx_dtprel exists, after all, and new_addr_loc_descr does produce
    it where appropriate.
[5] e.g. an address in the .tbss/.tdata section.
[6] e.g. on x86-64 by examining %fsbase and the offset in the assembly

2025-05-01  Kyle Huey  <me@kylehuey.com>

* dwarf2out.cc (resolve_addr_in_expr): Propagate dtprel into the address
table when appropriate.

2 months agoc++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]
Nathaniel Shead [Thu, 8 May 2025 13:06:13 +0000 (23:06 +1000)] 
c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]

The attached testcase ICEs in maybe_thunk_body because we haven't
created a node in the cgraph for an imported explicit instantiation yet.

We in fact really shouldn't be emitting calls at all, since an imported
explicit instantiation always exists in the TU we imported it from.  So
this patch adjusts DECL_NOT_REALLY_EXTERN handling to account for this.

PR c++/120125

gcc/cp/ChangeLog:

* module.cc (trees_out::write_function_def): Only set
DECL_NOT_REALLY_EXTERN if the importer might need to emit it.
* optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph
node created.

gcc/testsuite/ChangeLog:

* g++.dg/modules/clone-4_a.C: New test.
* g++.dg/modules/clone-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit d787bc4fd372298e9ed5b11cb3050fd3707070f6)

2 months agoc++: Fix OpenMP support with C++20 modules [PR119864]
Nathaniel Shead [Mon, 21 Apr 2025 10:40:29 +0000 (20:40 +1000)] 
c++: Fix OpenMP support with C++20 modules [PR119864]

In r15-2799-gf1bfba3a9b3f31, a new kind of global constructor was added.
Unfortunately this broke C++20 modules, as both the host and target
constructors were given the same mangled name.  This patch ensures that
only the host constructor gets the module name mangling for now, and
stops forcing the creation of the target constructor even when no such
initialization is required.

PR c++/119864

gcc/cp/ChangeLog:

* decl2.cc (start_objects): Only use module initialized for
host.
(c_parse_final_cleanups): Don't always create an OMP offload
init function in modules.

gcc/testsuite/ChangeLog:

* g++.dg/modules/openmp-1.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 79b7e37ea3fbbc43958190f69f6da3be3d809c9c)

2 months agoDaily bump.
GCC Administrator [Wed, 14 May 2025 00:25:57 +0000 (00:25 +0000)] 
Daily bump.

2 months agoDo not generate formal arglist from actual if we have already resolved it.
Thomas Koenig [Sun, 11 May 2025 05:40:23 +0000 (07:40 +0200)] 
Do not generate formal arglist from actual if we have already resolved it.

This bug was another case of generating a formal arglist from
an actual one where we should not have done so.  The fix is
straightforward:  If we have resolved the formal arglist, we should
not generare a new one.

OK for trunk and backport?

gcc/fortran/ChangeLog:

PR fortran/120163
* gfortran.h: Add formal_resolved to gfc_symbol.
* resolve.cc (gfc_resolve_formal_arglist): Set it.
(resolve_function): Do not call gfc_get_formal_from_actual_arglist
if we already resolved a formal arglist.
(resolve_call): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/120163
* gfortran.dg/interface_61.f90: New test.

2 months ago[PATCH] PR modula2/120117: ICE when attempting to obtain the MAX of an aliased set...
Gaius Mulley [Tue, 13 May 2025 18:42:39 +0000 (19:42 +0100)] 
[PATCH] PR modula2/120117: ICE when attempting to obtain the MAX of an aliased set type

The ICE occurred because of a bug in M2GenGCC.mod:FoldBecomes which
attempted to remove the same quadruple twice.  Thereafter cc1gm2
generated an erroneous error type error as PCSymBuild did not skip
an aliased set type.  The type of the const was set incorrectly
(as a set type) rather than the type of the set element.

gcc/m2/ChangeLog:

PR modula2/120117
* gm2-compiler/M2GenGCC.mod (FoldBecomes): Remove the call to
RemoveQuad since this is performed by TypeCheckBecomes.
* gm2-compiler/PCSymBuild.mod (buildConstFunction): Rewrite
header comment.
Check for a set or a type aliased set and appropriately
skip type equivalences and obtain the element type.
* gm2-compiler/SymbolTable.mod (PutConst): Add call to
CheckBreak.

gcc/testsuite/ChangeLog:

PR modula2/120117
* gm2/pim/pass/highbit.mod: New test.
* gm2/pim/pass/highbit2.mod: New test.

(cherry picked from commit bb83283e5c5c55eab7493a58c5e415aa56f5940c)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months ago[PATCH] PR modula2/115276: libgm2 wraptime.cc field access all return -1.
Gaius Mulley [Tue, 13 May 2025 18:05:40 +0000 (19:05 +0100)] 
[PATCH] PR modula2/115276: libgm2 wraptime.cc field access all return -1.

This patch provides autoconf tests for each field used in wraptime.cc
referencing struct tm and struct timeval.

libgm2/ChangeLog:

PR modula2/115276
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac (AC_STRUCT_TIMEZONE): Add.
(AC_CHECK_MEMBER): Test for struct tm.tm_year.
(AC_CHECK_MEMBER): Test for struct tm.tm_mon.
(AC_CHECK_MEMBER): Test for struct tm.tm_mday.
(AC_CHECK_MEMBER): Test for struct tm.tm_hour.
(AC_CHECK_MEMBER): Test for struct tm.tm_min.
(AC_CHECK_MEMBER): Test for struct tm.tm_sec.
(AC_CHECK_MEMBER): Test for struct tm.tm_year.
(AC_CHECK_MEMBER): Test for struct tm.tm_yday.
(AC_CHECK_MEMBER): Test for struct tm.tm_wday.
(AC_CHECK_MEMBER): Test for struct tm.tm_isdst.
(AC_CHECK_MEMBER): Test for struct timeval.tv_sec.
(AC_CHECK_MEMBER): Test for struct timeval.tv_sec.
(AC_CHECK_MEMBER): Test for struct timeval.tv_usec.
* libm2iso/wraptime.cc (InitTimeval): Guard against lack
struct timeval and malloc.
(InitTimezone): Guard against lack of struct tm.tm_zone
and malloc.
(KillTimezone): Ditto.
(InitTimeval): Guard against lack of struct timeval
and malloc.
(KillTimeval): Guard against lack of malloc.
(settimeofday): Guard against lack of struct tm.tm_zone.
(GetFractions): Guard against lack of struct timeval.
(localtime_r): Ditto.
(GetYear): Guard against lack of struct tm.
(GetMonth): Ditto.
(GetDay): Ditto.
(GetHour): Ditto.
(GetMinute): Ditto.
(GetSecond): Ditto.
(GetSummerTime): Ditto.
(GetDST): Guards against lack of struct timezone.
(SetTimezone): Ditto.
(SetTimeval): Guard against lack of struct tm.

(cherry picked from commit 419f40af5c5335b84c16e4891377142f12f7577b)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months ago[PATCH] PR modula2/119915: Sprintf1 repeats the entire format string if it starts...
Gaius Mulley [Tue, 13 May 2025 17:04:57 +0000 (18:04 +0100)] 
[PATCH] PR modula2/119915: Sprintf1 repeats the entire format string if it starts with a directive

This bugfix is for FormatStrings to ensure that in the case of %x, %u the
procedure function PerformFormatString uses Copy rather than Slice to
avoid the case on an upper bound of zero in Slice.  Oddly the %d case
had the correct code.

gcc/m2/ChangeLog:

PR modula2/119915
* gm2-libs/FormatStrings.mod (PerformFormatString): Handle
the %u and %x format specifiers in a similar way to the %d
specifier.  Avoid using Slice and use Copy instead.

gcc/testsuite/ChangeLog:

PR modula2/119915
* gm2/pimlib/run/pass/format2.mod: New test.

(cherry picked from commit 7a4f7a92770db4e739e76a06175454ba38d60b22)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months ago[PATCH] PR modula2/119914 No error message generated when passing a Ztype to an unbou...
Gaius Mulley [Tue, 13 May 2025 16:51:22 +0000 (17:51 +0100)] 
[PATCH] PR modula2/119914 No error message generated when passing a Ztype to an unbounded array

This patch detects constants ZType, RType, CType being passed to unbounded
arrays and generates an error message highlighting the formal and
actual parameters in error.

gcc/m2/ChangeLog:

PR modula2/119914
* gm2-compiler/M2Check.mod (checkConstMeta): Add check for
Ztype, Rtype and Ctype and unbounded arrays.
(IsZRCType): New procedure function.
(isZRC): Add comment.
* gm2-compiler/M2Quads.mod:
* gm2-compiler/M2Range.mod (gdbinit): New procedure.
(BreakWhenRangeCreated): Ditto.
(CheckBreak): Ditto.
(InitRange): Call CheckBreak.
(Init): Add gdbhook and initialize interactive watch point.
* gm2-compiler/SymbolTable.def (GetNthParamAnyClosest): New
procedure function.
* gm2-compiler/SymbolTable.mod (BreakSym): Remove constant.
(BreakSym): Add Variable.
(stop): Remove.
(gdbhook): New procedure.
(BreakWhenSymCreated): Ditto.
(CheckBreak): Ditto.
(NewSym): Call CheckBreak.
(Init): Add gdbhook and initialize interactive watch point.
(MakeProcedure): Replace guarded call to stop with CheckBreak.
(GetNthParamChoice): New procedure function.
(GetNthParamOrdered): Ditto.
(GetNthParamAnyClosest): Ditto.
(GetOuterModuleScope): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/119914
* gm2/pim/fail/constintarraybyte.mod: New test.

(cherry picked from commit e9a81addd5b7d018e173fa8d59aafc2f84e41d8b)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months ago[PATCH] PR modula2/120188: Use existing test for plugin
Gaius Mulley [Tue, 13 May 2025 15:51:06 +0000 (16:51 +0100)] 
[PATCH] PR modula2/120188: Use existing test for plugin

This is a cleanup patch which to use the existing plugin test
rather than check the configure build options.

gcc/testsuite/ChangeLog:

PR modula2/120188
* gm2.dg/doc/examples/plugin/fail/doc-examples-plugin-fail.exp:
Remove call to gm2-dg-frontend-configure-check and replace with
tests for whether plugin variables exist.

(cherry picked from commit f1f94e79dbcfa4b33267db27780870ea7810cd21)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months ago[PATCH] PR modula2/120188: documented example does not work assignvalue m2plugin
Gaius Mulley [Tue, 13 May 2025 15:48:52 +0000 (16:48 +0100)] 
[PATCH] PR modula2/120188: documented example does not work assignvalue m2plugin

This patch corrects the gm2 command line used in the documentation
to invoke the m2-plugin.  The patch also includes the documentation
example in dejagnu test code with an expect script to check whether
plugins were enabled.

gcc/ChangeLog:

PR modula2/120188
* doc/gm2.texi (Semantic checking): Add -fm2-plugin command line option.

gcc/testsuite/ChangeLog:

PR modula2/120188
* lib/gm2-dg.exp (gm2-dg-frontend-configure-check): New function.
(gm2-dg-runtest): Add -O2 to the option_list.
* gm2.dg/doc/examples/plugin/fail/assignvalue.mod: New test.
* gm2.dg/doc/examples/plugin/fail/doc-examples-plugin-fail.exp: New test.

(cherry picked from commit 9ce4c801e8275fcf0336ae2fb548f6ebb3ca068b)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agolibfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]
Jakub Jelinek [Tue, 13 May 2025 12:20:22 +0000 (14:20 +0200)] 
libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]

As mentioned in the PR, _gfortran_{,m,s}findloc2_s{1,4} iterate too many
times in the back case if nothing is found.
For !back, the loops are for (i = 1; i <= extent; i++) so i is in the
body [1, extent] if nothing is found, but for back it is
for (i = extent; i >= 0; i--) so i is in the body [0, extent] and compares
one element before the start of the array.
Note, findloc1_s{1,4} uses
          for (n = len; n > 0; n--, src -= delta * len_array)
for the back loop and
          for (n = 1; n <= len; n++, src += delta * len_array)
for !back.  This patch fixes that.
The testcase fails under valgrind without the libgfortran changes and
succeeds with those.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/120196
* m4/ifindloc2.m4 (header1, header2): For back use i > 0 rather than
i >= 0 as for condition.
* generated/findloc2_s1.c: Regenerate.
* generated/findloc2_s4.c: Regenerate.

* gfortran.dg/pr120196.f90: New test.

(cherry picked from commit 748a7bc4624e7b000f6fdb93a8cf7da73ff193bb)

2 months agolibfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:19:25 +0000 (14:19 +0200)] 
libfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191]

There is a bug in _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} which the
following testcase shows.
The functions return but then crash in the caller.
Seems that is because buffer overflows, I believe those functions for
if (mask == NULL || *mask) condition being false are supposed to fill in
the result array with all zeros (or allocate it and fill it with zeros).
My understanding is the result array in that case is integer(kind={4,8,16})
and should have the extents the character input array has.
The problem is that it uses * string_len in the extent multiplication:
      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n) * string_len;
and
      extent[n] =
        GFC_DESCRIPTOR_EXTENT(array,n + 1) * string_len;
which is I guess fine and desirable for the extents of the character array,
but not for the extents of the destination array.  Yet the code uses
that extent array for that purpose (and no other purposes).
Here it uses it to set the dimensions for the case where it needs to
allocate (as well as size):
      for (n = 0; n < rank; n++)
        {
          if (n == 0)
            str = 1;
          else
            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
          GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
        }
Here it uses it for bounds checking of the destination:
      if (unlikely (compile_options.bounds_check))
        {
          for (n=0; n < rank; n++)
            {
              index_type ret_extent;

              ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
              if (extent[n] != ret_extent)
                runtime_error ("Incorrect extent in return value of"
                               " MAXLOC intrinsic in dimension %ld:"
                               " is %ld, should be %ld", (long int) n + 1,
                               (long int) ret_extent, (long int) extent[n]);
            }
        }
and here to find out how many retarray elements to actually fill in each
dimension:
  while(1)
    {
      *dest = 0;
      count[0]++;
      dest += dstride[0];
      n = 0;
      while (count[n] == extent[n])
        {
          /* When we get to the end of a dimension, reset it and increment
             the next dimension.  */
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
          dest -= dstride[n] * extent[n];
Seems maxloc1s.m4 and minloc1s.m4 are the only users of ifunction-s.m4,
so we can change SCALAR_ARRAY_FUNCTION in there without breaking anything
else.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR fortran/120191
* m4/ifunction-s.m4 (SCALAR_ARRAY_FUNCTION): Don't multiply
GFC_DESCRIPTOR_EXTENT(array,) by string_len.
* generated/maxloc1_4_s1.c: Regenerate.
* generated/maxloc1_4_s4.c: Regenerate.
* generated/maxloc1_8_s1.c: Regenerate.
* generated/maxloc1_8_s4.c: Regenerate.
* generated/maxloc1_16_s1.c: Regenerate.
* generated/maxloc1_16_s4.c: Regenerate.
* generated/minloc1_4_s1.c: Regenerate.
* generated/minloc1_4_s4.c: Regenerate.
* generated/minloc1_8_s1.c: Regenerate.
* generated/minloc1_8_s4.c: Regenerate.
* generated/minloc1_16_s1.c: Regenerate.
* generated/minloc1_16_s4.c: Regenerate.

* gfortran.dg/pr120191_3.f90: New test.

(cherry picked from commit 781cfc454b8dc24952fe7f4c5c409296dca505e1)

2 months agolibfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:18:10 +0000 (14:18 +0200)] 
libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191]

I've tried to write a testcase for the BT_CHARACTER maxloc/minloc with named
or unnamed arguments and indeed the just posted patch fixed the arguments
in there in multiple cases to match what the library expects.
But the testcase still fails, due to library problems.

One dealt with in this patch are _gfortran_s{max,min}loc2_{4,8,16}_s{1,4}
functions.  Those are trivial wrappers around
_gfortrani_{max,min}loc2_{4,8,16}_s{1,4} which should call those functions
if the scalar mask is true and just return 0 otherwise.
The two bugs I see there is that the back, len arguments are swapped,
which means that it always acts as back=.true. and for len will use
character length of 1 or 0 instead of the desired one.
The _gfortrani_{max,min}loc2_{4,8,16}_s{1,4} functions have prototypes like
GFC_INTEGER_4
maxloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charlen_type len)
so back comes before len, ditto for the
GFC_INTEGER_4
smaxloc2_4_s1 (gfc_array_s1 * const restrict array,
               GFC_LOGICAL_4 *mask, GFC_LOGICAL_4 back, gfc_charlen_type len)
The other problem is that it was just testing if (mask).  In my limited
Fortran understanding that means that the optional argument mask was
supplied but nothing about its actual value.  Other scalar mask generated
routines use if (mask == NULL || *mask) as the condition when to call the
non-masked function, i.e. when mask is not supplied (then it should act like
.true. mask) or when it is supplied and evaluates to .true.).

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR fortran/120191
* m4/maxloc2s.m4: For smaxloc2 call maxloc2 if mask is NULL or *mask.
Swap back and len arguments.
* m4/minloc2s.m4: Likewise.
* generated/maxloc2_4_s1.c: Regenerate.
* generated/maxloc2_4_s4.c: Regenerate.
* generated/maxloc2_8_s1.c: Regenerate.
* generated/maxloc2_8_s4.c: Regenerate.
* generated/maxloc2_16_s1.c: Regenerate.
* generated/maxloc2_16_s4.c: Regenerate.
* generated/minloc2_4_s1.c: Regenerate.
* generated/minloc2_4_s4.c: Regenerate.
* generated/minloc2_8_s1.c: Regenerate.
* generated/minloc2_8_s4.c: Regenerate.
* generated/minloc2_16_s1.c: Regenerate.
* generated/minloc2_16_s4.c: Regenerate.

* gfortran.dg/pr120191_2.f90: New test.

(cherry picked from commit 482f2192d4ef6af55acae2dc3e0df00b8487cc7d)

2 months agofortran: Fix up minloc/maxloc lowering [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:14:55 +0000 (14:14 +0200)] 
fortran: Fix up minloc/maxloc lowering [PR120191]

We need to drop the kind argument from what is passed to the
library, but need to do it not only when one uses the argument name
for it (so kind=4 etc.) but also when one passes all the arguments
to the intrinsics.

The following patch uses what gfc_conv_intrinsic_findloc uses,
which looks more efficient and cleaner, we already set automatic
vars to point to the kind and back actual arguments, so we can just
free/clear expr on the former and set name to "%VAL" on the latter.

And similarly clears dim argument for the BT_CHARACTER case when using
maxloc2/minloc2, again regardless of whether it was named or not.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>
    Daniil Kochergin  <daniil2472s@gmail.com>
    Tobias Burnus  <tburnus@baylibre.com>

PR fortran/120191
* trans-intrinsic.cc (strip_kind_from_actual): Remove.
(gfc_conv_intrinsic_minmaxloc): Don't call strip_kind_from_actual.
Free and clear kind_arg->expr if non-NULL.  Set back_arg->name to
"%VAL" instead of a loop looking for last argument.  Remove actual
variable, use array_arg instead.  Free and clear dim_arg->expr if
non-NULL for BT_CHARACTER cases instead of using a loop.

* gfortran.dg/pr120191_1.f90: New test.

(cherry picked from commit ec249be3c287c6f1dfb328712ac9c39e6fa95eca)

2 months agoDaily bump.
GCC Administrator [Tue, 13 May 2025 00:24:47 +0000 (00:24 +0000)] 
Daily bump.

2 months agolibstdc++: Remove #warning from <ciso646> for C++17 [PR120187]
Jonathan Wakely [Fri, 9 May 2025 09:23:05 +0000 (10:23 +0100)] 
libstdc++: Remove #warning from <ciso646> for C++17 [PR120187]

Although <ciso646> was removed from C++20, it was not formally
deprecated in C++17. In contrast, <ctgmath>, <cstdalign>, etc. were
formally deprecated in C++17 before being removed in C++20.

Due to the widespread convention of including <ciso646> to detect
implementation-specific macros (such as _GLIBCXX_RELEASE) it causes
quite a lot of noise to issue deprecation warnings in C++17 mode. The
recommendation to include <version> instead does work for recent
compilers, even in C++17 mode, but isn't portable to older compilers
that don't provide <version> yet (e.g. GCC 8).

There are also potential objections to including <version> pre-C++20
when it wasn't defined by the standard. I don't have much sympathy for
this position, because including <ciso646> for implementation-specific
macros wasn't part of the C++17 standard either. It's no more
non-standard to rely on <version> being present and defining those
macros than to rely on <ciso646> defining them, and __has_include can be
used to detect whether <version> is present. However, <ciso646> is being
used in the wild by popular libraries like Abseil and we can't change
versions of those that have already been released.

This removes the #warning in <ciso646> for C++17 mode, so that we only
emit diagnostics for C++20 and later. With this change, including
<ciso646> in C++20 or later gives an error if _GLIBCXX_USE_DEPRECATED is
defined to zero, otherwise a warning if -Wdeprecated is enabled,
otherwise no diagnostic is given.

This also adds "@since C++11 (removed in C++20)" to the Doxygen @file
comments in all the relevant headers.

The test for <ciso646> needs to be updated to no longer expect a warning
for c++17_only. A new test is added to ensure that we get a warning
instead of an error when -D_GLIBCXX_USE_DEPRECATED=0 is not used.

libstdc++-v3/ChangeLog:

PR libstdc++/120187
* include/c_global/ciso646: Only give deprecated warning for
C++20 and later.
* include/c_global/ccomplex: Add @since to Doxygen comment.
* include/c_global/cstdalign: Likewise.
* include/c_global/cstdbool: Likewise.
* include/c_global/ctgmath: Likewise.
* testsuite/18_support/headers/ciso646/macros.cc: Remove
dg-warning for c++17_only effective target.
* testsuite/18_support/headers/ciso646/macros-2.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit af062510f4179aa7b13e632f77593deee8fe29f2)

2 months agolibstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198]
Jonathan Wakely [Fri, 9 May 2025 16:50:52 +0000 (17:50 +0100)] 
libstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198]

This was a regression introduced with using version.def to define
feature test macros (r14-3248-g083b7f2833d71d). std::scoped_lock doesn't
need to depend on gthreads and so can be defined unconditionally, even
for freestanding.

libstdc++-v3/ChangeLog:

PR libstdc++/120198
* include/bits/version.def (scoped_lock): Do not depend on
gthreads or hosted.
* include/bits/version.h: Regenerate.
* include/std/mutex (scoped_lock): Update comment.
* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
Remove dg-require-gthreads and use custom lockable type instead
of std::mutex. Check that typedef is only present for a single
template argument.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit bdd2753f5f021a15a6c4ef02565356985fea1300)

2 months agoc+: -Wabi false positive [PR120012]
Jason Merrill [Mon, 12 May 2025 15:53:03 +0000 (11:53 -0400)] 
c+: -Wabi false positive [PR120012]

The warning compares the position of a field depending on whether or not the
previous base/field is considered a POD for layout, but failed to consider
whether the previous base/field is empty; layout of an empty base doesn't
consider PODness.

PR c++/120012

gcc/cp/ChangeLog:

* class.cc (check_non_pod_aggregate): Check is_empty_class.

gcc/testsuite/ChangeLog:

* g++.dg/abi/base-defaulted2.C: New test.

(cherry picked from commit b4b4dfbd22e06877052bd4cc4b191d9d138155cf)

2 months agoUpdate cpplib es.po
Joseph Myers [Mon, 12 May 2025 17:56:18 +0000 (17:56 +0000)] 
Update cpplib es.po

* es.po: Update.

2 months agoUpdate gcc sv.po
Joseph Myers [Mon, 12 May 2025 17:38:12 +0000 (17:38 +0000)] 
Update gcc sv.po

* sv.po: Update.

2 months agolibstdc++: Update C++23 status table
Jonathan Wakely [Thu, 8 May 2025 14:35:43 +0000 (15:35 +0100)] 
libstdc++: Update C++23 status table

This should have been updated for the GCC 15.1 release.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2023.xml: Update status of proposals
implemented after GCC 14.2 release.
* doc/html/*: Regenerate.

(cherry picked from commit 203eb116ec60afba61c9fbe6cc4b54310ecda9de)

2 months agolibstdc++: Fix constraint recursion in std::expected's operator== [PR119714]
Patrick Palka [Mon, 12 May 2025 13:15:34 +0000 (09:15 -0400)] 
libstdc++: Fix constraint recursion in std::expected's operator== [PR119714]

This std::expected friend operator== is prone to constraint recursion
after CWG 2369 for the same reason as basic_const_iterator's comparison
operators were before the r15-7757-g4342c50ca84ae5 workaround.  This
patch works around the constraint recursion here in a similar manner,
by making the function parameter of type std::expected dependent in a
trivial way.

PR libstdc++/119714
PR libstdc++/112490

libstdc++-v3/ChangeLog:

* include/std/expected (expected::operator==): Replace
non-dependent std::expected function parameter with a dependent
one of type expected<_Vp, _Er> where _Vp matches _Tp.
* testsuite/20_util/expected/119714.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 91bc8169edd9038d78f38bd813287d72e6345c26)

2 months agolibstdc++: Fix availability of std::erase_if(std::flat_foo) [PR119427]
Patrick Palka [Tue, 29 Apr 2025 12:21:35 +0000 (08:21 -0400)] 
libstdc++: Fix availability of std::erase_if(std::flat_foo) [PR119427]

These std::erase_if overloads were wrongly implemented as hidden
friends, visible only via ADL, so erase_if(x) would work but not
std::erase_if(x).

PR libstdc++/119427

libstdc++-v3/ChangeLog:

* include/std/flat_map (_Flat_map_impl::erase_if): Replace
this hidden friend with ...
(_Flat_map_impl::_M_erase_if): ... this member function.
(flat_map): Export _Flat_map_impl::_M_erase_if.
(erase_if(flat_map)): Define.
(flat_multimap): Export _Flat_map_impl::_M_erase_if.
(erase_if(flat_multimap)): Define.
* include/std/flat_set (_Flat_set_impl::erase_if): Replace
with ...
(_Flat_set_impl::_M_erase_if): ... this member function.
(flat_set): Export _Flat_set_impl::_M_erase_if.
(erase_if(flat_set)): Define.
(flat_multiset): Export _Flat_set_impl::_M_erase_if.
(erase_if(flat_multiset)): Define.
* testsuite/23_containers/flat_map/1.cc (test07): New test.
* testsuite/23_containers/flat_multimap/1.cc (test07): New test.
* testsuite/23_containers/flat_multiset/1.cc (test09): New test.
* testsuite/23_containers/flat_set/1.cc (test09): New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit aa93272cfd2233858da0792761387cc27f4d5ff3)

2 months agolibstdc++: Suppress GDB output from new 'skip' commands [PR118260]
Jonathan Wakely [Fri, 9 May 2025 10:39:39 +0000 (11:39 +0100)] 
libstdc++: Suppress GDB output from new 'skip' commands [PR118260]

I added some gdb.execute('skip -rfu ...') commands to the Python hook
loaded with libstdc++.so but this makes GDB print output like:

Function(s) ^std::(move|forward|as_const|(__)?addressof) will be skipped when stepping.

This probably aren't interesting to users, so this change suppresses
that output by capturing the output into the gdb.execute return value
(which is then ignored). An exception is thrown if the gdb.execute
command fails, so this doesn't suppress any errors which might be
meaningful to users or libstdc++ developers.

libstdc++-v3/ChangeLog:

PR libstdc++/118260
* python/hook.in: Suppress output from gdb.execute calls to
register skips.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 31cbac3037b7811bd0df63f4a09aa981b250c4bf)

2 months agolibstdc++: Update <charconv> rows in C++17 status table
Jonathan Wakely [Thu, 8 May 2025 13:48:16 +0000 (14:48 +0100)] 
libstdc++: Update <charconv> rows in C++17 status table

Document that std::to_chars and std::from_chars are complete, mentioning
the libraries used for floating-point types.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2017.xml: Update status for
std::to_chars and std::from_chars.
* doc/html/manual/*: Regenerate.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Björn Schäpers <gcc@hazardy.de>
(cherry picked from commit e0bcedba6132fa5c75cb22b9232dbe72c7b3fea0)