[gcc r15-8524] gccrs: Push ribs by kind rather than by value
https://gcc.gnu.org/g:5d169079df844aaf1175769ce6ba49697d55ae4d commit r15-8524-g5d169079df844aaf1175769ce6ba49697d55ae4d Author: Owen Avery Date: Mon Nov 11 16:37:38 2024 -0500 gccrs: Push ribs by kind rather than by value gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::push): Accept argument of type Rib::Kind rather than Rib. * resolve/rust-forever-stack.hxx (ForeverStack::push): Likewise. * resolve/rust-name-resolution-context.cc (NameResolutionContext::scoped): Likewise. * resolve/rust-name-resolution-context.h (NameResolutionContext::scoped): Likewise. Signed-off-by: Owen Avery Diff: --- gcc/rust/resolve/rust-forever-stack.h| 2 +- gcc/rust/resolve/rust-forever-stack.hxx | 5 +++-- gcc/rust/resolve/rust-name-resolution-context.cc | 15 --- gcc/rust/resolve/rust-name-resolution-context.h | 9 + 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index 28509259497b..c548eeae0879 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -416,7 +416,7 @@ public: * @param path An optional path if the Rib was created due to a "named" *lexical scope, like a module's. */ - void push (Rib rib, NodeId id, tl::optional path = {}); + void push (Rib::Kind rib_kind, NodeId id, tl::optional path = {}); /** * Pop the innermost Rib from the stack diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 31f8ba498b32..58164a4d3285 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -52,9 +52,10 @@ ForeverStack::Node::insert_child (Link link, Node child) template void -ForeverStack::push (Rib rib, NodeId id, tl::optional path) +ForeverStack::push (Rib::Kind rib_kind, NodeId id, + tl::optional path) { - push_inner (rib, Link (id, path)); + push_inner (rib_kind, Link (id, path)); } template diff --git a/gcc/rust/resolve/rust-name-resolution-context.cc b/gcc/rust/resolve/rust-name-resolution-context.cc index 9bfaa094abe1..1b3752138785 100644 --- a/gcc/rust/resolve/rust-name-resolution-context.cc +++ b/gcc/rust/resolve/rust-name-resolution-context.cc @@ -103,13 +103,13 @@ NameResolutionContext::lookup (NodeId usage) const } void -NameResolutionContext::scoped (Rib rib, NodeId id, +NameResolutionContext::scoped (Rib::Kind rib_kind, NodeId id, std::function lambda, tl::optional path) { - values.push (rib, id, path); - types.push (rib, id, path); - macros.push (rib, id, path); + values.push (rib_kind, id, path); + types.push (rib_kind, id, path); + macros.push (rib_kind, id, path); // labels.push (rib, id); lambda (); @@ -121,17 +121,18 @@ NameResolutionContext::scoped (Rib rib, NodeId id, } void -NameResolutionContext::scoped (Rib rib, Namespace ns, NodeId scope_id, +NameResolutionContext::scoped (Rib::Kind rib_kind, Namespace ns, + NodeId scope_id, std::function lambda, tl::optional path) { switch (ns) { case Namespace::Values: - values.push (rib, scope_id, path); + values.push (rib_kind, scope_id, path); break; case Namespace::Types: - types.push (rib, scope_id, path); + types.push (rib_kind, scope_id, path); break; case Namespace::Labels: case Namespace::Macros: diff --git a/gcc/rust/resolve/rust-name-resolution-context.h b/gcc/rust/resolve/rust-name-resolution-context.h index cd6fa931be51..183ce7f3c2e4 100644 --- a/gcc/rust/resolve/rust-name-resolution-context.h +++ b/gcc/rust/resolve/rust-name-resolution-context.h @@ -185,8 +185,8 @@ public: * function. This variant of the function enters a new scope in *all* * namespaces, while the second variant enters a scope in *one* namespace. * - * @param rib New `Rib` to create when entering this scope. A function `Rib`, - *or an item `Rib`... etc + * @param rib_kind New `Rib` to create when entering this scope. A function + *`Rib`, or an item `Rib`... etc * @param scope_id node ID of the scope we are entering, e.g the block's *`NodeId`. * @param lambda Function to run within that scope @@ -196,9 +196,10 @@ public: */ // FIXME: Do we want to handle something in particular for expected within the // scoped lambda? - void scoped (Rib rib, NodeId scope_id, std::function lambda, + void scoped (Rib::Kind rib_kind, NodeId scope_id, + std::function lambda, tl::optional path = {}); - void scoped (Rib rib, Namespace ns, NodeId scope_id, + void scoped (Rib::Kind rib_kin
[gcc r15-8882] arm: add commutative alternatives to mull pattern.
https://gcc.gnu.org/g:a86891525d200c1ae81d9f5f441a5b8e24b647ca commit r15-8882-ga86891525d200c1ae81d9f5f441a5b8e24b647ca Author: Richard Earnshaw Date: Tue Mar 25 11:50:30 2025 + arm: add commutative alternatives to mull pattern. Prior to Armv6, the SMULL and UMULL instructions, which have the form UMULL Rdlo, Rdhi, Rm, Rs had an operand restriction such that Rdlo, Rdhi and Rm must all be different registers. Rs, however can overlap either of the destination registers. Add some register-tie alternatives to allow the register allocator to find these forms without having to use additional register moves. In addition to this, the test is pretty meaningless on Thumb-1 targets as the S/UMULL instructions do not exist in a 16-bit encoding. So skip the test in this case. gcc/ChangeLog: * config/arm/arm.md (mull): Add alternatives that allow Rs to be tied to either Rdlo or Rdhi. gcc/testsuite/ChangeLog: * gcc.target/arm/pr42575.c: Skip test if thumb1. Diff: --- gcc/config/arm/arm.md | 10 +- gcc/testsuite/gcc.target/arm/pr42575.c | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 442d86b93292..597ef6725bb7 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -2432,11 +2432,11 @@ ) (define_insn "mull" - [(set (match_operand:SI 0 "s_register_operand" "=r,&r") + [(set (match_operand:SI 0 "s_register_operand" "=r,&r,&r,&r") (mult:SI -(match_operand:SI 2 "s_register_operand" "%r,r") -(match_operand:SI 3 "s_register_operand" "r,r"))) - (set (match_operand:SI 1 "s_register_operand" "=r,&r") +(match_operand:SI 2 "s_register_operand" "%r,r,r,r") +(match_operand:SI 3 "s_register_operand" "r,r,0,1"))) + (set (match_operand:SI 1 "s_register_operand" "=r,&r,&r,&r") (truncate:SI (lshiftrt:DI (mult:DI (SE:DI (match_dup 2)) (SE:DI (match_dup 3))) @@ -2445,7 +2445,7 @@ "mull%?\\t%0, %1, %2, %3" [(set_attr "type" "umull") (set_attr "predicable" "yes") - (set_attr "arch" "v6,nov6")] + (set_attr "arch" "v6,nov6,nov6,nov6")] ) (define_expand "maddsidi4" diff --git a/gcc/testsuite/gcc.target/arm/pr42575.c b/gcc/testsuite/gcc.target/arm/pr42575.c index 1998e323df17..3906c77ed569 100644 --- a/gcc/testsuite/gcc.target/arm/pr42575.c +++ b/gcc/testsuite/gcc.target/arm/pr42575.c @@ -1,4 +1,5 @@ /* { dg-options "-O2" } */ +/* { dg-skip-if "Thumb1 lacks UMULL" { arm_thumb1 } } */ /* Make sure RA does good job allocating registers and avoids unnecessary moves. */ /* { dg-final { scan-assembler-not "mov" } } */
[gcc/devel/omp/gcc-14] c++: fix return type of __cxa_bad_array_new_length
https://gcc.gnu.org/g:ad200708db0ab5d97b3bdcc8919f17a58cf930b2 commit ad200708db0ab5d97b3bdcc8919f17a58cf930b2 Author: Jason Merrill Date: Thu Mar 20 09:55:40 2025 -0400 c++: fix return type of __cxa_bad_array_new_length We were lying about the return type, but that's not necessary; we already need to handle a COND_EXPR where one side is void for THROW_EXPR. This fixes an execution failure on nvptx: error: Prototype doesn't match for '__cxa_throw_bad_array_new_length' gcc/cp/ChangeLog: * init.cc (throw_bad_array_new_length): Returns void. (cherry picked from commit cb537f0d838bac376bfe5e6d765e19cd3af01031) Diff: --- gcc/cp/ChangeLog.omp | 5 + gcc/cp/init.cc | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index ed923563941f..e37a4344ca47 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,5 +1,10 @@ 2025-03-25 Thomas Schwinge + Backported from trunk: + 2025-03-21 Jason Merrill + + * init.cc (throw_bad_array_new_length): Returns void. + Backported from trunk: 2025-03-21 Thomas Schwinge diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index e622547a092f..12e7cecfc59f 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -2800,8 +2800,7 @@ diagnose_uninitialized_cst_or_ref_member (tree type, bool using_new, bool compla } /* Call __cxa_bad_array_new_length to indicate that the size calculation - overflowed. Pretend it returns sizetype so that it plays nicely in the - COND_EXPR. */ + overflowed. */ tree throw_bad_array_new_length (void) @@ -2813,7 +2812,7 @@ throw_bad_array_new_length (void) fn = get_global_binding (name); if (!fn) fn = push_throw_library_fn - (name, build_function_type_list (sizetype, NULL_TREE)); + (name, build_function_type_list (void_type_node, NULL_TREE)); } return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
[gcc/devel/omp/gcc-14] Add 'gcc.target/nvptx/alias-unsupported-1.c'
https://gcc.gnu.org/g:4a23af4ce199a57e52ff1782262d0bbc5b399974 commit 4a23af4ce199a57e52ff1782262d0bbc5b399974 Author: Thomas Schwinge Date: Tue Mar 18 16:14:42 2025 +0100 Add 'gcc.target/nvptx/alias-unsupported-1.c' ... testing for the GCC/nvptx "alias definitions not supported" error diagnostic. gcc/testsuite/ * gcc.target/nvptx/alias-unsupported-1.c: New. (cherry picked from commit 6d3a48baac33e9ccd6ea02012078fefd48181af3) Diff: --- gcc/testsuite/ChangeLog.omp | 7 +++ gcc/testsuite/gcc.target/nvptx/alias-unsupported-1.c | 9 + 2 files changed, 16 insertions(+) diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index ae13f4c40638..45c57dbcf2dc 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,10 @@ +2025-03-25 Thomas Schwinge + + Backported from trunk: + 2025-03-21 Thomas Schwinge + + * gcc.target/nvptx/alias-unsupported-1.c: New. + 2025-03-21 Paul-Antoine Arras Backported from master: diff --git a/gcc/testsuite/gcc.target/nvptx/alias-unsupported-1.c b/gcc/testsuite/gcc.target/nvptx/alias-unsupported-1.c new file mode 100644 index ..47b30bd928b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/alias-unsupported-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-additional-options -mno-alias } */ + +void __f () +{ +} + +void f () __attribute__ ((alias ("__f"))); +/* { dg-error {alias definitions not supported} {} { target *-*-* } .-1 } */
[gcc/devel/omp/gcc-14] Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-2.C'
https://gcc.gnu.org/g:0b492224e115de78152f68a84fb0c53d6524450c commit 0b492224e115de78152f68a84fb0c53d6524450c Author: Thomas Schwinge Date: Tue Mar 18 16:18:54 2025 +0100 Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-2.C' ... next to '-malias' variant: commit a1865fd33897bc6c6e0109df0a12ee73ce386315 "Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'", to document what we're doing to '-mno-alias'. gcc/testsuite/ * g++.target/nvptx/alias-g++.dg_init_dtor2-2.C: New. (cherry picked from commit f7f6a3dd8251421f873dc99be4acb70ae277d509) Diff: --- gcc/testsuite/ChangeLog.omp| 5 .../g++.target/nvptx/alias-g++.dg_init_dtor2-2.C | 33 ++ 2 files changed, 38 insertions(+) diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 45c57dbcf2dc..ca1886735360 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -3,6 +3,11 @@ Backported from trunk: 2025-03-21 Thomas Schwinge + * g++.target/nvptx/alias-g++.dg_init_dtor2-2.C: New. + + Backported from trunk: + 2025-03-21 Thomas Schwinge + * gcc.target/nvptx/alias-unsupported-1.c: New. 2025-03-21 Paul-Antoine Arras diff --git a/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-2.C b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-2.C new file mode 100644 index ..f00575e023ee --- /dev/null +++ b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-2.C @@ -0,0 +1,33 @@ +/* Reduced from 'g++.dg/init/dtor2.C'. */ + +/* { dg-do link } */ +/* { dg-additional-options -mno-alias } */ +/* { dg-additional-options -save-temps } */ +/* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient. */ + +struct B +{ + ~B(); +}; + +B::~B () { +} + +int main() +{ + B b; + return 0; +} + +/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: _ZN1BD2Ev$} 1 } } + { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD2Ev \(\.param\.u64 %in_ar0\);$} 1 } } + { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: _ZN1BD2Ev$} 1 } } + { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD2Ev \(\.param\.u64 %in_ar0\)$} 1 } } */ + +/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: _ZN1BD1Ev$} 1 } } + { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD1Ev \(\.param\.u64 %in_ar0\);$} 1 } } + { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: _ZN1BD1Ev$} 1 } } + { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD1Ev \(\.param\.u64 %in_ar0\)$} 1 } } */ + +/* { dg-final { scan-assembler-times {(?n)\tcall _ZN1BD1Ev, \(} 1 } } + { dg-final { scan-assembler-times {(?n)\tcall _ZN1BD2Ev, \(} 0 } } */
[gcc/devel/omp/gcc-14] nvptx: Default at least to '-mptx=6.3'
https://gcc.gnu.org/g:e052d4160675bab88f4ece1d228174298ff88e20 commit e052d4160675bab88f4ece1d228174298ff88e20 Author: Thomas Schwinge Date: Thu Mar 20 14:21:26 2025 +0100 nvptx: Default at least to '-mptx=6.3' gcc/ * config/nvptx/nvptx.cc (default_ptx_version_option): Default at least to '-mptx=6.3'. * doc/invoke.texi (Nvidia PTX Options): Update '-mptx=[...]'. gcc/testsuite/ * gcc.target/nvptx/march-map=sm_30.c: Adjust. * gcc.target/nvptx/march-map=sm_32.c: Likewise. * gcc.target/nvptx/march-map=sm_35.c: Likewise. * gcc.target/nvptx/march-map=sm_37.c: Likewise. * gcc.target/nvptx/march-map=sm_50.c: Likewise. * gcc.target/nvptx/march=sm_30.c: Likewise. * gcc.target/nvptx/march=sm_35.c: Likewise. * gcc.target/nvptx/march=sm_37.c: Likewise. (cherry picked from commit 5450afcfb761834b7f4156022f1ec38f2226c193) Diff: --- gcc/ChangeLog.omp| 9 + gcc/config/nvptx/nvptx.cc| 3 +++ gcc/doc/invoke.texi | 2 +- gcc/testsuite/ChangeLog.omp | 12 gcc/testsuite/gcc.target/nvptx/march-map=sm_30.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march-map=sm_32.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march-map=sm_35.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march-map=sm_37.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march-map=sm_50.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march=sm_30.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march=sm_35.c | 4 ++-- gcc/testsuite/gcc.target/nvptx/march=sm_37.c | 4 ++-- 12 files changed, 41 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 2f931af7425c..dd3b0e1e029a 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,12 @@ +2025-03-25 Thomas Schwinge + + Backported from trunk: + 2025-03-24 Thomas Schwinge + + * config/nvptx/nvptx.cc (default_ptx_version_option): Default at + least to '-mptx=6.3'. + * doc/invoke.texi (Nvidia PTX Options): Update '-mptx=[...]'. + 2025-03-21 Paul-Antoine Arras Backported from master: diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 6dd358bf3d58..6ebc2d627eeb 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -251,6 +251,9 @@ default_ptx_version_option (void) warp convergence. */ res = MAX (res, PTX_VERSION_6_0); + /* Pick at least 6.3. */ + res = MAX (res, PTX_VERSION_6_3); + /* For sm_52+, pick at least 7.3, to enable PTX 'alloca'. */ if (ptx_isa_option >= PTX_ISA_SM52) res = MAX (res, PTX_VERSION_7_3); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c32a44e9cb3b..9b39a7598691 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -30062,7 +30062,7 @@ Valid version strings are @samp{7.0}, @samp{7.3}, and @samp{7.8}. The default PTX ISA version is the one that added support for the selected PTX ISA target architecture, see @option{-march=}, but at -least @samp{6.0}, or @samp{7.3} for @option{-march=sm_52} and higher. +least @samp{6.3}, or @samp{7.3} for @option{-march=sm_52} and higher. This option sets the values of the preprocessor macros @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index ca1886735360..2437f76e7553 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,5 +1,17 @@ 2025-03-25 Thomas Schwinge + Backported from trunk: + 2025-03-24 Thomas Schwinge + + * gcc.target/nvptx/march-map=sm_30.c: Adjust. + * gcc.target/nvptx/march-map=sm_32.c: Likewise. + * gcc.target/nvptx/march-map=sm_35.c: Likewise. + * gcc.target/nvptx/march-map=sm_37.c: Likewise. + * gcc.target/nvptx/march-map=sm_50.c: Likewise. + * gcc.target/nvptx/march=sm_30.c: Likewise. + * gcc.target/nvptx/march=sm_35.c: Likewise. + * gcc.target/nvptx/march=sm_37.c: Likewise. + Backported from trunk: 2025-03-21 Thomas Schwinge diff --git a/gcc/testsuite/gcc.target/nvptx/march-map=sm_30.c b/gcc/testsuite/gcc.target/nvptx/march-map=sm_30.c index b69926e6debc..b5e2c19b07c9 100644 --- a/gcc/testsuite/gcc.target/nvptx/march-map=sm_30.c +++ b/gcc/testsuite/gcc.target/nvptx/march-map=sm_30.c @@ -1,14 +1,14 @@ /* { dg-do assemble } */ /* { dg-options {-march-map=sm_30 -mptx=_} } */ /* { dg-additional-options -save-temps } */ -/* { dg-final { scan-assembler-times {(?n)^\.version 6\.0$} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)^\.version 6\.3$} 1 } } */ /* { dg-final { scan-assembler-times {(?n)^\.targetsm_30$} 1 } } */ #if __PTX_ISA_VERSION_MAJOR__ != 6 #error wrong value for __PTX_ISA_VERSION_MAJOR__ #endif -#if __
[gcc/devel/omp/gcc-14] nvptx: In offloading compilation, special-case certain host-setup symbol aliases [PR101544]
https://gcc.gnu.org/g:5d90a8a8e3d682d1eaad0bcf41bebc35bc40af9c commit 5d90a8a8e3d682d1eaad0bcf41bebc35bc40af9c Author: Thomas Schwinge Date: Thu Mar 20 14:21:26 2025 +0100 nvptx: In offloading compilation, special-case certain host-setup symbol aliases [PR101544] Namely, use PTX '.alias' even for (default) '-mno-alias' if the host made the C++ "base and complete [cd]tor aliases". PR target/101544 gcc/ * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls) [ACCEL_COMPILER]: Special-case certain host-setup symbol aliases. * varasm.cc (do_assemble_alias) [ACCEL_COMPILER]: Adjust. (cherry picked from commit 65b31b3fff2fced015ded1026733605f34053796) Diff: --- gcc/ChangeLog.omp | 8 gcc/config/nvptx/nvptx.cc | 28 +++- gcc/varasm.cc | 7 ++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index dd3b0e1e029a..d26fc33b9a09 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -3,6 +3,14 @@ Backported from trunk: 2025-03-24 Thomas Schwinge + PR target/101544 + * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls) + [ACCEL_COMPILER]: Special-case certain host-setup symbol aliases. + * varasm.cc (do_assemble_alias) [ACCEL_COMPILER]: Adjust. + + Backported from trunk: + 2025-03-24 Thomas Schwinge + * config/nvptx/nvptx.cc (default_ptx_version_option): Default at least to '-mptx=6.3'. * doc/invoke.texi (Nvidia PTX Options): Update '-mptx=[...]'. diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 6ebc2d627eeb..886a39a26e95 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -251,7 +251,7 @@ default_ptx_version_option (void) warp convergence. */ res = MAX (res, PTX_VERSION_6_0); - /* Pick at least 6.3. */ + /* Pick at least 6.3, to enable PTX '.alias'. */ res = MAX (res, PTX_VERSION_6_3); /* For sm_52+, pick at least 7.3, to enable PTX 'alloca'. */ @@ -8426,6 +8426,30 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, { if (nvptx_alias == 0 || !TARGET_PTX_6_3) { + /* Symbol aliases are not supported here. */ + +#ifdef ACCEL_COMPILER + if (DECL_CXX_CONSTRUCTOR_P (name) + || DECL_CXX_DESTRUCTOR_P (name)) + { + /* ..., but symbol aliases are supported and used in the host system, +via 'gcc/cp/optimize.cc:can_alias_cdtor'. */ + + gcc_assert (!lookup_attribute ("weak", DECL_ATTRIBUTES (name))); + gcc_assert (TREE_CODE (name) == FUNCTION_DECL); + + /* In this specific case, use PTX '.alias', if available, even for +(default) '-mno-alias'. */ + if (TARGET_PTX_6_3) + { + DECL_ATTRIBUTES (name) + = tree_cons (get_identifier ("symbol alias handled"), +NULL_TREE, DECL_ATTRIBUTES (name)); + goto emit_ptx_alias; + } + } +#endif + /* Copied from assemble_alias. */ error_at (DECL_SOURCE_LOCATION (name), "alias definitions not supported in this configuration"); @@ -8457,6 +8481,8 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, return; } + emit_ptx_alias: + cgraph_node *cnode = cgraph_node::get (name); if (!cnode->referred_to_p ()) /* Prevent "Internal error: reference to deleted section". */ diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 0a0da8c142ea..0a03285a8214 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -6339,7 +6339,12 @@ do_assemble_alias (tree decl, tree target) IDENTIFIER_POINTER (target)); # endif /* If symbol aliases aren't actually supported... */ - if (!TARGET_SUPPORTS_ALIASES) + if (!TARGET_SUPPORTS_ALIASES +# ifdef ACCEL_COMPILER + /* ..., and unless special-cased... */ + && !lookup_attribute ("symbol alias handled", DECL_ATTRIBUTES (decl)) +# endif + ) /* ..., 'ASM_OUTPUT_DEF{,_FROM_DECLS}' better have raised an error. */ gcc_checking_assert (seen_error ()); #elif defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
[gcc/devel/omp/gcc-14] Merge commit '10041f146132993c328e3112e33e33c08f90ae06' into HEAD
https://gcc.gnu.org/g:d7450bc0725a9032e30fb111f21a143066be3784 commit d7450bc0725a9032e30fb111f21a143066be3784 Merge: b6cc32a175fe 10041f146132 Author: Thomas Schwinge Date: Tue Mar 25 09:16:05 2025 +0100 Merge commit '10041f146132993c328e3112e33e33c08f90ae06' into HEAD Diff: libgomp/ChangeLog.omp | 8 libgomp/plugin/plugin-nvptx.c | 18 -- libgomp/target.c | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --cc libgomp/ChangeLog.omp index d8881985f2be,d0a2d53881dd..9cb3e08e8279 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@@ -1,21 -1,11 +1,29 @@@ +2025-03-25 Thomas Schwinge + + Backported from trunk: + 2025-03-24 Thomas Schwinge + + PR libgomp/96835 + * testsuite/libgomp.c++/pr96835-1.C: New. + * testsuite/libgomp.c++/pr96835-1-O0.C: Likewise. + * testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise. + + Backported from trunk: + 2025-03-24 Thomas Schwinge + + PR target/101544 + * testsuite/libgomp.c++/pr101544-1.C: New. + * testsuite/libgomp.c++/pr101544-1-O0.C: Likewise. + * testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise. + + 2025-03-24 Tobias Burnus + + Backported from master: + 2025-03-24 Tobias Burnus + + * plugin/plugin-nvptx.c (GOMP_OFFLOAD_interop): Set context for + stream creation to use the specified device. + 2025-03-21 Tobias Burnus Backported from master:
[gcc r15-8880] libstdc++: Cast -1 to size_t in [PR119429]
https://gcc.gnu.org/g:039cc50867000e6427924ca490dc810eaa44cf08 commit r15-8880-g039cc50867000e6427924ca490dc810eaa44cf08 Author: Jonathan Wakely Date: Mon Mar 24 21:25:20 2025 + libstdc++: Cast -1 to size_t in [PR119429] This avoids a runtime error from Clang's annoying -fsanitize=integer (even though it's not undefined and behaves correctly). libstdc++-v3/ChangeLog: PR libstdc++/119429 * include/std/format (__format::_Scanner::_Scanner): Cast default argument to size_t. Diff: --- libstdc++-v3/include/std/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 1b38913359d1..c3327e1d3841 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -4051,7 +4051,7 @@ namespace __format } _M_pc; constexpr explicit - _Scanner(basic_string_view<_CharT> __str, size_t __nargs = -1) + _Scanner(basic_string_view<_CharT> __str, size_t __nargs = (size_t)-1) : _M_pc(__str, __nargs) { }
[gcc r15-8881] opcodes: fix wrong code in expand_binop_directly [PR117811]
https://gcc.gnu.org/g:7679b826840c58343d72d05922355b646db4bdcc commit r15-8881-g7679b826840c58343d72d05922355b646db4bdcc Author: Richard Earnshaw Date: Thu Mar 20 14:42:59 2025 + opcodes: fix wrong code in expand_binop_directly [PR117811] If expand_binop_directly fails to add a REG_EQUAL note it tries to unwind and restart. But it can unwind too far if expand_binop changed some of the operands before calling it. We don't need to unwind that far anyway since we should end up taking exactly the same route next time, just without a target rtx. To fix this we remove LAST from the argument list and let the callers (all in expand_binop) do their own unwinding if the call fails. Instead we unwind just as far as the entry to expand_binop_directly and recurse within this function instead of all the way back up. gcc/ChangeLog: PR middle-end/117811 * optabs.cc (expand_binop_directly): Remove LAST as an argument, instead record the last insn on entry. Only delete insns if we need to restart and restart by calling ourself, not expand_binop. (expand_binop): Update callers to expand_binop_directly. If it fails to expand the operation, delete back to LAST. gcc/testsuite: PR middle-end/117811 * gcc.dg/torture/pr117811.c: New test. Diff: --- gcc/optabs.cc | 24 gcc/testsuite/gcc.dg/torture/pr117811.c | 27 +++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gcc/optabs.cc b/gcc/optabs.cc index 36f2e6af8b5c..0a14b1eef8a5 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -1369,8 +1369,7 @@ avoid_expensive_constant (machine_mode mode, optab binoptab, static rtx expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab, rtx op0, rtx op1, - rtx target, int unsignedp, enum optab_methods methods, - rtx_insn *last) + rtx target, int unsignedp, enum optab_methods methods) { machine_mode xmode0 = insn_data[(int) icode].operand[1].mode; machine_mode xmode1 = insn_data[(int) icode].operand[2].mode; @@ -1380,6 +1379,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab, rtx_insn *pat; rtx xop0 = op0, xop1 = op1; bool canonicalize_op1 = false; + rtx_insn *last = get_last_insn (); /* If it is a commutative operator and the modes would match if we would swap the operands, we can save the conversions. */ @@ -1444,10 +1444,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab, tmp_mode = insn_data[(int) icode].operand[0].mode; if (VECTOR_MODE_P (mode) && maybe_ne (GET_MODE_NUNITS (tmp_mode), 2 * GET_MODE_NUNITS (mode))) - { - delete_insns_since (last); - return NULL_RTX; - } + return NULL_RTX; } else tmp_mode = mode; @@ -1467,14 +1464,14 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab, ops[1].value, ops[2].value, mode0)) { delete_insns_since (last); - return expand_binop (mode, binoptab, op0, op1, NULL_RTX, - unsignedp, methods); + return expand_binop_directly (icode, mode, binoptab, op0, op1, + NULL_RTX, unsignedp, methods); } emit_insn (pat); return ops[0].value; } - delete_insns_since (last); + return NULL_RTX; } @@ -1543,9 +1540,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, if (icode != CODE_FOR_nothing) { temp = expand_binop_directly (icode, mode, binoptab, op0, op1, - target, unsignedp, methods, last); + target, unsignedp, methods); if (temp) return temp; + delete_insns_since (last); } } @@ -1571,9 +1569,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, NULL_RTX, unsignedp, OPTAB_DIRECT); temp = expand_binop_directly (icode, int_mode, otheroptab, op0, newop1, - target, unsignedp, methods, last); + target, unsignedp, methods); if (temp) return temp; + delete_insns_since (last); } /* If this is a multiply, see if we can do a widening operation that @@ -1637,9 +1636,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, if (vop1) { temp = expand_binop_directly (icode, mode, otheroptab, op0, vop1, - target, unsignedp, methods, last); +
[gcc r13-9450] c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504]
https://gcc.gnu.org/g:f10853a0087bc115c8ee1ddb5fc641bffdb7f1a4 commit r13-9450-gf10853a0087bc115c8ee1ddb5fc641bffdb7f1a4 Author: Simon Martin Date: Tue Mar 25 09:26:26 2025 +0100 c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504] We have been miscompiling the following valid code since GCC8, and r8-3497-g281e6c1d8f1b4c === cut here === struct span { span (const int (&__first)[1]) : _M_ptr (__first) {} int operator[] (long __i) { return _M_ptr[__i]; } const int *_M_ptr; }; void foo () { constexpr int a_vec[]{1}; auto vec{[&a_vec]() -> span { return a_vec; }()}; } === cut here === The problem is that perform_implicit_conversion_flags (via mark_rvalue_use) replaces "a_vec" in the return statement by a CONSTRUCTOR representing a_vec's constant value, and then takes its address when invoking span's constructor. So we end up with an instance that points to garbage instead of a_vec's storage. As per Jason's suggestion, this patch simply removes the calls to mark_*_use from perform_implicit_conversion_flags, which fixes the PR. PR c++/117504 gcc/cp/ChangeLog: * call.cc (perform_implicit_conversion_flags): Don't call mark_{l,r}value_use. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-117504.C: New test. * g++.dg/cpp2a/constexpr-117504a.C: New test. (cherry picked from commit fdf846fdddcc0467b9f025757f081c5d54319d08) Diff: --- gcc/cp/call.cc | 5 --- gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C | 60 ++ gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C | 12 ++ 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index d4aaeba94f6d..0cc235cb2b40 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13403,11 +13403,6 @@ perform_implicit_conversion_flags (tree type, tree expr, void *p; location_t loc = cp_expr_loc_or_input_loc (expr); - if (TYPE_REF_P (type)) -expr = mark_lvalue_use (expr); - else -expr = mark_rvalue_use (expr); - if (error_operand_p (expr)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C new file mode 100644 index ..290d3dfd61e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C @@ -0,0 +1,60 @@ +// PR c++/117504 - Initial report +// { dg-do "run" { target c++20 } } + +struct span { + span (const int (&__first)[1]) : _M_ptr (__first) {} + int operator[] (long __i) { return _M_ptr[__i]; } + const int *_M_ptr; +}; + +constexpr int a_global_vec[]{1}; +span myFunctor() { + return a_global_vec; +} + +int main() { + constexpr int a_vec[]{1}; + + // + // This PR's case, that used to be miscompiled. + // + auto lambda_1 = [&a_vec] () -> span { return a_vec; }; + auto vec_1 { lambda_1 () }; + if (vec_1[0] != 1) +__builtin_abort (); + + // Variant that used to be miscompiled as well. + auto lambda_2 = [&] () -> span { return a_vec; }; + auto vec_2 { lambda_2 () }; + if (vec_2[0] != 1) +__builtin_abort (); + + // + // Related cases that worked already. + // + auto lambda_3 = [&a_vec] () /* -> span */ { return a_vec; }; + auto vec_3 { lambda_3 () }; + if (vec_3[0] != 1) +__builtin_abort (); + + auto lambda_4 = [&] () /* -> span */ { return a_vec; }; + auto vec_4 { lambda_4 () }; + if (vec_4[0] != 1) +__builtin_abort (); + + const int (&vec_5)[1] = a_vec; + if (vec_5[0] != 1) +__builtin_abort (); + + span vec_6 (a_vec); + if (vec_6[0] != 1) +__builtin_abort (); + + auto vec_7 = myFunctor (); + if (vec_7[0] != 1) +__builtin_abort (); + + const int (&vec_8)[1] { a_vec }; + if (vec_8[0] != 1) +__builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C new file mode 100644 index ..f6d4dc8cbc53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C @@ -0,0 +1,12 @@ +// PR c++/117504 - ICE discovered by ppalka@ when reducing. +// { dg-do "compile" { target c++20 } } + +struct span { + span (const int* __first) : _M_ptr (__first) {} + int operator[] (long __i) { return _M_ptr[__i]; } + const int *_M_ptr; +}; +int main() { + constexpr int a_vec[]{1}; + auto vec { [&a_vec]() -> span { return a_vec; } () }; +}
[gcc r15-8908] gcc, configure: When checking for basename, use the same process as libiberty [PR119250].
https://gcc.gnu.org/g:87d60bcba534b53255c19aae7d2d24ff7a1be414 commit r15-8908-g87d60bcba534b53255c19aae7d2d24ff7a1be414 Author: Iain Sandoe Date: Thu Mar 13 17:23:33 2025 + gcc, configure: When checking for basename, use the same process as libiberty [PR119250]. We need the configure result from the decl check for basename() in the GCC configuration to match that obtained when configuring libiberty or we get conflicts when is included in any TU that also includes "system.h" or "libiberty.h" directly. PR other/119250 gcc/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Match the configure test in libiberty when checking the basename decl. Signed-off-by: Iain Sandoe Diff: --- gcc/config.in| 10 -- gcc/configure| 18 +++--- gcc/configure.ac | 12 ++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index bc60d36a6352..0d8a6ba18089 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -941,8 +941,8 @@ #endif -/* Define to 1 if you have the declaration of `basename(const char*)', and to - 0 if you don't. */ +/* Define to 1 if you have the declaration of `basename(char*)', and to 0 if + you don't. */ #ifndef USED_FOR_TARGET #undef HAVE_DECL_BASENAME #endif @@ -1888,6 +1888,12 @@ #endif +/* Define to 1 if you have the header file. */ +#ifndef USED_FOR_TARGET +#undef HAVE_LIBGEN_H +#endif + + /* Define to 1 if you have the header file. */ #ifndef USED_FOR_TARGET #undef HAVE_LIMITS_H diff --git a/gcc/configure b/gcc/configure index ae1d34971e42..063b9ce67011 100755 --- a/gcc/configure +++ b/gcc/configure @@ -9508,7 +9508,7 @@ fi for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h sys/mman.h \ sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \ -direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h +direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libgen.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header" @@ -12121,10 +12121,14 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" # normal autoconf function for these. But force definition of # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre # basename handling in libiberty.h. -as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(const char*)" | $as_tr_sh` -ac_fn_cxx_check_decl "$LINENO" "basename(const char*)" "$as_ac_Symbol" " +# Match the configure test in libiberty so that we have a consistent result. +as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(char*)" | $as_tr_sh` +ac_fn_cxx_check_decl "$LINENO" "basename(char*)" "$as_ac_Symbol" " #undef HAVE_DECL_BASENAME #define HAVE_DECL_BASENAME 1 +#if HAVE_LIBGEN_H +# include +#endif #include \"ansidecl.h\" #include \"system.h\" " @@ -12137,10 +12141,10 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_BASENAME $ac_have_decl _ACEOF + + as_ac_Symbol=`$as_echo "ac_cv_have_decl_strstr(const char*,const char*)" | $as_tr_sh` ac_fn_cxx_check_decl "$LINENO" "strstr(const char*,const char*)" "$as_ac_Symbol" " -#undef HAVE_DECL_BASENAME -#define HAVE_DECL_BASENAME 1 #include \"ansidecl.h\" #include \"system.h\" " @@ -21480,7 +21484,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21483 "configure" +#line 21487 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21586,7 +21590,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21589 "configure" +#line 21593 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 8ef11e36210b..3243472680c3 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1366,7 +1366,7 @@ AC_HEADER_TIOCGWINSZ AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h sys/mman.h \ sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \ -direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h) +direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libgen.h) # Check for thread headers. AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=]) @@ -1645,9 +1645,17 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" # normal autoconf function for these. But force definition of # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre # basename handling in libiberty.h. -AC_CHECK_DECLS([basename(const char*), strstr(co
[gcc r15-8910] toplevel, libcobol: Add dependency on libquadmath build [PR119244].
https://gcc.gnu.org/g:0fb10aca02852b2e8d78a78c07aa2f62aec6a07e commit r15-8910-g0fb10aca02852b2e8d78a78c07aa2f62aec6a07e Author: Iain Sandoe Date: Tue Mar 25 16:20:58 2025 + toplevel, libcobol: Add dependency on libquadmath build [PR119244]. For the configuration of libgcobol to be correct for targets that need to use libquadmath for 128b FP support, we must be able to find the quadmath library (or not, for targets that have the support in libc). PR cobol/119244 ChangeLog: * Makefile.def: libgcobol configure depends on libquadmath build. * Makefile.in: Regenerate. Signed-off-by: Iain Sandoe Diff: --- Makefile.def | 2 ++ Makefile.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Makefile.def b/Makefile.def index d2a1cd55b6e6..3f980bce8c05 100644 --- a/Makefile.def +++ b/Makefile.def @@ -693,6 +693,7 @@ dependencies = { module=install-target-libitm; on=install-target-libgcc; }; dependencies = { module=install-target-libobjc; on=install-target-libgcc; }; dependencies = { module=install-target-libstdc++-v3; on=install-target-libgcc; }; dependencies = { module=install-target-libgcobol; on=install-target-libstdc++-v3; }; +dependencies = { module=install-target-libgcobol; on=install-target-libquadmath; }; // Target modules in the 'src' repository. lang_env_dependencies = { module=libtermcap; }; @@ -706,6 +707,7 @@ dependencies = { module=configure-target-newlib; on=all-ld; }; dependencies = { module=configure-target-libgfortran; on=all-target-libquadmath; }; dependencies = { module=configure-target-libgfortran; on=all-target-libbacktrace; }; dependencies = { module=configure-target-libgo; on=all-target-libbacktrace; }; +dependencies = { module=configure-target-libgcobol; on=all-target-libquadmath; }; languages = { language=c; gcc-check-target=check-gcc; }; languages = { language=c++;gcc-check-target=check-c++; diff --git a/Makefile.in b/Makefile.in index a5e6e11aece0..b1ed67d3d4f1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -69170,9 +69170,11 @@ install-target-libitm: maybe-install-target-libgcc install-target-libobjc: maybe-install-target-libgcc install-target-libstdc++-v3: maybe-install-target-libgcc install-target-libgcobol: maybe-install-target-libstdc++-v3 +install-target-libgcobol: maybe-install-target-libquadmath all-target-libgloss: maybe-all-target-newlib all-target-winsup: maybe-all-target-libtermcap configure-target-libgfortran: maybe-all-target-libquadmath +configure-target-libgcobol: maybe-all-target-libquadmath @if gcc-bootstrap
[gcc r15-8911] c++: Properly fold .* [PR114525]
https://gcc.gnu.org/g:35ce9afc84a63fb647a90cbecb2adf3e748178be commit r15-8911-g35ce9afc84a63fb647a90cbecb2adf3e748178be Author: Simon Martin Date: Tue Mar 25 20:11:19 2025 +0100 c++: Properly fold .* [PR114525] We've been miscompiling the following since r0-51314-gd6b4ea8592e338 (I did not go compile something that old, and identified this change via git blame, so might be wrong) === cut here === struct Foo { int x; }; Foo& get (Foo &v) { return v; } void bar () { Foo v; v.x = 1; (true ? get (v) : get (v)).*(&Foo::x) = 2; // v.x still equals 1 here... } === cut here === The problem lies in build_m_component_ref, that computes the address of the COND_EXPR using build_address to build the representation of (true ? get (v) : get (v)).*(&Foo::x); and gets something like &(true ? get (v) : get (v)) // #1 instead of (true ? &get (v) : &get (v)) // #2 and the write does not go where want it to, hence the miscompile. This patch replaces the call to build_address by a call to cp_build_addr_expr, which gives #2, that is properly handled. PR c++/114525 gcc/cp/ChangeLog: * typeck2.cc (build_m_component_ref): Call cp_build_addr_expr instead of build_address. gcc/testsuite/ChangeLog: * g++.dg/expr/cond18.C: New test. Diff: --- gcc/cp/typeck2.cc | 2 +- gcc/testsuite/g++.dg/expr/cond18.C | 36 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index 1adc05aa86dc..45edd1801739 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -2387,7 +2387,7 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) (cp_type_quals (type) | cp_type_quals (TREE_TYPE (datum; - datum = build_address (datum); + datum = cp_build_addr_expr (datum, complain); /* Convert object to the correct base. */ if (binfo) diff --git a/gcc/testsuite/g++.dg/expr/cond18.C b/gcc/testsuite/g++.dg/expr/cond18.C new file mode 100644 index ..326985eed506 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cond18.C @@ -0,0 +1,36 @@ +/* PR c++/114525 */ +/* { dg-do run } */ + +struct Foo { + int x; +}; + +Foo& get (Foo& v) { + return v; +} + +int main () { + bool cond = true; + + /* Testcase from PR; v.x would wrongly remain equal to 1. */ + Foo v_ko; + v_ko.x = 1; + (cond ? get (v_ko) : get (v_ko)).*(&Foo::x) = 2; + if (v_ko.x != 2) +__builtin_abort (); + + /* Those would already work, i.e. x be changed to 2. */ + Foo v_ok_1; + v_ok_1.x = 1; + (cond ? get (v_ok_1) : get (v_ok_1)).x = 2; + if (v_ok_1.x != 2) +__builtin_abort (); + + Foo v_ok_2; + v_ok_2.x = 1; + get (v_ok_2).*(&Foo::x) = 2; + if (v_ok_2.x != 2) +__builtin_abort (); + + return 0; +}
[gcc r15-8912] c++: add fixed test [PR101881]
https://gcc.gnu.org/g:7c63237ccfd9cb76c513f567429e939709c193e4 commit r15-8912-g7c63237ccfd9cb76c513f567429e939709c193e4 Author: Marek Polacek Date: Tue Mar 25 15:40:25 2025 -0400 c++: add fixed test [PR101881] Fixed recently by r15-7822. PR c++/101881 gcc/testsuite/ChangeLog: * g++.dg/ext/vector44.C: New test. Diff: --- gcc/testsuite/g++.dg/ext/vector44.C | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/testsuite/g++.dg/ext/vector44.C b/gcc/testsuite/g++.dg/ext/vector44.C new file mode 100644 index ..cb24ef6e2645 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector44.C @@ -0,0 +1,5 @@ +// PR c++/101881 +// { dg-do compile { target c++11 } } + +template using A = int __attribute__((vector_size(N)))*; +void foo(A<4>) {}
[gcc r15-8504] rust: Desugar IfLet* into MatchExpr
https://gcc.gnu.org/g:aa0e2abc57f4f43198e2b072a84c34c476aa2fad commit r15-8504-gaa0e2abc57f4f43198e2b072a84c34c476aa2fad Author: Marc Poulhiès Date: Wed Jun 12 21:58:26 2024 +0200 rust: Desugar IfLet* into MatchExpr Replace the "regular" AST->HIR lowering for IfLet* with a desugaring into a MatchExpr. Desugar a simple if let: if let Some(y) = some_value { bar(); } into: match some_value { Some(y) => {bar();}, _ => () } Same applies for IfLetExprConseqElse (if let with an else block). Desugar: if let Some(y) = some_value { bar(); } else { baz(); } into: match some_value { Some(y) => {bar();}, _ => {baz();} } Fixes https://github.com/Rust-GCC/gccrs/issues/1177 gcc/rust/ChangeLog: * backend/rust-compile-block.h: Adjust after removal of HIR::IfLetExpr and HIR::IfLetExprConseqElse. * backend/rust-compile-expr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-block.h (ASTLoweringIfLetBlock::translate): Change return type. * hir/rust-ast-lower.cc (ASTLoweringIfLetBlock::desugar_iflet): New. (ASTLoweringIfLetBlock::visit(AST::IfLetExpr &)): Adjust and use desugar_iflet. * hir/rust-ast-lower.h: Add comment. * hir/rust-hir-dump.cc (Dump::do_ifletexpr): Remove. (Dump::visit(IfLetExpr&)): Remove. (Dump::visit(IfLetExprConseqElse&)): Remove. * hir/rust-hir-dump.h (Dump::do_ifletexpr): Remove. (Dump::visit(IfLetExpr&)): Remove. (Dump::visit(IfLetExprConseqElse&)): Remove. * hir/tree/rust-hir-expr.h (class IfLetExpr): Remove. (class IfLetExprConseqElse): Remove. * hir/tree/rust-hir-full-decls.h (class IfLetExpr): Remove. (class IfLetExprConseqElse): Remove. * hir/tree/rust-hir-visitor.h: Adjust after removal of HIR::IfLetExpr and HIR::IfLetExprConseqElse. * hir/tree/rust-hir.cc (IfLetExpr::as_string): Remove. (IfLetExprConseqElse::as_string): Remove. (IfLetExpr::accept_vis): Remove. (IfLetExprConseqElse::accept_vis): Remove. * hir/tree/rust-hir.h: Adjust after removal of HIR::IfLetExpr and HIR::IfLetExprConseqElse. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit (IfLetExpr &)): Remove. (PatternChecker::visit (IfLetExprConseqElse &)): Remove. * checks/errors/rust-hir-pattern-analysis.h (visit(IfLetExpr &)): Remove. (visit(IfLetExprConseqElse &)): Remove. gcc/testsuite/ChangeLog: * rust/compile/if_let_expr.rs: Adjust. * rust/compile/if_let_expr_simple.rs: New test. * rust/compile/iflet.rs: New test. * rust/execute/torture/iflet.rs: New test. * rust/compile/nr2/exclude: Add iflet.rs and if_let_expr_simple.rs Signed-off-by: Marc Poulhiès Diff: --- gcc/rust/backend/rust-compile-block.h | 4 - gcc/rust/backend/rust-compile-expr.h | 2 - .../errors/borrowck/rust-bir-builder-expr-stmt.cc | 12 -- .../errors/borrowck/rust-bir-builder-expr-stmt.h | 2 - .../borrowck/rust-bir-builder-lazyboolexpr.h | 8 - .../errors/borrowck/rust-bir-builder-struct.h | 2 - .../errors/borrowck/rust-function-collector.h | 2 - .../checks/errors/privacy/rust-privacy-reporter.cc | 15 -- .../checks/errors/privacy/rust-privacy-reporter.h | 2 - gcc/rust/checks/errors/rust-const-checker.cc | 16 -- gcc/rust/checks/errors/rust-const-checker.h| 2 - .../checks/errors/rust-hir-pattern-analysis.cc | 1
[gcc r15-8915] i386: Add "s_" as Saturation for AVX10.2 Converting Intrinsics.
https://gcc.gnu.org/g:330df57938fe609a49c5cb047be443475cb9a3c3 commit r15-8915-g330df57938fe609a49c5cb047be443475cb9a3c3 Author: Hu, Lin1 Date: Fri Mar 21 10:43:10 2025 +0800 i386: Add "s_" as Saturation for AVX10.2 Converting Intrinsics. This patch aims to add "s_" after 'cvt' represent saturation. gcc/ChangeLog: * config/i386/avx10_2-512convertintrin.h (_mm512_mask_cvtx2ps_ph): Formatting fixes (_mm512_mask_cvtx_round2ps_ph): Ditto (_mm512_maskz_cvtx_round2ps_ph): Ditto (_mm512_cvtbiassph_bf8): Rename to _mm512_cvts_biasph_bf8. (_mm512_mask_cvtbiassph_bf8): Rename to _mm512_mask_cvts_biasph_bf8. (_mm512_maskz_cvtbiassph_bf8): Rename to _mm512_maskz_cvts_biasph_bf8. (_mm512_cvtbiassph_hf8): Rename to _mm512_cvts_biasph_hf8. (_mm512_mask_cvtbiassph_hf8): Rename to _mm512_mask_cvts_biasph_hf8. (_mm512_maskz_cvtbiassph_hf8): Rename to _mm512_maskz_cvts_biasph_hf8. (_mm512_cvts2ph_bf8): Rename to _mm512_cvts_2ph_bf8. (_mm512_mask_cvts2ph_bf8): Rename to _mm512_mask_cvts_2ph_bf8. (_mm512_maskz_cvts2ph_bf8): Rename to _mm512_maskz_cvts_2ph_bf8. (_mm512_cvts2ph_hf8): Rename to _mm512_cvts_2ph_hf8. (_mm512_mask_cvts2ph_hf8): Rename to _mm512_mask_cvts_2ph_hf8. (_mm512_maskz_cvts2ph_hf8): Rename to _mm512_maskz_cvts_2ph_hf8. (_mm512_cvtsph_bf8): Rename to _mm512_cvts_ph_bf8. (_mm512_mask_cvtsph_bf8): Rename to _mm512_mask_cvts_ph_bf8. (_mm512_maskz_cvtsph_bf8): Rename to _mm512_maskz_cvts_ph_bf8. (_mm512_cvtsph_hf8): Rename to _mm512_cvts_ph_hf8. (_mm512_mask_cvtsph_hf8): Rename to _mm512_mask_cvts_ph_hf8. (_mm512_maskz_cvtsph_hf8): Rename to _mm512_maskz_cvts_ph_hf8. * config/i386/avx10_2convertintrin.h (_mm_cvtbiassph_bf8): Rename to _mm_cvts_biasph_bf8. (_mm_mask_cvtbiassph_bf8): Rename to _mm_mask_cvts_biasph_bf8. (_mm_maskz_cvtbiassph_bf8): Rename to _mm_maskz_cvts_biasph_bf8. (_mm256_cvtbiassph_bf8): Rename to _mm256_cvts_biasph_bf8. (_mm256_mask_cvtbiassph_bf8): Rename to _mm256_mask_cvts_biasph_bf8. (_mm256_maskz_cvtbiassph_bf8): Rename to _mm256_maskz_cvts_biasph_bf8. (_mm_cvtbiassph_hf8): Rename to _mm_cvts_biasph_hf8. (_mm_mask_cvtbiassph_hf8): Rename to _mm_mask_cvts_biasph_hf8. (_mm_maskz_cvtbiassph_hf8): Rename to _mm_maskz_cvts_biasph_hf8. (_mm256_cvtbiassph_hf8): Rename to _mm256_cvts_biasph_hf8. (_mm256_mask_cvtbiassph_hf8): Rename to _mm256_mask_cvts_biasph_hf8. (_mm256_maskz_cvtbiassph_hf8): Rename to _mm256_maskz_cvts_biasph_hf8. (_mm_cvts2ph_bf8): Rename to _mm_cvts_2ph_bf8. (_mm_mask_cvts2ph_bf8): Rename to _mm_mask_cvts_2ph_bf8. (_mm_maskz_cvts2ph_bf8): Rename to _mm_maskz_cvts_2ph_bf8. (_mm256_cvts2ph_bf8): Rename to _mm256_cvts_2ph_bf8. (_mm256_mask_cvts2ph_bf8): Rename to _mm256_mask_cvts_2ph_bf8. (_mm256_maskz_cvts2ph_bf8): Rename to _mm256_maskz_cvts_2ph_bf8. (_mm_cvts2ph_hf8): Rename to _mm_cvts_2ph_hf8. (_mm_mask_cvts2ph_hf8): Rename to _mm_mask_cvts_2ph_hf8. (_mm_maskz_cvts2ph_hf8): Rename to _mm_maskz_cvts_2ph_hf8. (_mm256_cvts2ph_hf8): Rename to _mm256_cvts_2ph_hf8. (_mm256_mask_cvts2ph_hf8): Rename to _mm256_mask_cvts_2ph_hf8. (_mm256_maskz_cvts2ph_hf8): Rename to _mm256_maskz_cvts_2ph_hf8. (_mm_cvtsph_bf8): Rename to _mm_cvts_ph_bf8. (_mm_mask_cvtsph_bf8): Rename to _mm_mask_cvts_ph_bf8. (_mm_maskz_cvtsph_bf8): Rename to _mm_maskz_cvts_ph_bf8. (_mm256_cvtsph_bf8): Rename to _mm256_cvts_ph_bf8. (_mm256_mask_cvtsph_bf8): Rename to _mm256_mask_cvts_ph_bf8. (_mm256_maskz_cvtsph_bf8): Rename to _mm256_maskz_cvts_ph_bf8. (_mm_cvtsph_hf8): Rename to _mm_cvts_ph_hf8. (_mm_mask_cvtsph_hf8): Rename to _mm_mask_cvts_ph_hf8. (_mm_maskz_cvtsph_hf8): Rename to _mm_maskz_cvts_ph_hf8. (_mm256_cvtsph_hf8): Rename to _mm256_cvts_ph_hf8. (_mm256_mask_cvtsph_hf8): Rename to _mm256_mask_cvts_ph_hf8. (_mm256_maskz_cvtsph_hf8): Rename to _mm256_maskz_cvts_ph_hf8. gcc/testsuite/ChangeLog: * gcc.target/i386/avx10_2-512-convert-1.c: Modify function name to follow the latest version. * gcc.target/i386/avx10_2-512-vcvt2ph2bf8s-2.c: Ditto. * gcc.target/i386/avx10_2-512-vcvt2ph2hf8s-2.c: Ditto. * gcc.target/i386/avx10_2-512-vcvtbiasph2bf8s-2.c: Ditto. * gcc.target/i386/avx10_2-512-vcvtbiasph2hf8s-2.c: Ditto. * gcc.target/i386/avx10_2-512-vcvtph2bf8s-2.c: Ditto. * gcc.target/i386/avx
[gcc r13-9451] Fortran: fix bogus bounds check for reallocation on assignment [PR116706]
https://gcc.gnu.org/g:f017297cc338b3db6827408574e7943d5a09b3de commit r13-9451-gf017297cc338b3db6827408574e7943d5a09b3de Author: Harald Anlauf Date: Wed Mar 19 22:56:03 2025 +0100 Fortran: fix bogus bounds check for reallocation on assignment [PR116706] PR fortran/116706 gcc/fortran/ChangeLog: * trans-array.cc (gfc_is_reallocatable_lhs): Fix check on allocatable components of derived type or class objects. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_27.f90: New test. (cherry picked from commit 3292ca9b0818c3e55102413c2407711d0755d280) Diff: --- gcc/fortran/trans-array.cc| 4 +-- gcc/testsuite/gfortran.dg/bounds_check_27.f90 | 45 +++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 6e159e0557cb..e6301b586613 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -10559,9 +10559,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) return true; /* All that can be left are allocatable components. */ - if ((sym->ts.type != BT_DERIVED - && sym->ts.type != BT_CLASS) - || !sym->ts.u.derived->attr.alloc_comp) + if (sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS) return false; /* Find a component ref followed by an array reference. */ diff --git a/gcc/testsuite/gfortran.dg/bounds_check_27.f90 b/gcc/testsuite/gfortran.dg/bounds_check_27.f90 new file mode 100644 index ..678aef63af6e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_27.f90 @@ -0,0 +1,45 @@ +! { dg-do run } +! { dg-additional-options "-fcheck=bounds" } +! +! PR fortran/116706 - bogus bounds check for reallocation on assignment +! Contributed by Balint Aradi + +program testprog + implicit none + + type :: data_node + integer, allocatable :: data(:) + end type data_node + + type :: data_list + type(data_node), pointer :: nodes(:) => null() + end type data_list + + type :: upoly_node + class(*), allocatable :: data(:) + end type upoly_node + + type :: star_list + type(upoly_node), pointer :: nodes(:) => null() + end type star_list + + type(data_list) :: datalist + type(star_list) :: starlist + class(star_list), allocatable :: astarlist + class(star_list), pointer :: pstarlist + + allocate (datalist%nodes(2)) + datalist%nodes(1)%data = [1, 2, 3] + + allocate (starlist%nodes(2)) + starlist%nodes(1)%data = [1., 2., 3.] + + allocate (astarlist) + allocate (astarlist%nodes(2)) + astarlist%nodes(1)%data = [1, 2, 3] + + allocate (pstarlist) + allocate (pstarlist%nodes(2)) + pstarlist%nodes(1)%data = [1., 2., 3.] + +end program testprog
[gcc r15-8913] cobol: Changes to eliminate _Float128 from the front end [PR119241]
https://gcc.gnu.org/g:e9adfb839f0d6aa05fd35d332b015623a33c3ce8 commit r15-8913-ge9adfb839f0d6aa05fd35d332b015623a33c3ce8 Author: Bob Dubner Date: Tue Mar 25 15:38:38 2025 -0400 cobol: Changes to eliminate _Float128 from the front end [PR119241] These changes switch _Float128 types to REAL_VALUE_TYPE in the front end. Some __int128 variables and function return values are changed to FIXED_WIDE_INT(128) gcc/cobol PR cobol/119241 * cdf.y: (cdfval_base_t::operator()): Return const. * cdfval.h: (struct cdfval_base_t): Add const cdfval_base_t& operator(). (struct cdfval_t): Add cdfval_t constructor. Change cdf_value definitions. * gcobolspec.cc (lang_specific_driver): Formatting fix. * genapi.cc: Include fold-const.h and realmpfr.h. (initialize_variable_internal): Use real_to_decimal instead of strfromf128. (get_binary_value_from_float): Use wide_int_to_tree instead of build_int_cst_type. (psa_FldLiteralN): Use fold_convert instead of strfromf128, real_from_string and build_real. (parser_display_internal): Rewritten to work on REAL_VALUE_TYPE rather than _Float128. (mh_source_is_literalN): Use FIXED_WIDE_INT(128) rather than __int128, wide_int_to_tree rather than build_int_cst_type, fold_convert rather than build_string_literal. (real_powi10): New function. (binary_initial_from_float128): Change type of last argument from _Float128 to REAL_VALUE_TYPE, process it using real.cc and mpfr APIs. (digits_from_float128): Likewise. (initial_from_float128): Make static. Remove value argument, add local REAL_VALUE_TYPE value variable instead, process it using real.cc and native_encode_expr APIs. (parser_symbol_add): Adjust initial_from_float128 caller. * genapi.h (initial_from_float128): Remove declaration. * genutil.cc (get_power_of_ten): Change return type from __int128 to FIXED_WIDE_INT(128), ditto for retval type, change type of pos from __int128 to unsigned long long. (scale_by_power_of_ten_N): Use wide_int_to_tree instead of build_int_cst_type. Use FIXED_WIDE_INT(128) instead of __int128 as power_of_ten variable type. (copy_little_endian_into_place): Likewise. * genutil.h (get_power_of_ten): Change return type from __int128 to FIXED_WIDE_INT(128). * parse.y (%union): Change type of float128 from _Float128 to REAL_VALUE_TYPE. (string_of): Change argument type from _Float128 to const REAL_VALUE_TYPE &, use real_to_decimal rather than strfromf128. Add another overload with tree argument type. (field: cdf): Use real_zerop rather than comparison against 0.0. (occurs_clause, const_value): Use real_to_integer. (value78): Use build_real and real_to_integer. (data_descr1): Use real_to_integer. (count): Use real_to_integer, real_from_integer and real_identical instead of direct comparison. (value_clause): Use real_from_string3 instead of num_str2i. Use real_identical instead of direct comparison. Use build_real. (allocate): Use real_isneg and real_iszero instead of <= 0 comparison. (move_tgt): Use real_to_integer, real_value_truncate, real_from_integer and real_identical instead of comparison of casts. (cce_expr): Use real_arithmetic and real_convert or real_value_negate instead of direct arithmetics on _Float128. (cce_factor): Use real_from_string3 instead of numstr2i. (literal_refmod_valid): Use real_to_integer. * symbols.cc (symbol_table_t::registers_t::registers_t): Formatting fix. (ERROR_FIELD): Likewise. (extend_66_capacity): Likewise. (cbl_occurs_t::subscript_ok): Use real_to_integer, real_from_integer and real_identical. * symbols.h (cbl_field_data_t::etc_t::value): Change type from _Float128 to tree. (cbl_field_data_t::etc_t::etc_t): Adjust defaulted argument value. (cbl_field_data_t::cbl_field_data_t): Formatting fix. Use etc() rather than etc(0). (cbl_field_data_t::value_of): Change return type from _Float128 to tree. (cbl_field_data_t::operator=): Change return and argument type from _Float128 to tree. (cbl_field_data_t::valify): Use real_from_string, real_value_truncate and build_real. (cbl_field_t::same_as): Use build_zero_cst instead of _Float128(0.0). gcc/t
[gcc r15-8909] gcc, gcov: Use 'lbasename' consistently.
https://gcc.gnu.org/g:dce62cda93a4b2965bca15b8c48b2202aeed27a6 commit r15-8909-gdce62cda93a4b2965bca15b8c48b2202aeed27a6 Author: Iain Sandoe Date: Thu Mar 13 17:28:55 2025 + gcc, gcov: Use 'lbasename' consistently. The 'basename' implementation can vary with the host platform (e.g. POSIX c.f. Linux). This is the only current uses of basename() in the source so convert them to use lbasename() as most other cases do. gcc/ChangeLog: * gcov.cc (get_gcov_intermediate_filename): Use lbasename(). Signed-off-by: Iain Sandoe Diff: --- gcc/gcov.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/gcov.cc b/gcc/gcov.cc index 3e6f2e4212ac..96fdc50f0e8f 100644 --- a/gcc/gcov.cc +++ b/gcc/gcov.cc @@ -1366,7 +1366,7 @@ get_md5sum (const char *input) static string get_gcov_intermediate_filename (const char *input_file_name) { - string base = basename (input_file_name); + string base = lbasename (input_file_name); string str = strip_extention (base); if (flag_hash_filenames)
[gcc r15-8907] libiberty: Append to AC_CHECK_DECLS [PR119218].
https://gcc.gnu.org/g:f3d07779fdb729c7ee81b8e764921becf8ecf1d0 commit r15-8907-gf3d07779fdb729c7ee81b8e764921becf8ecf1d0 Author: Iain Sandoe Date: Wed Mar 12 15:04:31 2025 + libiberty: Append to AC_CHECK_DECLS [PR119218]. Darwin and Solaris, at least, provide basename() in libc, but only declare it in . That library is not one of the set in AC_INCLUDES_DEFAULT and so we fail the config test and fall back to the libiberty-provided version. In itself, this is not an issue; however, if we include and libiberty.h in the same TU we do then get a decl conflict. PR other/119218 libiberty/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Append to AC_INCLUDES_DEFAULT when checking for the 'basename' decl. Signed-off-by: Iain Sandoe Diff: --- libiberty/config.in| 3 +++ libiberty/configure| 12 +--- libiberty/configure.ac | 9 +++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libiberty/config.in b/libiberty/config.in index 1b1f2b09a8ab..b055150961c5 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -153,6 +153,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGEN_H + /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H diff --git a/libiberty/configure b/libiberty/configure index 38856a07e5f0..347719c62623 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -5745,7 +5745,7 @@ host_makefile_frag=${frag} # It's OK to check for header files. Although the compiler may not be # able to link anything, it had better be able to at least compile # something. -for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h +for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header" @@ -7389,7 +7389,12 @@ fi done as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(char *)" | $as_tr_sh` -ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" "$ac_includes_default" +ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" " +$ac_includes_default +#ifdef HAVE_LIBGEN_H +# include +#endif +" if eval test \"x\$"$as_ac_Symbol"\" = x"yes"; then : ac_have_decl=1 else @@ -7399,7 +7404,8 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_BASENAME $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default" + + ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default" if test "x$ac_cv_have_decl_ffs" = xyes; then : ac_have_decl=1 else diff --git a/libiberty/configure.ac b/libiberty/configure.ac index c27e08e14288..5bad0f936920 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -291,7 +291,7 @@ AC_SUBST_FILE(host_makefile_frag) # It's OK to check for header files. Although the compiler may not be # able to link anything, it had better be able to at least compile # something. -AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h) +AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h) AC_HEADER_SYS_WAIT AC_HEADER_TIME @@ -723,7 +723,12 @@ if test -z "${setobjs}"; then [AC_MSG_RESULT([no])]) AC_CHECK_FUNCS($checkfuncs) - AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf]) + AC_CHECK_DECLS([basename(char *)], [], [], [ +AC_INCLUDES_DEFAULT +#ifdef HAVE_LIBGEN_H +# include +#endif]) + AC_CHECK_DECLS([ffs, asprintf, vasprintf, snprintf, vsnprintf]) AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc]) case "${host}" in *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
[gcc r14-11448] Fortran: fix bogus bounds check for reallocation on assignment [PR116706]
https://gcc.gnu.org/g:de9500d93eed789bf7bc4a82b522edb6dd2b6202 commit r14-11448-gde9500d93eed789bf7bc4a82b522edb6dd2b6202 Author: Harald Anlauf Date: Wed Mar 19 22:56:03 2025 +0100 Fortran: fix bogus bounds check for reallocation on assignment [PR116706] PR fortran/116706 gcc/fortran/ChangeLog: * trans-array.cc (gfc_is_reallocatable_lhs): Fix check on allocatable components of derived type or class objects. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_27.f90: New test. (cherry picked from commit 3292ca9b0818c3e55102413c2407711d0755d280) Diff: --- gcc/fortran/trans-array.cc| 4 +-- gcc/testsuite/gfortran.dg/bounds_check_27.f90 | 45 +++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 61f641aa4918..c1c2b933b279 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -10850,9 +10850,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) return true; /* All that can be left are allocatable components. */ - if ((sym->ts.type != BT_DERIVED - && sym->ts.type != BT_CLASS) - || !sym->ts.u.derived->attr.alloc_comp) + if (sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS) return false; /* Find a component ref followed by an array reference. */ diff --git a/gcc/testsuite/gfortran.dg/bounds_check_27.f90 b/gcc/testsuite/gfortran.dg/bounds_check_27.f90 new file mode 100644 index ..678aef63af6e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_27.f90 @@ -0,0 +1,45 @@ +! { dg-do run } +! { dg-additional-options "-fcheck=bounds" } +! +! PR fortran/116706 - bogus bounds check for reallocation on assignment +! Contributed by Balint Aradi + +program testprog + implicit none + + type :: data_node + integer, allocatable :: data(:) + end type data_node + + type :: data_list + type(data_node), pointer :: nodes(:) => null() + end type data_list + + type :: upoly_node + class(*), allocatable :: data(:) + end type upoly_node + + type :: star_list + type(upoly_node), pointer :: nodes(:) => null() + end type star_list + + type(data_list) :: datalist + type(star_list) :: starlist + class(star_list), allocatable :: astarlist + class(star_list), pointer :: pstarlist + + allocate (datalist%nodes(2)) + datalist%nodes(1)%data = [1, 2, 3] + + allocate (starlist%nodes(2)) + starlist%nodes(1)%data = [1., 2., 3.] + + allocate (astarlist) + allocate (astarlist%nodes(2)) + astarlist%nodes(1)%data = [1, 2, 3] + + allocate (pstarlist) + allocate (pstarlist%nodes(2)) + pstarlist%nodes(1)%data = [1., 2., 3.] + +end program testprog
[gcc r15-8888] testsuite: aarch64: arm: Remove redundant dg-do run in advsimd-intrinsics tests
https://gcc.gnu.org/g:3fcdf55469f8787c04e4f0b5e93139247d8fe7ee commit r15--g3fcdf55469f8787c04e4f0b5e93139247d8fe7ee Author: Christophe Lyon Date: Fri Mar 14 13:12:08 2025 + testsuite: aarch64: arm: Remove redundant dg-do run in advsimd-intrinsics tests Tests under advsimd-intrinsics are controlled by advsimd-intrinsics.exp which computes the adequate dg-do-what depending on the actual target, it should not be redefined in the tests, except when the action can never be 'run'. This currently makes no difference, but it would when we remove dg-skip-if for arm targets from tests that could at least be compiled (e.g. vst1x2.c) gcc/testsuite/ * gcc.target/aarch64/advsimd-intrinsics/vabdh_f16_1.c: Remove dg-do directive. * gcc.target/aarch64/advsimd-intrinsics/vabsh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vaddh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcageh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcagth_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcaleh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcalth_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vceqh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vceqzh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcgeh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcgezh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcgth_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcgtzh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcleh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vclezh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vclth_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcltzh_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_s16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_s32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_s64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_u16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_u32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtah_u64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_s16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_s32_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_s64_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_u16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_u32_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_f16_u64_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_s16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_s32_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_s64_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_u16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_u32_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_f16_u64_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_s16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_s32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_s64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_u16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_u32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_n_u64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_s16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_s32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_s64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_u16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_u32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvth_u64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtmh_s16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtmh_s32_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtmh_s64_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtmh_u16_f16_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vcvtmh_u32_f16_1.c: Likewise. * gcc.target/aarch64/advsi
[gcc r15-8885] testsuite: aarch64: arm: move saturating_arithmetic_autovect tests to simd/
https://gcc.gnu.org/g:e8ada4131657f7dc61f53fe49daaf96a1d1c6774 commit r15-8885-ge8ada4131657f7dc61f53fe49daaf96a1d1c6774 Author: Christophe Lyon Date: Tue Mar 18 14:56:41 2025 + testsuite: aarch64: arm: move saturating_arithmetic_autovect tests to simd/ These tests force dg-options because they rely on -ftree-vectorize and do not make use of torture options, so move them to simd/ where they belong. gcc/testsuite/ * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect.inc: Move to gcc.target/aarch64/simd/. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_2.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_3.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_4.c: Likewise. Diff: --- .../{advsimd-intrinsics => simd}/saturating_arithmetic_autovect.inc | 0 .../{advsimd-intrinsics => simd}/saturating_arithmetic_autovect_1.c | 0 .../{advsimd-intrinsics => simd}/saturating_arithmetic_autovect_2.c | 0 .../{advsimd-intrinsics => simd}/saturating_arithmetic_autovect_3.c | 0 .../{advsimd-intrinsics => simd}/saturating_arithmetic_autovect_4.c | 0 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect.inc b/gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect.inc similarity index 100% rename from gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect.inc rename to gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect.inc diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_1.c b/gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_1.c similarity index 100% rename from gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_1.c rename to gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_1.c diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_2.c b/gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_2.c similarity index 100% rename from gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_2.c rename to gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_2.c diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_3.c b/gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_3.c similarity index 100% rename from gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_3.c rename to gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_3.c diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_4.c b/gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_4.c similarity index 100% rename from gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_4.c rename to gcc/testsuite/gcc.target/aarch64/simd/saturating_arithmetic_autovect_4.c
[gcc r15-8886] testsuite: aarch64: restore torture options in bf16_dup.c
https://gcc.gnu.org/g:52df53079310cad5b6aad68ae6594d375a844272 commit r15-8886-g52df53079310cad5b6aad68ae6594d375a844272 Author: Christophe Lyon Date: Mon Mar 17 23:37:25 2025 + testsuite: aarch64: restore torture options in bf16_dup.c Remove dg-options, so that the test is executed as expected using the options defined by advsimd-intrinsics.exp. (Previously we pretend we do, but in fact all torture options are silently overriden with -O2) We skip it at -O0, because the tested optimizations does not take place at this level. gcc/testsuite/ * gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c: Remove dg-options. Diff: --- gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c index c42c7acbbe92..da9370ba52bb 100644 --- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c +++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c @@ -1,6 +1,6 @@ /* { dg-do assemble { target { aarch64*-*-* } } } */ +/* { dg-skip-if "no optimizations" { *-*-* } { "-O0" } { "" } } */ /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */ -/* { dg-options "-O2" } */ /* { dg-add-options arm_v8_2a_bf16_neon } */ /* { dg-additional-options "-save-temps" } */
[gcc r15-8889] arm: testsuite use -std=gnu17 for pr65647.c
https://gcc.gnu.org/g:143ad00ccd63a6cf38d8067d5fa79bd9a81e3144 commit r15-8889-g143ad00ccd63a6cf38d8067d5fa79bd9a81e3144 Author: Richard Earnshaw Date: Tue Mar 25 13:18:06 2025 + arm: testsuite use -std=gnu17 for pr65647.c This test has missing prototypes. To avoid disturbing the test, use gnu17. gcc/testsuite/ChangeLog: * gcc.target/arm/pr65647.c (dg-options): Add -std=gnu17. Diff: --- gcc/testsuite/gcc.target/arm/pr65647.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c b/gcc/testsuite/gcc.target/arm/pr65647.c index e0c534bc813a..663157c9c66f 100644 --- a/gcc/testsuite/gcc.target/arm/pr65647.c +++ b/gcc/testsuite/gcc.target/arm/pr65647.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_arch_v6m_ok } */ -/* { dg-options "-O3 -w -fpermissive" } */ +/* { dg-options "-O3 -w -fpermissive -std=gnu17" } */ /* { dg-add-options arm_arch_v6m } */ a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x,
[gcc r15-8614] gccrs: nr2.0: Early resolve pending eager macro invocations
https://gcc.gnu.org/g:c9f85323b5173fef754ccc5698e36aef8cee17aa commit r15-8614-gc9f85323b5173fef754ccc5698e36aef8cee17aa Author: Owen Avery Date: Fri Jan 10 23:55:29 2025 -0500 gccrs: nr2.0: Early resolve pending eager macro invocations gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Resolve the pending eager invocations inside builtin macro invocations. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery Diff: --- gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 4 gcc/testsuite/rust/compile/nr2/exclude | 5 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index 55330487fd7a..342f1027273a 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -238,6 +238,10 @@ Early::visit (AST::MacroInvocation &invoc) { auto path = invoc.get_invoc_data ().get_path (); + if (invoc.get_kind () == AST::MacroInvocation::InvocKind::Builtin) +for (auto &pending_invoc : invoc.get_pending_eager_invocations ()) + pending_invoc->accept_vis (*this); + // When a macro is invoked by an unqualified identifier (not part of a // multi-part path), it is first looked up in textual scoping. If this does // not yield any results, then it is looked up in path-based scoping. If the diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 9b490c18bab4..0f482df2f005 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -1,11 +1,6 @@ bounds1.rs break-rust2.rs break-rust3.rs -macros/builtin/eager1.rs -macros/builtin/eager2.rs -macros/builtin/recurse2.rs -macros/builtin/include3.rs -macros/builtin/include4.rs canonical_paths1.rs cfg1.rs cfg3.rs
[gcc r15-8511] gccrs: Improve handling of struct expressions in nr2.0
https://gcc.gnu.org/g:cbab7a138956c7a83639b501194ca4031289e028 commit r15-8511-gcbab7a138956c7a83639b501194ca4031289e028 Author: Owen Avery Date: Sat Oct 26 22:19:21 2024 -0400 gccrs: Improve handling of struct expressions in nr2.0 gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Handle StructExprStruct and use ForeverStack::resolve_path instead of ForeverStack::get to resolve struct expression paths. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Handle StructExprStruct. Signed-off-by: Owen Avery Diff: --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 13 +++-- gcc/rust/resolve/rust-late-name-resolver-2.0.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index 812154eaf799..850f96aef896 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -272,10 +272,19 @@ Late::visit (AST::StructStruct &s) ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis); } +void +Late::visit (AST::StructExprStruct &s) +{ + auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ()); + + ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()), +Definition (resolved->get_node_id ())); +} + void Late::visit (AST::StructExprStructBase &s) { - auto resolved = ctx.types.get (s.get_struct_name ().as_string ()); + auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ()); ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()), Definition (resolved->get_node_id ())); @@ -285,7 +294,7 @@ Late::visit (AST::StructExprStructBase &s) void Late::visit (AST::StructExprStructFields &s) { - auto resolved = ctx.types.get (s.get_struct_name ().as_string ()); + auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ()); ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()), Definition (resolved->get_node_id ())); diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h b/gcc/rust/resolve/rust-late-name-resolver-2.0.h index 35fe400aeea3..79572fbc4fac 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h @@ -47,6 +47,7 @@ public: void visit (AST::IdentifierExpr &) override; void visit (AST::PathInExpression &) override; void visit (AST::TypePath &) override; + void visit (AST::StructExprStruct &) override; void visit (AST::StructExprStructBase &) override; void visit (AST::StructExprStructFields &) override; void visit (AST::StructStruct &) override;
[gcc r15-8917] rust: Use 'lbasename()' consistently.
https://gcc.gnu.org/g:e7871b36f17fa58385198c079edf42b5c8e630b6 commit r15-8917-ge7871b36f17fa58385198c079edf42b5c8e630b6 Author: Iain Sandoe Date: Mon Mar 24 08:33:53 2025 + rust: Use 'lbasename()' consistently. The amends the remaining case in the rust code to use the libiberty lbasename() instead of the (potentially variably-behaved) system 'basename()'. gcc/rust/ChangeLog: * metadata/rust-export-metadata.cc (PublicInterface::write_to_path): Use 'lbasename()' instead of 'basename()'. Signed-off-by: Iain Sandoe Diff: --- gcc/rust/metadata/rust-export-metadata.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/metadata/rust-export-metadata.cc b/gcc/rust/metadata/rust-export-metadata.cc index 79c5f30d7554..771bec6e6378 100644 --- a/gcc/rust/metadata/rust-export-metadata.cc +++ b/gcc/rust/metadata/rust-export-metadata.cc @@ -234,7 +234,7 @@ PublicInterface::write_to_path (const std::string &path) const { // validate path contains correct extension const std::string expected_file_name = expected_metadata_filename (); - const char *path_base_name = basename (path.c_str ()); + const char *path_base_name = lbasename (path.c_str ()); if (strcmp (path_base_name, expected_file_name.c_str ()) != 0) { rust_error_at (UNDEF_LOCATION,
[gcc r15-8904] libstdc++: Optimize std::vector construction from input iterators [PR108487]
https://gcc.gnu.org/g:e200f53a5556516ec831e6b7a34aaa0f10a4ab0a commit r15-8904-ge200f53a5556516ec831e6b7a34aaa0f10a4ab0a Author: Jonathan Wakely Date: Tue Mar 25 13:24:08 2025 + libstdc++: Optimize std::vector construction from input iterators [PR108487] LWG 3291 make std::ranges::iota_view's iterator have input_iterator_tag as its iterator_category, even though it satisfies the C++20 std::forward_iterator concept. This means that the traditional std::vector::vector(InputIterator, InputIterator) constructor treats iota_view iterators as input iterators, because it only understands the C++17 iterator requirements, not the C++20 iterator concepts. This results in a loop that calls emplace_back for each individual element of the iota_view, requiring the vector to reallocate repeatedly as the values are inserted. This makes it unnecessarily slow to construct a vector from an iota_view. This change adds a new _M_range_initialize_n function for initializing a vector from a range (which doesn't have to be common) and a size. This new function can be used by vector(InputIterator, InputIterator) and vector(from_range_t, R&&) when std::ranges::distance can be used to get the size. It can also be used by the _M_range_initialize overload that gets the size for a Cpp17ForwardIterator pair using std::distance, and by the vector(initializer_list) constructor. With this new function constructing a std::vector from iota_view does a single allocation of the correct size and so doesn't need to reallocate in a loop. Previously the _M_range_initialize overload for Cpp17ForwardIterator was using a local RAII _Guard_alloc object to own the storage, but that was redundant. The _Vector_base can own the storage right away, and its destructor will deallocate it if _M_range_initialize exits via an exception. libstdc++-v3/ChangeLog: PR libstdc++/108487 * include/bits/stl_vector.h (vector(initializer_list)): Call _M_range_initialize_n instead of _M_range_initialize. (vector(InputIterator, InputIterator)): Use _M_range_initialize_n for C++20 sized sentinels and forward iterators. (vector(from_range_t, R&&)): Use _M_range_initialize_n for sized ranges and forward ranges. (vector::_M_range_initialize(FwIt, FwIt, forward_iterator_tag)): Likewise. (vector::_M_range_initialize_n): New function. * testsuite/23_containers/vector/cons/108487.cc: New test. Reviewed-by: Tomasz Kamiński Diff: --- libstdc++-v3/include/bits/stl_vector.h | 48 ++ .../testsuite/23_containers/vector/cons/108487.cc | 24 +++ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 21f6cd04f490..458adc987dac 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -65,6 +65,9 @@ #if __cplusplus >= 202002L # include #endif +#if __glibcxx_concepts // C++ >= C++20 +# include // ranges::distance +#endif #if __glibcxx_ranges_to_container // C++ >= 23 # include // ranges::copy # include // ranges::subrange @@ -706,8 +709,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const allocator_type& __a = allocator_type()) : _Base(__a) { - _M_range_initialize(__l.begin(), __l.end(), - random_access_iterator_tag()); + _M_range_initialize_n(__l.begin(), __l.end(), __l.size()); } #endif @@ -735,6 +737,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const allocator_type& __a = allocator_type()) : _Base(__a) { +#if __glibcxx_concepts // C++ >= C++20 + if constexpr (sized_sentinel_for<_InputIterator, _InputIterator> + || forward_iterator<_InputIterator>) + { + const auto __n + = static_cast(ranges::distance(__first, __last)); + _M_range_initialize_n(__first, __last, __n); + return; + } + else +#endif _M_range_initialize(__first, __last, std::__iterator_category(__first)); } @@ -763,13 +776,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) { - const auto __n = size_type(ranges::distance(__rg)); - pointer __start = - this->_M_allocate(_S_check_init_len(__n, - _M_get_Tp_allocator())); - this->_M_impl._M_finish = this->_M_impl._M_start = __start; - this->_M_impl._M_end_of_storage = __start + __n; - _Base::_M_append_range(__rg); + const
[gcc r15-8916] testsuite: add testcase for recent alias fix
https://gcc.gnu.org/g:4cac3f83c2b31ab352f537368e4efdadd5c47a9a commit r15-8916-g4cac3f83c2b31ab352f537368e4efdadd5c47a9a Author: Sam James Date: Tue Mar 25 07:47:27 2025 + testsuite: add testcase for recent alias fix r15-7961-gdc47161c1f32c3 fixes a typo in ao_compare::compare_ao_refs but there wasn't a testcase available at the time. Now there is. Thanks to Andrew for the testcase. gcc/testsuite/ChangeLog: PR testsuite/119382 * gcc.dg/ipa/ipa-icf-40.c: New test. Co-authored-by: Andrew Pinski Diff: --- gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c | 16 1 file changed, 16 insertions(+) diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c new file mode 100644 index ..ab328ba33412 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf-optimized" } */ + +int c0 = 0; +typedef int v4si __attribute__((vector_size(4*sizeof(int; +v4si a; +int f() +{ +return a[c0]; +} +int g() +{ +return a[c0]; +} + +/* { dg-final { scan-ipa-dump "optimized: Semantic equality hit:f/\[0-9+\]+->g/\[0-9+\]+" "icf" } } */
[gcc r15-8900] c++: lambda, default argument, unevaluated context
https://gcc.gnu.org/g:525d4a10302113b3cce9b4e5420767f0a2f5624e commit r15-8900-g525d4a10302113b3cce9b4e5420767f0a2f5624e Author: yxj-github-437 <2457369...@qq.com> Date: Tue Mar 25 23:43:10 2025 +0800 c++: lambda, default argument, unevaluated context This patch would like to avoid the ICE when template lambdas call with default parameters in unevaluated context. The bug is the same as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119385. For example: 1 | template 2 | void foo(T x) { 3 | sizeof [](T=x) { return 0; }(); 4 | } 5 | 6 | void test { 7 | foo(0); 8 | } when compile with -fsyntax-only -std=c++20, it will have ICE similar to test.cc: In instantiation of 'void foo(T) [with T = int]': test.cc:7:6: required from here 6 | foo(0); | ~~~^~~ test.cc:3:38: internal compiler error: in tsubst_expr, at cp/pt.cc:21919 2 | sizeof [](T=x) { return 0; }(); | ^~ And if without the template code ``, the code will pass compile, it's wrong. When parsing lambda, the sizeof will affect the lambda internal unevaluated operand being handled. So consider save/restore cp_unevaluated_operand. gcc/cp/ChangeLog: * parser.cc (cp_parser_lambda_expression): Use cp_evaluated. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-uneval25.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/cp/parser.cc | 3 +++ gcc/testsuite/g++.dg/cpp2a/lambda-uneval25.C | 11 +++ 2 files changed, 14 insertions(+) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 57a461042bf1..88e722d8406d 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -11773,6 +11773,9 @@ cp_parser_lambda_expression (cp_parser* parser) parser->auto_is_implicit_function_template_parm_p = false; parser->omp_array_section_p = false; +/* Inside the lambda, outside unevaluated context do not apply. */ +cp_evaluated ev; + /* The body of a lambda in a discarded statement is not discarded. */ bool discarded = in_discarded_stmt; in_discarded_stmt = 0; diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval25.C b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval25.C new file mode 100644 index ..7fdd44d3ddd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval25.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++20 } } + +template +void foo(T x) { + sizeof [](T=x) { return 0; }(); // { dg-error "may not appear" } + sizeof [](T=x) { return 0; }(); // { dg-error "may not appear" } +}; + +void test() { + foo(0); +}
[gcc r15-8899] arm: testsuite: skip mtp tests on thumb1
https://gcc.gnu.org/g:ca0a8421f7aa2191b2b867ff24888223d6cde433 commit r15-8899-gca0a8421f7aa2191b2b867ff24888223d6cde433 Author: Richard Earnshaw Date: Tue Mar 25 16:30:36 2025 + arm: testsuite: skip mtp tests on thumb1 These tests need access to the MRC instruction, but that isn't part of of the Thumb1 ISA. So skip the tests when this isn't the case. gcc/testsuite/ChangeLog: * gcc.target/arm/mtp_1.c: Require arm32. * gcc.target/arm/mtp_2.c: Likewise. * gcc.target/arm/mtp_3.c: Likewise. * gcc.target/arm/mtp_4.c: Likewise. Diff: --- gcc/testsuite/gcc.target/arm/mtp_1.c | 1 + gcc/testsuite/gcc.target/arm/mtp_2.c | 1 + gcc/testsuite/gcc.target/arm/mtp_3.c | 1 + gcc/testsuite/gcc.target/arm/mtp_4.c | 1 + 4 files changed, 4 insertions(+) diff --git a/gcc/testsuite/gcc.target/arm/mtp_1.c b/gcc/testsuite/gcc.target/arm/mtp_1.c index 678d27d92344..f78ceb8574e0 100644 --- a/gcc/testsuite/gcc.target/arm/mtp_1.c +++ b/gcc/testsuite/gcc.target/arm/mtp_1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target tls_native } */ +/* { dg-require-effective-target arm32 } */ /* { dg-options "-O -mtp=cp15" } */ #include "mtp.c" diff --git a/gcc/testsuite/gcc.target/arm/mtp_2.c b/gcc/testsuite/gcc.target/arm/mtp_2.c index bcb308f2637c..1368fe4a3a3f 100644 --- a/gcc/testsuite/gcc.target/arm/mtp_2.c +++ b/gcc/testsuite/gcc.target/arm/mtp_2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target tls_native } */ +/* { dg-require-effective-target arm32 } */ /* { dg-options "-O -mtp=tpidrprw" } */ #include "mtp.c" diff --git a/gcc/testsuite/gcc.target/arm/mtp_3.c b/gcc/testsuite/gcc.target/arm/mtp_3.c index 7d5cea3cab61..2ef2e95b62dd 100644 --- a/gcc/testsuite/gcc.target/arm/mtp_3.c +++ b/gcc/testsuite/gcc.target/arm/mtp_3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target tls_native } */ +/* { dg-require-effective-target arm32 } */ /* { dg-options "-O -mtp=tpidruro" } */ #include "mtp.c" diff --git a/gcc/testsuite/gcc.target/arm/mtp_4.c b/gcc/testsuite/gcc.target/arm/mtp_4.c index 068078df84ed..121fc836513c 100644 --- a/gcc/testsuite/gcc.target/arm/mtp_4.c +++ b/gcc/testsuite/gcc.target/arm/mtp_4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target tls_native } */ +/* { dg-require-effective-target arm32 } */ /* { dg-options "-O -mtp=tpidrurw" } */ #include "mtp.c"
[gcc r15-8897] arm: testsuite: adjust ftest tests
https://gcc.gnu.org/g:91051d60d95156e830423fd258dedfb574b42195 commit r15-8897-g91051d60d95156e830423fd258dedfb574b42195 Author: Richard Earnshaw Date: Tue Mar 25 15:36:02 2025 + arm: testsuite: adjust ftest tests The ftest-*.c tests for Arm check certain ACLE mandated macros to ensure they are correctly defined based on the selected architecture. ACLE states that the macro should be defined if the operation exists in the hardware, but it doesn't have to exist in the current ISA because and interworking call to the library function will still result in using the hardware operation (both GCC and Clang agree on this). So adjust the tests accordingly. Whilst cleaning this up, also remove the now redundant dg-skip-if operations that were testing for incompatible command-line options. That should now be a thing of the past as the framework will clean this up more thoroughly before running the test, or detect incompatible option combinations. gcc/testsuite/ChangeLog: * gcc.target/arm/ftest-armv4t-thumb.c: Expect __ARM_FEATURE_CLZ to be defined. Remove redundant dg-skip-if rules. * gcc.target/arm/ftest-armv5t-thumb.c: Likewise. * gcc.target/arm/ftest-armv5te-thumb.c: Likewise. * gcc.target/arm/ftest-armv6-thumb.c: Likewise. * gcc.target/arm/ftest-armv6k-thumb.c: Likewise. * gcc.target/arm/ftest-armv6z-thumb.c: Likewise. * gcc.target/arm/ftest-armv7em-thumb.c: Remove redundant dg-skip-if rules. Add a require-effective-target for armv7em. * gcc.target/arm/ftest-armv7a-arm.c: Likewise. * gcc.target/arm/ftest-armv7a-thumb.c: Likewise. * gcc.target/arm/ftest-armv7r-arm.c: Likewise. * gcc.target/arm/ftest-armv7r-thumb.c: Likewise. * gcc.target/arm/ftest-armv7ve-arm.c: Likewise. * gcc.target/arm/ftest-armv7ve-thumb.c: Likewise. * gcc.target/arm/ftest-armv8a-arm.c: Likewise. * gcc.target/arm/ftest-armv8a-thumb.c: Likewise. * gcc.target/arm/ftest-armv4-arm.c: Remove redundant dg-skip-if rules. * gcc.target/arm/ftest-armv4t-arm.c: Likewise. * gcc.target/arm/ftest-armv5t-arm.c: Likewise. * gcc.target/arm/ftest-armv5te-arm.c: Likewise. * gcc.target/arm/ftest-armv6-arm.c: Likewise. * gcc.target/arm/ftest-armv6k-arm.c: Likewise. * gcc.target/arm/ftest-armv6m-thumb.c: Likewise. * gcc.target/arm/ftest-armv6t2-arm.c: Likewise. * gcc.target/arm/ftest-armv6t2-thumb.c: Likewise. * gcc.target/arm/ftest-armv6z-arm.c: Likewise. Diff: --- gcc/testsuite/gcc.target/arm/ftest-armv4-arm.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv4t-arm.c| 2 -- gcc/testsuite/gcc.target/arm/ftest-armv4t-thumb.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv5t-arm.c| 2 -- gcc/testsuite/gcc.target/arm/ftest-armv5t-thumb.c | 7 +-- gcc/testsuite/gcc.target/arm/ftest-armv5te-arm.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv5te-thumb.c | 7 +-- gcc/testsuite/gcc.target/arm/ftest-armv6-arm.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6-thumb.c | 7 +-- gcc/testsuite/gcc.target/arm/ftest-armv6k-arm.c| 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6k-thumb.c | 7 +-- gcc/testsuite/gcc.target/arm/ftest-armv6m-thumb.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6t2-arm.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6t2-thumb.c | 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6z-arm.c| 2 -- gcc/testsuite/gcc.target/arm/ftest-armv6z-thumb.c | 7 +-- gcc/testsuite/gcc.target/arm/ftest-armv7a-arm.c| 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv7a-thumb.c | 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv7em-thumb.c | 3 +-- gcc/testsuite/gcc.target/arm/ftest-armv7r-arm.c| 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv7r-thumb.c | 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv7ve-arm.c | 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv7ve-thumb.c | 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv8a-arm.c| 4 +--- gcc/testsuite/gcc.target/arm/ftest-armv8a-thumb.c | 4 +--- 25 files changed, 34 insertions(+), 58 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/ftest-armv4-arm.c b/gcc/testsuite/gcc.target/arm/ftest-armv4-arm.c index 447a8ec16ae6..63d57d41d3f5 100644 --- a/gcc/testsuite/gcc.target/arm/ftest-armv4-arm.c +++ b/gcc/testsuite/gcc.target/arm/ftest-armv4-arm.c @@ -1,6 +1,4 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-march=*" } { "-march=armv4" } } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-mthumb" } { "" } } */ /* { dg-require-effective-target arm_arch_v4_ok } */ /* { dg-options "-marm" } */ /* { dg-add-options arm_arch_v4 } */ diff --git a/gcc/testsuite/gcc.target/arm/ftest-ar
[gcc r14-11447] ipa-cp: Avoid ICE when redistributing nodes among edges to recursive clones (PR 118318)
https://gcc.gnu.org/g:82bd83122a483275787fcd18131bf6cd91fbdbd4 commit r14-11447-g82bd83122a483275787fcd18131bf6cd91fbdbd4 Author: Martin Jambor Date: Fri Mar 7 17:17:24 2025 +0100 ipa-cp: Avoid ICE when redistributing nodes among edges to recursive clones (PR 118318) PR 118318 reported an ICE during PGO build of Firefox when IPA-CP, in the final stages of update_counts_for_self_gen_clones where it attempts to guess how to distribute profile count among clones created for recursive edges and the various edges that are created in the process. If one such edge has profile count of kind GUESSED_GLOBAL0, the compatibility check in the operator+ will lead to an ICE. After discussing the situation with Honza, we concluded that there is little more we can do other than check for this situation before touching the edge count, so this is what this patch does. gcc/ChangeLog: 2025-02-28 Martin Jambor PR ipa/118318 * ipa-cp.cc (adjust_clone_incoming_counts): Add a compatible_p check. (cherry picked from commit 7deb498425799aceb7659ea25614175a49533184) Diff: --- gcc/ipa-cp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index b7add455bd5d..6b772fae88ff 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -4608,7 +4608,8 @@ adjust_clone_incoming_counts (cgraph_node *node, cs->count = cs->count.combine_with_ipa_count (sum); } else if (!desc->processed_edges->contains (cs) -&& cs->caller->clone_of == desc->orig) +&& cs->caller->clone_of == desc->orig +&& cs->count.compatible_p (desc->count)) { cs->count += desc->count; if (dump_file)
[gcc/devel/omp/gcc-14] OpenMP: interop - fix Fortran test
https://gcc.gnu.org/g:d26a2eac8bb4b5bb121f462398903a778ada8da3 commit d26a2eac8bb4b5bb121f462398903a778ada8da3 Author: Paul-Antoine Arras Date: Mon Mar 24 15:53:36 2025 +0100 OpenMP: interop - fix Fortran test This fixes up commit r15-8654-g99e2906ae255fc: * Do not use omp_lib in Fortran compile test; instead, provide needed declarations explicitly. * Update scan-dump patterns to be compatible with 32-bit architectures. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/interop-5.f90: Declare omp_interop_kind explicitly instead of use'ing omp_lib. Update scan-dumps to allow for 4-byte pointers. (cherry picked from commit e0a1d0e044c6eb129d1133d5af51818129a4d4e0) Diff: --- gcc/testsuite/gfortran.dg/gomp/interop-5.f90 | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/gomp/interop-5.f90 b/gcc/testsuite/gfortran.dg/gomp/interop-5.f90 index a6a2d719189c..a08eeb83f716 100644 --- a/gcc/testsuite/gfortran.dg/gomp/interop-5.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/interop-5.f90 @@ -1,7 +1,13 @@ ! { dg-additional-options "-fdump-tree-omplower" } subroutine sub1 (a1, a2, a3, a4) - use omp_lib, only: omp_interop_kind + use iso_c_binding + implicit none + + ! The following definitions are in omp_lib, which cannot be included + ! in gcc/testsuite/ + integer, parameter :: omp_interop_kind = c_intptr_t + integer(omp_interop_kind) :: a1 ! by ref integer(omp_interop_kind), optional :: a2 ! as pointer integer(omp_interop_kind), allocatable :: a3 ! ref to pointer @@ -9,13 +15,13 @@ subroutine sub1 (a1, a2, a3, a4) integer(omp_interop_kind) :: b !$omp interop init(target : a1, a2, a3, a4, b) - ! { dg-final { scan-tree-dump-times "void \\* interopobjs\.\[0-9\]+\\\[5\\\];\[\r\n ]*integer\\(kind=4\\) tgt_tgtsync\.\[0-9\]+\\\[5\\\];\[\r\n ]*integer\\(kind=8\\) \\* & a3\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) \\* D\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) \\* a2\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) & a1\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[0\\\] = &b;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[0\\\] = 1;\[\r\n ]*interopobjs\.\[0-9\]+\\\[1\\\] = &a4;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[1\\\] = 1;\[\r\n ]*a3\.\[0-9\]+ = a3;\[\r\n ]*D\.\[0-9\]+ = \\*a3\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[2\\\] = D\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[2\\\] = 1;\[\r\n ]*a2\.\[0-9\]+ = a2;\[\r\n ]*interopobjs\.\[0-9\]+\\\[3\\\] = a2\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[3\\\] = 1;\[\r\n ]*a1\.\[0-9\]+ = a1;\[\r\n ]*interopobjs\.\[0-9\]+\\\[4\\\] = a1\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[4\\\] = 1;\[\r\n ]*__builtin_GOMP_interop \\(-5, 5, &interopobjs\.\[0-9\]+, &tgt_tgtsync\ .\[0-9\]+, 0B, 0, 0B, 0, 0B, 0, 0B\\);" 1 "omplower" } } + ! { dg-final { scan-tree-dump-times "void \\* interopobjs\.\[0-9\]+\\\[5\\\];\[\r\n ]*integer\\(kind=4\\) tgt_tgtsync\.\[0-9\]+\\\[5\\\];\[\r\n ]*integer\\(kind=\[48\]\\) \\* & a3\.\[0-9\]+;\[\r\n ]*integer\\(kind=\[48\]\\) \\* D\.\[0-9\]+;\[\r\n ]*integer\\(kind=\[48\]\\) \\* a2\.\[0-9\]+;\[\r\n ]*integer\\(kind=\[48\]\\) & a1\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[0\\\] = &b;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[0\\\] = 1;\[\r\n ]*interopobjs\.\[0-9\]+\\\[1\\\] = &a4;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[1\\\] = 1;\[\r\n ]*a3\.\[0-9\]+ = a3;\[\r\n ]*D\.\[0-9\]+ = \\*a3\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[2\\\] = D\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[2\\\] = 1;\[\r\n ]*a2\.\[0-9\]+ = a2;\[\r\n ]*interopobjs\.\[0-9\]+\\\[3\\\] = a2\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[3\\\] = 1;\[\r\n ]*a1\.\[0-9\]+ = a1;\[\r\n ]*interopobjs\.\[0-9\]+\\\[4\\\] = a1\.\[0-9\]+;\[\r\n ]*tgt_tgtsync\.\[0-9\]+\\\[4\\\] = 1;\[\r\n ]*__builtin_GOMP_interop \\(-5, 5, &interopobjs\.\[0 -9\]+, &tgt_tgtsync\.\[0-9\]+, 0B, 0, 0B, 0, 0B, 0, 0B\\);" 1 "omplower" } } !$omp interop use(a1, a2, a3, a4, b) - ! { dg-final { scan-tree-dump-times "void \\* interopobjs\.\[0-9\]+\\\[5\\\];\[\r\n ]*integer\\(kind=8\\) b\.\[0-9\]+;\[\r\n ]*void \\* b\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) a4\.\[0-9\]+;\[\r\n ]*void \\* a4\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) \\* & a3\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) \\* D\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) D\.\[0-9\]+;\[\r\n ]*void \\* D\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) \\* a2\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) D\.\[0-9\]+;\[\r\n ]*void \\* D\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) & a1\.\[0-9\]+;\[\r\n ]*integer\\(kind=8\\) D\.\[0-9\]+;\[\r\n ]*void \\* D\.\[0-9\]+;\[\r\n ]*b\.\[0-9\]+ = b;\[\r\n ]*b\.\[0-9\]+ = \\(void \\*\\) b\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[0\\\] = b\.\[0-9\]+;\[\r\n ]*a4\.\[0-9\]+ = a4;\[\r\n ]*a4\.\[0-9\]+ = \\(void \\*\\) a4\.\[0-9\]+;\[\r\n ]*interopobjs\.\[0-9\]+\\\[1\\\] = a4\.\[0-9\]+;\[\r\n ]*a3\.\[0-9\]+ = a3;\[\r\n ]*D\.\[0-9\]+ = \\*a3\.\[0-9\]+;\[\r\n ]*D\.\[0-9\]+ = \\*D\.\[0-9\]+;\[\r\n
[gcc r15-8902] libstdc++: Fix std::vector::append_range for overlapping ranges
https://gcc.gnu.org/g:d4f7d18b3ed83a8265be913bb230f6efa395e527 commit r15-8902-gd4f7d18b3ed83a8265be913bb230f6efa395e527 Author: Jonathan Wakely Date: Fri Mar 21 23:21:42 2025 + libstdc++: Fix std::vector::append_range for overlapping ranges Unlike insert_range and assign_range, the append_range function does not have a precondition that the range doesn't overlap *this. That means we need to avoid relocating the existing elements until after copying from the range. This means I need to revert r15-8488-g3e1d760bf49d0e which made the from_range_t constructor use append_range, because the constructor can avoid the additional complexity needed by append_range. When relocating the existing elements in append_range we can use std::__relocate_a to do it more efficiently, if that's valid. std::vector::append_range needs similar treatment, although it's a bit simpler as we know that the elements are trivially copyable and so we don't need to worry about them throwing. assign_range doesn't allow overlapping ranges, so can be rewritten to be more efficient than calling append_range for the forward or sized range case. libstdc++-v3/ChangeLog: * include/bits/stl_bvector.h (vector::assign_range): More efficient implementation for forward/sized ranges. (vector::append_range): Handle potentially overlapping range. * include/bits/stl_vector.h (vector(from_range_t, R&&, Alloc)): Do not use append_range for non-sized input range case. (vector::append_range): Handle potentially overlapping range. * include/bits/vector.tcc (vector::insert_range): Forward range instead of moving it. * testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc: Test overlapping ranges. * testsuite/23_containers/vector/modifiers/append_range.cc: Likewise. Reviewed-by: Tomasz Kamiński Diff: --- libstdc++-v3/include/bits/stl_bvector.h| 77 -- libstdc++-v3/include/bits/stl_vector.h | 110 +- libstdc++-v3/include/bits/vector.tcc | 2 +- .../vector/bool/modifiers/insert/append_range.cc | 51 +++ .../23_containers/vector/modifiers/append_range.cc | 165 + 5 files changed, 385 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 3ee15eaa938c..03f6434604c3 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -899,6 +899,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __glibcxx_ranges_to_container // C++ >= 23 /** * @brief Construct a vector from a range. + * @param __rg A range of values that are convertible to `value_type`. * @since C++23 */ template<__detail::__container_compatible_range _Rg> @@ -1028,6 +1029,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __glibcxx_ranges_to_container // C++ >= 23 /** * @brief Assign a range to the vector. + * @param __rg A range of values that are convertible to `value_type`. + * @pre `__rg` and `*this` do not overlap. * @since C++23 */ template<__detail::__container_compatible_range _Rg> @@ -1035,8 +1038,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER assign_range(_Rg&& __rg) { static_assert(assignable_from>); - clear(); - append_range(std::forward<_Rg>(__rg)); + if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) + { + if (auto __n = size_type(ranges::distance(__rg))) + { + reserve(__n); + this->_M_impl._M_finish + = ranges::copy(std::forward<_Rg>(__rg), begin()).out; + } + else + clear(); + } + else + { + clear(); + auto __first = ranges::begin(__rg); + const auto __last = ranges::end(__rg); + for (; __first != __last; ++__first) + emplace_back(*__first); + } } #endif @@ -1330,6 +1350,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __glibcxx_ranges_to_container // C++ >= 23 /** * @brief Insert a range into the vector. + * @param __rg A range of values that are convertible to `bool`. + * @return An iterator that points to the first new element inserted, + * or to `__pos` if `__rg` is an empty range. + * @pre `__rg` and `*this` do not overlap. * @since C++23 */ template<__detail::__container_compatible_range _Rg> @@ -1385,24 +1409,53 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER constexpr void append_range(_Rg&& __rg) { + // N.B. __rg may overlap with *this, so we must copy from _
[gcc r15-8905] libstdc++: Allow std::ranges::to to create unions
https://gcc.gnu.org/g:479a0a8644e5efa0470f032be21ca7749968af42 commit r15-8905-g479a0a8644e5efa0470f032be21ca7749968af42 Author: Jonathan Wakely Date: Tue Mar 25 00:27:52 2025 + libstdc++: Allow std::ranges::to to create unions LWG 4229 points out that the std::ranges::to wording refers to class types, but I added an assertion using std::is_class_v which only allows non-union class types. LWG consensus is that unions should be allowed, so this additionally uses std::is_union_v. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::to): Allow unions as well as non-union class types. * testsuite/std/ranges/conv/lwg4229.cc: New test. Reviewed-by: Tomasz Kamiński Diff: --- libstdc++-v3/include/std/ranges | 4 ++-- libstdc++-v3/testsuite/std/ranges/conv/lwg4229.cc | 18 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 34c6f113e216..7a339c51368e 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -9421,7 +9421,7 @@ namespace __detail to [[nodiscard]] (_Rg&& __r, _Args&&... __args) { static_assert(!is_const_v<_Cont> && !is_volatile_v<_Cont>); - static_assert(is_class_v<_Cont>); + static_assert(is_class_v<_Cont> || is_union_v<_Cont>); if constexpr (__detail::__toable<_Cont, _Rg>) { @@ -9580,7 +9580,7 @@ namespace __detail to [[nodiscard]] (_Args&&... __args) { static_assert(!is_const_v<_Cont> && !is_volatile_v<_Cont>); - static_assert(is_class_v<_Cont>); + static_assert(is_class_v<_Cont> || is_union_v<_Cont>); using __detail::_To; using views::__adaptor::_Partial; diff --git a/libstdc++-v3/testsuite/std/ranges/conv/lwg4229.cc b/libstdc++-v3/testsuite/std/ranges/conv/lwg4229.cc new file mode 100644 index ..780ed1fd932b --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/conv/lwg4229.cc @@ -0,0 +1,18 @@ +// { dg-do compile { target c++23 } } + +// LWG 4229 std::ranges::to with union return type + +#include + +union U +{ + template U(std::from_range_t, R&&) { } + + int i; +}; + +void +test_lwg4229(std::ranges::subrange r) +{ + U u = std::ranges::to(r); +}
[gcc r15-8903] libstdc++: Adjust how __gnu_debug::vector detects invalidation
https://gcc.gnu.org/g:2848b8dabcaca05563b92528206345f8f845daff commit r15-8903-g2848b8dabcaca05563b92528206345f8f845daff Author: Jonathan Wakely Date: Mon Mar 24 21:21:02 2025 + libstdc++: Adjust how __gnu_debug::vector detects invalidation The new C++23 member functions assign_range, insert_range and append_range were checking whether the begin() iterator changed after calling the base class member. That works, but is technically undefined when the original iterator has been invalidated by a change in capacity. We can just check the capacity directly, because reallocation only occurs if a change in capacity is required. N.B. we can't use data() either because std::vector doesn't have it. libstdc++-v3/ChangeLog: * include/debug/vector (vector::assign_range): Use change in capacity to detect reallocation. (vector::insert_range, vector::append_range): Likewise. Remove unused variables. Reviewed-by: Tomasz Kamiński Diff: --- libstdc++-v3/include/debug/vector | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 022ebe8c6645..b49766c18a76 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -876,12 +876,12 @@ namespace __debug constexpr void assign_range(_Rg&& __rg) { - auto __old_begin = _Base::begin(); + auto __old_capacity = _Base::capacity(); auto __old_size = _Base::size(); _Base::assign_range(__rg); if (!std::__is_constant_evaluated()) { - if (_Base::begin() != __old_begin) + if (_Base::capacity() != __old_capacity) this->_M_invalidate_all(); else if (_Base::size() < __old_size) this->_M_invalidate_after_nth(_Base::size()); @@ -893,12 +893,11 @@ namespace __debug constexpr iterator insert_range(const_iterator __pos, _Rg&& __rg) { - auto __old_begin = _Base::begin(); - auto __old_size = _Base::size(); + auto __old_capacity = _Base::capacity(); auto __res = _Base::insert_range(__pos.base(), __rg); if (!std::__is_constant_evaluated()) { - if (_Base::begin() != __old_begin) + if (_Base::capacity() != __old_capacity) this->_M_invalidate_all(); this->_M_update_guaranteed_capacity(); } @@ -909,12 +908,11 @@ namespace __debug constexpr void append_range(_Rg&& __rg) { - auto __old_begin = _Base::begin(); - auto __old_size = _Base::size(); + auto __old_capacity = _Base::capacity(); _Base::append_range(__rg); if (!std::__is_constant_evaluated()) { - if (_Base::begin() != __old_begin) + if (_Base::capacity() != __old_capacity) this->_M_invalidate_all(); this->_M_update_guaranteed_capacity(); }
[gcc r15-8906] C prototypes for functions returning C function pointers.
https://gcc.gnu.org/g:737a5760bb24a0a945cc2c916ba452e3f0060c58 commit r15-8906-g737a5760bb24a0a945cc2c916ba452e3f0060c58 Author: Thomas Koenig Date: Tue Mar 25 18:42:30 2025 +0100 C prototypes for functions returning C function pointers. This patch handles dumping prototypes for C functions returning function pointers. For the test case MODULE test USE, INTRINSIC :: ISO_C_BINDING CONTAINS FUNCTION lookup(idx) BIND(C) type(C_FUNPTR) :: lookup integer(C_INT), VALUE :: idx lookup = C_FUNLOC(x1) END FUNCTION lookup subroutine x1() end subroutine x1 END MODULE test the prototype is void (*lookup (int idx)) (); Regression-tested. Again no test case because I don't know how. During testing, I also found that vtabs were dumped, this is also corrected. gcc/fortran/ChangeLog: PR fortran/119419 * dump-parse-tree.cc (write_funptr_fcn): New function. (write_type): Invoke it for C_FUNPTR. (write_interop_decl): Do not dump vtabs. Diff: --- gcc/fortran/dump-parse-tree.cc | 26 +++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 1a15757b57be..9501bccb803b 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -4038,6 +4038,7 @@ static void write_interop_decl (gfc_symbol *); static void write_proc (gfc_symbol *, bool); static void show_external_symbol (gfc_gsymbol *, void *); static void write_type (gfc_symbol *sym); +static void write_funptr_fcn (gfc_symbol *); /* Do we need to write out an #include or not? */ @@ -4379,9 +4380,10 @@ write_type (gfc_symbol *sym) { gfc_component *c; - /* Don't dump our iso c module. */ + /* Don't dump our iso c module, nor vtypes. */ - if (sym->from_intmod == INTMOD_ISO_C_BINDING || sym->attr.flavor != FL_DERIVED) + if (sym->from_intmod == INTMOD_ISO_C_BINDING || sym->attr.flavor != FL_DERIVED + || sym->attr.vtype) return; fprintf (dumpfile, "typedef struct %s {\n", sym->name); @@ -4495,6 +4497,18 @@ write_formal_arglist (gfc_symbol *sym, bool bind_c) } +/* Write out an interoperable function returning a function pointer. Better + handled separately. As we know nothing about the type, assume void. + Function ponters can be freely converted in C anyway. */ + +static void +write_funptr_fcn (gfc_symbol *sym) +{ + fprintf (dumpfile, "void (*%s (", sym->binding_label); + write_formal_arglist (sym, 1); + fputs (")) ();\n", dumpfile); +} + /* Write out a procedure, including its arguments. */ static void write_proc (gfc_symbol *sym, bool bind_c) @@ -4552,7 +4566,13 @@ write_interop_decl (gfc_symbol *sym) else if (sym->attr.flavor == FL_DERIVED) write_type (sym); else if (sym->attr.flavor == FL_PROCEDURE) -write_proc (sym, true); +{ + if (sym->ts.type == BT_DERIVED + && sym->ts.u.derived->intmod_sym_id == ISOCBINDING_FUNPTR) + write_funptr_fcn (sym); + else + write_proc (sym, true); +} } /* This section deals with dumping the global symbol tree. */
[gcc r15-8892] omp-general.cc: Remove 'if' around call to always 'true' returning function [PR118627]
https://gcc.gnu.org/g:c6279fffdbf8e13e46932eb8e100cfc579d06f2c commit r15-8892-gc6279fffdbf8e13e46932eb8e100cfc579d06f2c Author: Tobias Burnus Date: Tue Mar 25 15:02:54 2025 +0100 omp-general.cc: Remove 'if' around call to always 'true' returning function [PR118627] Before omp_parse_access_method and omp_parse_access_methods unconditionally returned true, now they are void functions. Accordingly, calls had to be updated by removing the 'if' around the call; this also fixes Clang's -Wsometimes-uninitialized warning when compiling omp-general.cc as one variable remained uninitialized for a never occurring false. gcc/ChangeLog: PR middle-end/118627 * omp-general.cc (omp_parse_access_method): Change to return void. (omp_parse_access_methods): Return void; remove 'if' around a function call. (omp_parse_expr): Remove 'if' around a function call. Diff: --- gcc/omp-general.cc | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc index 0a2dd6b5be79..0b7c3b9d3181 100644 --- a/gcc/omp-general.cc +++ b/gcc/omp-general.cc @@ -4185,7 +4185,7 @@ omp_parse_pointer (tree *expr0, bool *has_offset) return false; } -static bool +static void omp_parse_access_method (tree *expr0, enum access_method_kinds *kind) { tree expr = *expr0; @@ -4216,18 +4216,17 @@ omp_parse_access_method (tree *expr0, enum access_method_kinds *kind) STRIP_NOPS (expr); *expr0 = expr; - return true; } -static bool +static void omp_parse_access_methods (vec &addr_tokens, tree *expr0) { tree expr = *expr0; enum access_method_kinds kind; tree am_expr; - if (omp_parse_access_method (&expr, &kind)) -am_expr = expr; + omp_parse_access_method (&expr, &kind); + am_expr = expr; if (TREE_CODE (expr) == INDIRECT_REF || TREE_CODE (expr) == MEM_REF @@ -4237,7 +4236,6 @@ omp_parse_access_methods (vec &addr_tokens, tree *expr0) addr_tokens.safe_push (new omp_addr_token (kind, am_expr)); *expr0 = expr; - return true; } static bool omp_parse_structured_expr (vec &, tree *); @@ -4355,8 +4353,7 @@ omp_parse_expr (vec &addr_tokens, tree expr) using namespace omp_addr_tokenizer; auto_vec expr_access_tokens; - if (!omp_parse_access_methods (expr_access_tokens, &expr)) -return false; + omp_parse_access_methods (expr_access_tokens, &expr); if (omp_parse_structured_expr (addr_tokens, &expr)) ;
[gcc r15-8891] arm: testsuite: avoid dg-options in primary LTO file
https://gcc.gnu.org/g:927cfea902c330092848bd7a228b714b07d08f6b commit r15-8891-g927cfea902c330092848bd7a228b714b07d08f6b Author: Richard Earnshaw Date: Tue Mar 25 13:48:06 2025 + arm: testsuite: avoid dg-options in primary LTO file As the primary LTO file in this test, it cannot use dg-options. Move the flags from there to dg-lto-options. gcc/testsuite/ChangeLog: * gcc.target/arm/lto/pr96939_0.c (dg-options): Delete. Move the options from here ... (dg-lto-options): ... to here. Diff: --- gcc/testsuite/gcc.target/arm/lto/pr96939_0.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/lto/pr96939_0.c b/gcc/testsuite/gcc.target/arm/lto/pr96939_0.c index 21d2c1d70a40..8dfbc0610090 100644 --- a/gcc/testsuite/gcc.target/arm/lto/pr96939_0.c +++ b/gcc/testsuite/gcc.target/arm/lto/pr96939_0.c @@ -1,8 +1,7 @@ /* PR target/96939 */ /* { dg-lto-do link } */ /* { dg-require-effective-target arm_arch_v8a_link } */ -/* { dg-options "-mcpu=unset -march=armv8-a+simd -mfpu=auto" } */ -/* { dg-lto-options { { -flto -O2 } } } */ +/* { dg-lto-options { { -flto -O2 -mcpu=unset -march=armv8-a+simd -mfpu=auto} } } */ extern unsigned crc (unsigned, const void *); typedef unsigned (*fnptr) (unsigned, const void *);
[gcc r15-8893] install.texi: gcn - suggest to use Newlib with simd math fix [PR119325]
https://gcc.gnu.org/g:56189d0ffeb35769637347720dfb24d2e4d7d47f commit r15-8893-g56189d0ffeb35769637347720dfb24d2e4d7d47f Author: Tobias Burnus Date: Tue Mar 25 15:07:56 2025 +0100 install.texi: gcn - suggest to use Newlib with simd math fix [PR119325] Suggest a Newlib with a fix for the SIMD math issue. Newlib commit: https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=2ef1a37e7 Additionally, for generic support in ROCm, it is expected that 6.4 will added the support; the current version is 6.3.3 and it does not support it; bump >6.3.2 to >6.3.3 in install.texi to avoid doubts. gcc/ChangeLog: PR middle-end/119325 * doc/install.texi (gcn): Change ROCm > 6.3.2 to >6.3.3 for generic support; mention Newlib commit that fixes a SIMD math issue. Diff: --- gcc/doc/install.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 308529669b15..b5509ff0c86b 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -4056,11 +4056,12 @@ ISA targets @code{gfx9-generic}, @code{gfx10-3-generic}, and @code{gfx11-generic} reduce the number of required multilibs but note that @code{gfx9-generic} does not include @code{gfx908} or @code{gfx90a}, that linking specific ISA code with generic code is currently not supported, -and that only a future ROCm release (newer than 6.3.2) will be able to execute +and that only a future ROCm release (newer than 6.3.3) will be able to execute generic code. Use Newlib (4.3.0 or newer; 4.4.0 contains some improvements and 4.5.0 fixes -the device console output for GFX10 and GFX11 devices). +the device console output for GFX10 and GFX11 devices; post-4.5.0 +commit 2ef1a37e7 [Mar 25, 2025] fixes a SIMD math issue). To run the binaries, install the HSA Runtime from the @uref{https://rocm.docs.amd.com/,,ROCm Platform}, and use
[gcc r15-8890] arm: testsuite: update expected output in vect-early-break-cbranch.c
https://gcc.gnu.org/g:2f4c5cf2c9bad6a6207b3377cf3179ed00cfcf11 commit r15-8890-g2f4c5cf2c9bad6a6207b3377cf3179ed00cfcf11 Author: Richard Earnshaw Date: Tue Mar 25 13:31:54 2025 + arm: testsuite: update expected output in vect-early-break-cbranch.c Similar to r15-4930-gd56d2f3102ada3, update the branch operations when not using CBN?Z for inverting the direction of the branch operations. gcc/testsuite/ChangeLog: * gcc.target/arm/vect-early-break-cbranch.c: Allow BEQ as well as BNE. Diff: --- gcc/testsuite/gcc.target/arm/vect-early-break-cbranch.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/vect-early-break-cbranch.c b/gcc/testsuite/gcc.target/arm/vect-early-break-cbranch.c index 4dc0edd874b4..045f143fb930 100644 --- a/gcc/testsuite/gcc.target/arm/vect-early-break-cbranch.c +++ b/gcc/testsuite/gcc.target/arm/vect-early-break-cbranch.c @@ -18,7 +18,7 @@ int b[N] = {0}; ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** ) @@ -43,7 +43,7 @@ void f1 () ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** ) @@ -68,7 +68,7 @@ void f2 () ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** ) @@ -94,7 +94,7 @@ void f3 () ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** ) @@ -119,7 +119,7 @@ void f4 () ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** ) @@ -144,7 +144,7 @@ void f5 () ** vmovr[0-9]+, s[0-9]+@ int ** ( ** cmp r[0-9]+, #0 -** bne \.L[0-9]+ +** b(ne|eq)\.L[0-9]+ ** | ** cbn?z r[0-9]+, \.L.+ ** )
[gcc/devel/omp/gcc-14] libgomp: Save OpenMP device number when initializing the interop object
https://gcc.gnu.org/g:e7a79c14ab50ac1bb3ae043f477e2d6ab7ceac4f commit e7a79c14ab50ac1bb3ae043f477e2d6ab7ceac4f Author: Tobias Burnus Date: Mon Mar 24 19:52:10 2025 +0100 libgomp: Save OpenMP device number when initializing the interop object The interop object (opaque object to the user, used internally in libgomp) already had a 'device_num' member, but it was missed to actually set it. libgomp/ChangeLog: * target.c (gomp_interop_internal): Set the 'device_num' member when initializing an interop object. (cherry picked from commit 4d5d1a7326c8509a4a6fc94eedc3ba22d68f806f) Diff: --- libgomp/ChangeLog.omp | 8 1 file changed, 8 insertions(+) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 9cb3e08e8279..34f8f9f162f5 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -16,6 +16,14 @@ * testsuite/libgomp.c++/pr101544-1-O0.C: Likewise. * testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise. +2025-03-24 Tobias Burnus + + Backported from master: + 2025-03-24 Tobias Burnus + + * target.c (gomp_interop_internal): Set the 'device_num' member + when initializing an interop object. + 2025-03-24 Tobias Burnus Backported from master:
[gcc r15-8477] d: Fix quoted command-line options to match lang.opt [PR118545]
https://gcc.gnu.org/g:47822ef8f1b03ab7124aba694709825a93897994 commit r15-8477-g47822ef8f1b03ab7124aba694709825a93897994 Author: Iain Buclaw Date: Fri Mar 21 00:28:45 2025 +0100 d: Fix quoted command-line options to match lang.opt [PR118545] It was noticed that not all D language options get a url in diagnostics. These have been checked and fixed as necessary. PR d/118545 gcc/d/ChangeLog: * d-lang.cc (d_handle_option): Adjust quoted options. Diff: --- gcc/d/d-lang.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 8e37fed2b608..21f46ffb6aa8 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -460,7 +460,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, break; } - error ("bad argument for %<-fdebug%>: %qs", arg); + error ("bad argument for %<-fdebug=%>: %qs", arg); break; case OPT_fdoc: @@ -533,7 +533,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, case OPT_fmodule_file_: global.params.modFileAliasStrings.push (arg); if (!strchr (arg, '=')) - error ("bad argument for %<-fmodule-file%>: %qs", arg); + error ("bad argument for %<-fmodule-file=%>: %qs", arg); break; case OPT_fmoduleinfo: @@ -700,7 +700,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, break; } - error ("bad argument for %<-fversion%>: %qs", arg); + error ("bad argument for %<-fversion=%>: %qs", arg); break; case OPT_H:
[gcc r15-8896] i386: Fix up combination of -2 r<<= (x & 7) into btr [PR119428]
https://gcc.gnu.org/g:584b346a4c7a6e6e77da6dc80968401a3c08161d commit r15-8896-g584b346a4c7a6e6e77da6dc80968401a3c08161d Author: Jakub Jelinek Date: Tue Mar 25 16:55:24 2025 +0100 i386: Fix up combination of -2 r<<= (x & 7) into btr [PR119428] The following patch is miscompiled from r15-8478 but latently already since my r11-5756 and r11-6631 changes. The r11-5756 change was https://gcc.gnu.org/pipermail/gcc-patches/2020-December/561164.html which changed the splitters to immediately throw away the masking. And the r11-6631 change was an optimization to recognize (set (zero_extract:HI (...) (const_int 1) (...)) (const_int 1) as btr. The problem is their interaction. x86 is not a SHIFT_COUNT_TRUNCATED target, so the masking needs to be explicit in the IL. And combine.cc (make_field_assignment) has since 1992 optimizations which try to optimize x &= (-2 r<< y) into zero_extract (x) = 0. Now, such an optimization is fine if y has not been masked or if the chosen zero_extract has the same mode as the rotate (or it recognizes something with a left shift too). IMHO such optimization is invalid for SHIFT_COUNT_TRUNCATED targets because we explicitly say that the masking of the shift/rotate counts are redundant there and don't need to be part of the IL (I have a patch for that, but because it is just latent, I'm not sure it needs to be posted for gcc 15 (and also am not sure if it should punt or add operand masking just in case)). x86 is not SHIFT_COUNT_TRUNCATED though and so even fixing combine not to do that for SHIFT_COUNT_TRUNCATED targets doesn't help, and we don't have QImode insv, so it is optimized into HImode insertions. Now, if the y in x &= (-2 r<< y) wasn't masked in any way, turning it into HImode btr is just fine, but if it was x &= (-2 r<< (y & 7)) and we just decided to throw away the masking, using btr changes the behavior on it and causes e2fsprogs and sqlite miscompilations. So IMHO on !SHIFT_COUNT_TRUNCATED targets, we need to keep the maskings explicit in the IL, either at least for the duration of the combine pass as does the following patch (where combine is the only known pass to have such transformation), or even keep it until final pass in case there are some later optimizations that would also need to know whether there was explicit masking or not and with what mask. The latter change would be much larger. The following patch just reverts the r11-5756 change and adds a testcase. 2025-03-25 Jakub Jelinek PR target/96226 PR target/119428 * config/i386/i386.md (splitter after *3_mask, splitter after *3_mask_1): Revert 2020-12-05 changes. * gcc.c-torture/execute/pr119428.c: New test. Diff: --- gcc/config/i386/i386.md| 6 -- gcc/testsuite/gcc.c-torture/execute/pr119428.c | 18 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 2b3cffc1f350..9d1b34e55959 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -18168,7 +18168,8 @@ [(set (match_dup 4) (match_dup 1)) (set (match_dup 0) (any_rotate:SWI (match_dup 4) - (subreg:QI (match_dup 2) 0)))] + (subreg:QI +(and:SI (match_dup 2) (match_dup 3)) 0)))] "operands[4] = gen_reg_rtx (mode);") (define_insn_and_split "*3_mask_1" @@ -18202,7 +18203,8 @@ == GET_MODE_BITSIZE (mode) - 1" [(set (match_dup 4) (match_dup 1)) (set (match_dup 0) - (any_rotate:SWI (match_dup 4) (match_dup 2)))] + (any_rotate:SWI (match_dup 4) + (and:QI (match_dup 2) (match_dup 3] "operands[4] = gen_reg_rtx (mode);") (define_insn_and_split "*3_add" diff --git a/gcc/testsuite/gcc.c-torture/execute/pr119428.c b/gcc/testsuite/gcc.c-torture/execute/pr119428.c new file mode 100644 index ..33a93f46b3bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr119428.c @@ -0,0 +1,18 @@ +/* PR target/119428 */ + +__attribute__((noipa)) void +foo (unsigned int x, unsigned char *y) +{ + y += x >> 3; + *y &= (unsigned char) ~(1 << (x & 0x07)); +} + +int +main () +{ + unsigned char buf[8]; + __builtin_memset (buf, 0xff, 8); + foo (8, buf); + if (buf[1] != 0xfe) +__builtin_abort (); +}
[gcc r15-8884] testsuite: arm: remove duplicate -mcpu=unset in arm_v8_1_lob_ok
https://gcc.gnu.org/g:3c384dfc89fcf87b01f300968e85a7547e058748 commit r15-8884-g3c384dfc89fcf87b01f300968e85a7547e058748 Author: Christophe Lyon Date: Wed Mar 19 10:59:04 2025 + testsuite: arm: remove duplicate -mcpu=unset in arm_v8_1_lob_ok This was probably a typo / oversight. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_arm_v8_1_lob_ok): Remove duplicate -mcpu=unset. Diff: --- gcc/testsuite/lib/target-supports.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index e875e3574b5e..e90c090027e3 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -13504,7 +13504,7 @@ proc check_effective_target_arm_v8_1_lob_ok { } { asm goto ("le lr, %l0" : : : "lr" : loop); return i != 10; } - } "-mcpu=unset -mcpu=unset -march=armv8.1-m.main -mthumb" ] + } "-mcpu=unset -march=armv8.1-m.main -mthumb" ] } }
[gcc r15-8895] RISC-V: disable the abd expander for gcc-15 release [PR119224]
https://gcc.gnu.org/g:cb6070c79dd9334e7cfff40bacd21da4f337cc33 commit r15-8895-gcb6070c79dd9334e7cfff40bacd21da4f337cc33 Author: Vineet Gupta Date: Mon Mar 24 10:36:52 2025 -0700 RISC-V: disable the abd expander for gcc-15 release [PR119224] It seems the new expander triggers a latent issue in sched1 causing extraneous spills in a different sad variant. Given how close we are to gcc-15 release, disable it for now. Since we do want to retain and re-enable this capabilty, manully disable vs. reverting the orig patch which takes away the test case too. Fix the orig test case to expect old codegen idiom (although vneg is no longer emitted, in favor of vrsub). Also add a new testcase which flags any future spills in the affected routine. PR target/119224 gcc/ChangeLog: * config/riscv/autovec.md: Disable abd splitter. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr117722.c: Adjust output insn. * gcc.target/riscv/rvv/autovec/pr119224.c: Add new test. Signed-off-by: Vineet Gupta Diff: --- gcc/config/riscv/autovec.md| 3 ++- .../gcc.target/riscv/rvv/autovec/pr117722.c| 6 ++--- .../gcc.target/riscv/rvv/autovec/pr119224.c| 27 ++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index c7f12f9e36f5..f53ed3a5e3fd 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -2975,7 +2975,8 @@ [(match_operand:V_VLSI 0 "register_operand") (match_operand:V_VLSI 1 "register_operand") (match_operand:V_VLSI 2 "register_operand")] - "TARGET_VECTOR" + ;; Disabled until PR119224 is resolved + "TARGET_VECTOR && 0" { rtx max = gen_reg_rtx (mode); insn_code icode = code_for_pred (UMAX, mode); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117722.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117722.c index f255ceb2cee6..493dab056212 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117722.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117722.c @@ -18,6 +18,6 @@ int pixel_sad_n(unsigned char *pix1, unsigned char *pix2, int n) return sum; } -/* { dg-final { scan-assembler {vminu\.v} } } */ -/* { dg-final { scan-assembler {vmaxu\.v} } } */ -/* { dg-final { scan-assembler {vsub\.v} } } */ +/* { dg-final { scan-assembler {vrsub\.v} } } */ +/* { dg-final { scan-assembler {vmax\.v} } } */ +/* { dg-final { scan-assembler {vwsubu\.v} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr119224.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr119224.c new file mode 100644 index ..fa3386c345b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr119224.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math -march=rv64gcv_zvl256b -mabi=lp64d -mtune=generic-ooo -mrvv-vector-bits=zvl" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-O2" "-Og" "-Os" "-Oz" } } */ + +/* A core routine of x264 which should not spill for OoO VLS build. */ + +inline int abs(int i) +{ + return (i < 0 ? -i : i); +} + +int x264_sad_16x16(unsigned char *p1, int st1, unsigned char *p2, int st2) +{ +int sum = 0; + +for(int y = 0; y < 16; y++) + { + for(int x = 0; x < 16; x++) + sum += abs (p1[x] - p2[x]); + p1 += st1; p2 += st2; + } + + return sum; +} + +/* { dg-final { scan-assembler-not {addi\t[a-x0-9]+,sp} } } */ +/* { dg-final { scan-assembler-not {addi\tsp,sp} } } */
[gcc r15-8898] OpenMP: Create additional interop objects with append_args.
https://gcc.gnu.org/g:f016ee89955ab4da5fe7ef89368e9437bb5ffb13 commit r15-8898-gf016ee89955ab4da5fe7ef89368e9437bb5ffb13 Author: Sandra Loosemore Date: Tue Mar 25 15:55:45 2025 + OpenMP: Create additional interop objects with append_args. This patch adds support for the case where #pragma omp declare variant with append_args is used inside a #pragma omp dispatch interop that specifies fewer interop args than required by the variant; new interop objects are implicitly created and then destroyed around the call to the variant, using the GOMP_interop builtin. gcc/fortran/ChangeLog * trans-openmp.cc (gfc_trans_omp_declare_variant): Remove accidental redeclaration of pref. gcc/ChangeLog * gimplify.cc (modify_call_for_omp_dispatch): Adjust arguments. Remove the "sorry" for the case where new interop objects must be constructed, and add code to make it work instead. (expand_variant_call_expr): Adjust arguments and call to modify_call_for_omp_dispatch. (gimplify_variant_call_expr): Simplify logic for calling expand_variant_call_expr. gcc/testsuite/ChangeLog * c-c++-common/gomp/append-args-1.c: Adjust expected behavior. * c-c++-common/gomp/append-args-interop.c: New. * c-c++-common/gomp/dispatch-11.c: Adjust expected behavior. * g++.dg/gomp/append-args-1.C: Likewise. * gfortran.dg/gomp/append-args-interop.f90: New. * gfortran.dg/gomp/declare-variant-mod-2.f90: Adjust expected behavior. libgomp/ChangeLog * libgomp.texi (OpenMP 5.1): Mark append_args as fully supported. Co-Authored-By: Tobias Burnus Diff: --- gcc/fortran/trans-openmp.cc| 4 +- gcc/gimplify.cc| 229 ++--- gcc/testsuite/c-c++-common/gomp/append-args-1.c| 14 +- .../c-c++-common/gomp/append-args-interop.c| 44 gcc/testsuite/c-c++-common/gomp/dispatch-11.c | 3 - gcc/testsuite/g++.dg/gomp/append-args-1.C | 18 +- .../gfortran.dg/gomp/append-args-interop.f90 | 27 +++ .../gfortran.dg/gomp/declare-variant-mod-2.f90 | 6 - libgomp/libgomp.texi | 3 +- 9 files changed, 275 insertions(+), 73 deletions(-) diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index bf8c34172c37..03d94326bc84 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -8980,8 +8980,8 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns, gfc_namespace *parent_ns) tree pref = NULL_TREE; if (n->u.init.len) { - tree pref = build_string (n->u.init.len, - n->u2.init_interop); + pref = build_string (n->u.init.len, + n->u2.init_interop); TREE_TYPE (pref) = build_array_type_nelts ( unsigned_char_type_node, n->u.init.len); diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 354c3d663e7e..2364de081ffe 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3874,8 +3874,8 @@ find_supercontext (void) /* OpenMP: Handle the append_args and adjust_args clauses of declare_variant for EXPR, which is a CALL_EXPR whose CALL_EXPR_FN - is the variant, within a dispatch construct with clauses DISPATCH_CLAUSES - and location DISPATCH_LOC. + is the variant, within a dispatch construct with clauses DISPATCH_CLAUSES. + WANT_VALUE and POINTERIZE are as for expand_variant_call_expr. 'append_args' causes interop objects are added after the last regular (nonhidden, nonvariadic) arguments of the variant function. @@ -3885,7 +3885,7 @@ find_supercontext (void) address. */ static tree modify_call_for_omp_dispatch (tree expr, tree dispatch_clauses, - location_t dispatch_loc) + bool want_value, bool pointerize) { tree fndecl = get_callee_fndecl (expr); @@ -3893,9 +3893,11 @@ modify_call_for_omp_dispatch (tree expr, tree dispatch_clauses, if (!fndecl) return expr; + tree init_code = NULL_TREE; + tree cleanup = NULL_TREE; + tree clobbers = NULL_TREE; int nargs = call_expr_nargs (expr); tree dispatch_device_num = NULL_TREE; - tree dispatch_device_num_init = NULL_TREE; tree dispatch_interop = NULL_TREE; tree dispatch_append_args = NULL_TREE; int nfirst_args = 0; @@ -3956,14 +3958,6 @@ modify_call_for_omp_dispatch (tree expr, tree dispatch_clauses, "the % clause must be present if the % " "clause has more than one list item"); } -
[gcc/devel/omp/gcc-14] Add 'libgomp.c++/pr96835-1{, -O0}.C', 'libgomp.oacc-c++/pr96835-1.C' [PR96835]
https://gcc.gnu.org/g:b6cc32a175fe52b354e34b9cf638bd4716f71242 commit b6cc32a175fe52b354e34b9cf638bd4716f71242 Author: Thomas Schwinge Date: Tue Oct 8 09:59:45 2024 +0200 Add 'libgomp.c++/pr96835-1{,-O0}.C', 'libgomp.oacc-c++/pr96835-1.C' [PR96835] PR libgomp/96835 libgomp/ * testsuite/libgomp.c++/pr96835-1.C: New. * testsuite/libgomp.c++/pr96835-1-O0.C: Likewise. * testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise. (cherry picked from commit 332a08173a7cbec43a8fdd2b5b29e086dd7e6ffd) Diff: --- libgomp/ChangeLog.omp | 8 + libgomp/testsuite/libgomp.c++/pr96835-1-O0.C | 3 ++ libgomp/testsuite/libgomp.c++/pr96835-1.C | 45 ++ libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C | 6 4 files changed, 62 insertions(+) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 14d7e562edb8..d8881985f2be 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,13 @@ 2025-03-25 Thomas Schwinge + Backported from trunk: + 2025-03-24 Thomas Schwinge + + PR libgomp/96835 + * testsuite/libgomp.c++/pr96835-1.C: New. + * testsuite/libgomp.c++/pr96835-1-O0.C: Likewise. + * testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise. + Backported from trunk: 2025-03-24 Thomas Schwinge diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C b/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C new file mode 100644 index ..85e42909e29f --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C @@ -0,0 +1,3 @@ +// { dg-additional-options -O0 } + +#include "pr96835-1.C" diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1.C b/libgomp/testsuite/libgomp.c++/pr96835-1.C new file mode 100644 index ..c9f6475eeb91 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr96835-1.C @@ -0,0 +1,45 @@ +// See also '../libgomp.oacc-c++/pr96835-1.C'. +#ifndef ALWAYS_INLINE +# define ALWAYS_INLINE +#endif + +#pragma omp declare target + +template +struct vector { + int values_[sz]; + vector(); + ALWAYS_INLINE + vector(int const& init_val); + ALWAYS_INLINE + int dot(vector o) { +int res = 0; +for (int i = 0; i < sz; ++ i) + res += values_[i] * o.values_[i]; +return res; + } +}; + +template +vector::vector(int const& init_val) { + for (int i = 0; i < sz; ++ i) values_[i] = init_val; +} +template +vector::vector() : vector(0) { +} + +#pragma omp end declare target + +int main() { + int res = 0; + #pragma omp target map(from:res) + #pragma acc serial copyout(res) + { +vector<4> v1(1); +vector<4> v2(2); +res = v1.dot(v2); + } + if (res != 8) +__builtin_abort(); + return 0; +} diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C b/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C new file mode 100644 index ..0a6ee22ec3c9 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C @@ -0,0 +1,6 @@ +// { dg-additional-options -fno-inline } for stable results regarding OpenACC 'routine'. +// But actually, as none of the '#pragma acc routine' syntax is accepted (see '../libgomp.c++/pr101544-1.C'), force inlining: +#define ALWAYS_INLINE inline __attribute__((always_inline)) + +#include "../libgomp.c++/pr96835-1.C" +//TODO { dg-prune-output {using 'vector_length \(32\)', ignoring 1} }
[gcc/devel/omp/gcc-14] C++: Adjust implicit '__cxa_bad_cast' prototype to reality
https://gcc.gnu.org/g:609157f0b7b3948dbb8e3a720ec4c7c06d1172a7 commit 609157f0b7b3948dbb8e3a720ec4c7c06d1172a7 Author: Thomas Schwinge Date: Wed Mar 19 12:18:26 2025 +0100 C++: Adjust implicit '__cxa_bad_cast' prototype to reality In 2001 Subversion r40924 (Git commit 52a11cbfcf0cfb32628b6953588b6af4037ac0b6) "IA-64 ABI Exception Handling", '__cxa_bad_cast' changed from 'void *' to 'void' return type: --- libstdc++-v3/libsupc++/exception_support.cc +++ /dev/null @@ -1,388 +0,0 @@ -[...] -// Helpers for rtti. Although these don't return, we give them return types so -// that the type system is not broken. -extern "C" void * -__cxa_bad_cast () -{ - [...] -} -[...] --- /dev/null +++ libstdc++-v3/libsupc++/unwind-cxx.h @@ -0,0 +1,163 @@ +[...] +extern "C" void __cxa_bad_cast (); +[...] --- /dev/null +++ libstdc++-v3/libsupc++/eh_aux_runtime.cc @@ -0,0 +1,56 @@ +[...] +extern "C" void +__cxa_bad_cast () +{ + [...] +} +[...] The implicit prototype in the C++ front end however wasn't likewise adjusted, and so for nvptx we generate code for 'void *' return type: // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast .extern .func (.param .u64 %value_out) __cxa_bad_cast; { .param .u64 %value_in; call (%value_in),__cxa_bad_cast; trap; // (noreturn) exit; // (noreturn) ld.param.u64 %r30,[%value_in]; } ..., which is in conflict with the library code with 'void' return type: // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast .visible .func __cxa_bad_cast; // BEGIN GLOBAL FUNCTION DEF: __cxa_bad_cast .visible .func __cxa_bad_cast { [...] } ..., and we thus get execution test FAIL for 'g++.dg/rtti/dyncast2.C': error : Prototype doesn't match for '__cxa_bad_cast' in 'input file 7 at offset 51437', first defined in 'input file 7 at offset 51437' nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300) With this patched, we get the expected: // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast -.extern .func (.param .u64 %value_out) __cxa_bad_cast; +.extern .func __cxa_bad_cast; { -.param .u64 %value_in; -call (%value_in),__cxa_bad_cast; +call __cxa_bad_cast; trap; // (noreturn) exit; // (noreturn) -ld.param.u64 %r30,[%value_in]; } ..., and execution test PASS. gcc/cp/ * rtti.cc (throw_bad_cast): Adjust implicit '__cxa_bad_cast' prototype to reality. (cherry picked from commit 618c42d23726be6e2086d452d6718abe5e0daca8) Diff: --- gcc/cp/ChangeLog.omp | 8 gcc/cp/rtti.cc | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index bf08763e2183..ed923563941f 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,3 +1,11 @@ +2025-03-25 Thomas Schwinge + + Backported from trunk: + 2025-03-21 Thomas Schwinge + + * rtti.cc (throw_bad_cast): Adjust implicit '__cxa_bad_cast' + prototype to reality. + 2025-03-21 Paul-Antoine Arras Backported from master: diff --git a/gcc/cp/rtti.cc b/gcc/cp/rtti.cc index ed69606f4ddc..e07cc01fd0ba 100644 --- a/gcc/cp/rtti.cc +++ b/gcc/cp/rtti.cc @@ -186,7 +186,7 @@ build_headof (tree exp) /* Get a bad_cast node for the program to throw... - See libstdc++/exception.cc for __throw_bad_cast */ + See 'libstdc++-v3/libsupc++/eh_aux_runtime.cc' for '__cxa_bad_cast'. */ static tree throw_bad_cast (void) @@ -198,7 +198,7 @@ throw_bad_cast (void) fn = get_global_binding (name); if (!fn) fn = push_throw_library_fn - (name, build_function_type_list (ptr_type_node, NULL_TREE)); + (name, build_function_type_list (void_type_node, NULL_TREE)); } return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
[gcc r15-8878] tailc: Only diagnose musttail failures during tailc or musttail passes [PR119376]
https://gcc.gnu.org/g:698e337bec3a36230c72816fcb82f1a239e64eba commit r15-8878-g698e337bec3a36230c72816fcb82f1a239e64eba Author: Jakub Jelinek Date: Tue Mar 25 09:36:41 2025 +0100 tailc: Only diagnose musttail failures during tailc or musttail passes [PR119376] The following testcases FAIL because musttail failures are diagnosed not just in the tailc or musttail passes, but also during the tailr1 and tailr2. tailr1 pass is before IPA and in the testcases eh cleanup has not cleaned up the IL sufficiently yet to make the musttail calls pass, even tailr2 could be too early. The following patch does that only during the tailc pass, and if that pass is not actually executed, during musttail pass. To do it only in the tailc pass, I chose to pass a new bool flag, because while we have the opt_tailcalls argument, it is actually passed by reference to find_tail_calls and sometimes cleared during that. musttail calls when the new DIAG_MUSTTAIL flag is not set are handled like any other calls, we simply silently punt on those if they can't be turned into tail calls. Furthermore, I had to tweak the musttail pass gate. Previously it was !flag_optimize_sibling_calls && f->has_musttail. The problem is that gate of tailr and tailc passes is flag_optimize_sibling_calls != 0 && dbg_cnt (tail_call) and furthermore, tailc pass is only in the normal optimization queue, so only if not -O0 or -Og. So when one would use tail_call dbg_cnt with some limit, or when e.g. using -foptimize-sibling-calls with -O0 or -Og, nothing would actually diagnose invalid musttail calls or set tail call flags on those if they are ok. I could insert a new PROP_ flag on whether musttail has been handled by tailc pass, but given that we have the cfun->has_musttail flag already and nothing after tailc/musttail passes uses it, I think it is easier to just clear the flag when musttail failures are diagnosed and correct ones have [[tail call]] flag added. Expansion will then only look at the [[tail call]] flag, it could even at the [[must tail call]] flag, but I don't see a point to check cfun->has_musttail. 2025-03-25 Jakub Jelinek PR ipa/119376 * tree-tailcall.cc (suitable_for_tail_opt_p): Add DIAG_MUSTTAIL argument, propagate it down to maybe_error_musttail. (suitable_for_tail_call_opt_p): Likewise. (maybe_error_musttail): Add DIAG_MUSTTAIL argument. Don't emit error for gimple_call_must_tail_p calls if it is false. (find_tail_calls): Add DIAG_MUSTTAIL argument, propagate it down to maybe_error_musttail, suitable_for_tail_opt_p, suitable_for_tail_call_opt_p and find_tail_calls calls. (tree_optimize_tail_calls_1): Add DIAG_MUSTTAIL argument, propagate it down to find_tail_calls and if set, clear cfun->has_musttail flag at the end. Rename OPT_MUSTCALL argument to OPT_MUSTTAIL. (execute_tail_calls): Pass true to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. (pass_tail_recursion::execute): Pass false to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. (pass_musttail::gate): Don't test flag_optimize_sibling_calls. (pass_musttail::execute): Pass true to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. * g++.dg/torture/musttail1.C: New test. * g++.dg/opt/musttail2.C: New test. Diff: --- gcc/testsuite/g++.dg/opt/musttail2.C | 14 + gcc/testsuite/g++.dg/torture/musttail1.C | 15 + gcc/tree-tailcall.cc | 97 +++- 3 files changed, 87 insertions(+), 39 deletions(-) diff --git a/gcc/testsuite/g++.dg/opt/musttail2.C b/gcc/testsuite/g++.dg/opt/musttail2.C new file mode 100644 index ..ee55c1a18df1 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/musttail2.C @@ -0,0 +1,14 @@ +// PR ipa/119376 +// { dg-do compile { target musttail } } +// { dg-options "-O2 -fno-early-inlining -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } + +struct S { S () {} }; +char *foo (S); + +char * +bar (S) +{ + S t; + [[clang::musttail]] return foo (t); +} diff --git a/gcc/testsuite/g++.dg/torture/musttail1.C b/gcc/testsuite/g++.dg/torture/musttail1.C new file mode 100644 index ..12012ad22074 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/musttail1.C @@ -0,0 +1,15 @@ +// PR ipa/119376 +// { dg-do compile { target musttail } } +// { dg-additional-options "-ffat-lto-objects -fdump-tree-optimized" } +/* { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */ + +struct S { int s; }; +int foo (int)
[gcc r14-11445] c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504]
https://gcc.gnu.org/g:f078a613bf85eff138c2567b599779dee6ae4b22 commit r14-11445-gf078a613bf85eff138c2567b599779dee6ae4b22 Author: Simon Martin Date: Tue Mar 25 07:08:16 2025 +0100 c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504] We have been miscompiling the following valid code since GCC8, and r8-3497-g281e6c1d8f1b4c === cut here === struct span { span (const int (&__first)[1]) : _M_ptr (__first) {} int operator[] (long __i) { return _M_ptr[__i]; } const int *_M_ptr; }; void foo () { constexpr int a_vec[]{1}; auto vec{[&a_vec]() -> span { return a_vec; }()}; } === cut here === The problem is that perform_implicit_conversion_flags (via mark_rvalue_use) replaces "a_vec" in the return statement by a CONSTRUCTOR representing a_vec's constant value, and then takes its address when invoking span's constructor. So we end up with an instance that points to garbage instead of a_vec's storage. As per Jason's suggestion, this patch simply removes the calls to mark_*_use from perform_implicit_conversion_flags, which fixes the PR. PR c++/117504 gcc/cp/ChangeLog: * call.cc (perform_implicit_conversion_flags): Don't call mark_{l,r}value_use. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-117504.C: New test. * g++.dg/cpp2a/constexpr-117504a.C: New test. (cherry picked from commit fdf846fdddcc0467b9f025757f081c5d54319d08) Diff: --- gcc/cp/call.cc | 5 --- gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C | 60 ++ gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C | 12 ++ 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index f580c3f5442f..180afa6d053d 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13663,11 +13663,6 @@ perform_implicit_conversion_flags (tree type, tree expr, conversion *conv; location_t loc = cp_expr_loc_or_input_loc (expr); - if (TYPE_REF_P (type)) -expr = mark_lvalue_use (expr); - else -expr = mark_rvalue_use (expr); - if (error_operand_p (expr)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C new file mode 100644 index ..290d3dfd61e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504.C @@ -0,0 +1,60 @@ +// PR c++/117504 - Initial report +// { dg-do "run" { target c++20 } } + +struct span { + span (const int (&__first)[1]) : _M_ptr (__first) {} + int operator[] (long __i) { return _M_ptr[__i]; } + const int *_M_ptr; +}; + +constexpr int a_global_vec[]{1}; +span myFunctor() { + return a_global_vec; +} + +int main() { + constexpr int a_vec[]{1}; + + // + // This PR's case, that used to be miscompiled. + // + auto lambda_1 = [&a_vec] () -> span { return a_vec; }; + auto vec_1 { lambda_1 () }; + if (vec_1[0] != 1) +__builtin_abort (); + + // Variant that used to be miscompiled as well. + auto lambda_2 = [&] () -> span { return a_vec; }; + auto vec_2 { lambda_2 () }; + if (vec_2[0] != 1) +__builtin_abort (); + + // + // Related cases that worked already. + // + auto lambda_3 = [&a_vec] () /* -> span */ { return a_vec; }; + auto vec_3 { lambda_3 () }; + if (vec_3[0] != 1) +__builtin_abort (); + + auto lambda_4 = [&] () /* -> span */ { return a_vec; }; + auto vec_4 { lambda_4 () }; + if (vec_4[0] != 1) +__builtin_abort (); + + const int (&vec_5)[1] = a_vec; + if (vec_5[0] != 1) +__builtin_abort (); + + span vec_6 (a_vec); + if (vec_6[0] != 1) +__builtin_abort (); + + auto vec_7 = myFunctor (); + if (vec_7[0] != 1) +__builtin_abort (); + + const int (&vec_8)[1] { a_vec }; + if (vec_8[0] != 1) +__builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C new file mode 100644 index ..f6d4dc8cbc53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-117504a.C @@ -0,0 +1,12 @@ +// PR c++/117504 - ICE discovered by ppalka@ when reducing. +// { dg-do "compile" { target c++20 } } + +struct span { + span (const int* __first) : _M_ptr (__first) {} + int operator[] (long __i) { return _M_ptr[__i]; } + const int *_M_ptr; +}; +int main() { + constexpr int a_vec[]{1}; + auto vec { [&a_vec]() -> span { return a_vec; } () }; +}
[gcc r15-8879] libstdc++: Fix handling of common cpp20-only ranges for flat sets [PR119415]
https://gcc.gnu.org/g:4d1b19695669e6c67b9c3df07673bc22cae3a662 commit r15-8879-g4d1b19695669e6c67b9c3df07673bc22cae3a662 Author: Tomasz Kamiński Date: Mon Mar 24 18:04:28 2025 +0100 libstdc++: Fix handling of common cpp20-only ranges for flat sets [PR119415] These patch add check to verify if common range iterators satisfies Cpp17LegacyIterator requirements (__detail::__cpp17_input_iterator), before invoking overloads of insert that accepts two iterators. As such overloads existed before c++20 iterators were introduced, they commonly assume existence of iterator_traits<..>::iterator_category, and passing a cpp20-only iterators, leads to hard errors. In case if user-defined container wants to support more efficient insertion in such cases, it should provided insert_range method, as in the case of standard containers. PR libstdc++/119415 libstdc++-v3/ChangeLog: * include/std/flat_set (_Flat_set_impl:insert_range): Add __detail::__cpp17_input_iterator check. * testsuite/23_containers/flat_multiset/1.cc: New tests * testsuite/23_containers/flat_set/1.cc: New tests Reviewed-by: Patrick Palka , Jonathan Wakely Signed-off-by: Tomasz Kamiński Diff: --- libstdc++-v3/include/std/flat_set | 3 ++- .../testsuite/23_containers/flat_multiset/1.cc | 27 ++ libstdc++-v3/testsuite/23_containers/flat_set/1.cc | 27 ++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/flat_set b/libstdc++-v3/include/std/flat_set index 9240f2b9a2eb..bab56742ddd6 100644 --- a/libstdc++-v3/include/std/flat_set +++ b/libstdc++-v3/include/std/flat_set @@ -480,7 +480,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename container_type::iterator __it; if constexpr (requires { _M_cont.insert_range(_M_cont.end(), __rg); }) __it = _M_cont.insert_range(_M_cont.end(), __rg); - else if constexpr (ranges::common_range<_Rg>) + else if constexpr (ranges::common_range<_Rg> +&& __detail::__cpp17_input_iterator>) __it = _M_cont.insert(_M_cont.end(), ranges::begin(__rg), ranges::end(__rg)); else { diff --git a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc index 910f5dca5be4..cc31164315ae 100644 --- a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc +++ b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc @@ -143,6 +143,32 @@ test06() VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) ); } +template +struct NoInsertRange : std::vector +{ + using std::vector::vector; + + template + void insert_range(typename std::vector::const_iterator, R&&) = delete; +}; + +void test07() +{ +#ifdef __SIZEOF_INT128__ + // PR libstdc++/119415 - flat_foo::insert_range cannot handle common ranges + // on c++20 only iterators + auto r = std::views::iota(__int128(1), __int128(6)); + + std::flat_multiset s; + s.insert_range(r); + VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) ); + + std::flat_multiset, NoInsertRange> s2; + s2.insert_range(r); + VERIFY( std::ranges::equal(s2, (int[]){1, 2, 3, 4, 5}) ); +#endif +} + int main() { @@ -153,4 +179,5 @@ main() test04(); test05(); test06(); + test07(); } diff --git a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc index f0eaac936bf6..16881d788fcd 100644 --- a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc +++ b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc @@ -158,6 +158,32 @@ test06() VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) ); } +template +struct NoInsertRange : std::vector +{ + using std::vector::vector; + + template + void insert_range(typename std::vector::const_iterator, R&&) = delete; +}; + +void test07() +{ +#ifdef __SIZEOF_INT128__ + // PR libstdc++/119415 - flat_foo::insert_range cannot handle common ranges + // on c++20 only iterators + auto r = std::views::iota(__int128(1), __int128(6)); + + std::flat_set s; + s.insert_range(r); + VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) ); + + std::flat_set, NoInsertRange> s2; + s2.insert_range(r); + VERIFY( std::ranges::equal(s2, (int[]){1, 2, 3, 4, 5}) ); +#endif +} + int main() { @@ -168,4 +194,5 @@ main() test04(); test05(); test06(); + test07(); }
[gcc r15-8883] libstdc++: Add testcase for std::filesystem::copy [PR118699]
https://gcc.gnu.org/g:466da4baba46608882d16d121fa46d33f841bc7b commit r15-8883-g466da4baba46608882d16d121fa46d33f841bc7b Author: Jonathan Wakely Date: Thu Jan 30 17:02:47 2025 + libstdc++: Add testcase for std::filesystem::copy [PR118699] This was fixed last year by r15-2409-g017e3f89b081e4 (and backports), so just add the testcase. libstdc++-v3/ChangeLog: PR libstdc++/118699 * testsuite/27_io/filesystem/operations/copy.cc: Check copying a file to a directory. Diff: --- .../testsuite/27_io/filesystem/operations/copy.cc | 18 ++ 1 file changed, 18 insertions(+) diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc index c302d9ad2a0c..289bef6160bf 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc @@ -228,6 +228,23 @@ test_pr99290() remove_all(dir); } +void +test_pr118699() +{ + auto dir = __gnu_test::nonexistent_path(); + fs::create_directories(dir/"a"); + fs::create_directories(dir/"c"); + std::ofstream{dir/"a/b.txt"} << "b"; + std::ofstream{dir/"a/bb.txt"} << "bb"; + + fs::copy(dir/"a/b.txt", dir/"c"); + auto ec = make_error_code(std::errc::invalid_argument); + fs::copy(dir/"a/bb.txt", dir/"c", ec); + VERIFY( !ec ); + + remove_all(dir); +} + int main() { @@ -237,4 +254,5 @@ main() test04(); test05(); test_pr99290(); + test_pr118699(); }