]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 months agoOpenMP: Require target and/or targetsync init modifier [PR118965]
Sandra Loosemore [Mon, 31 Mar 2025 22:02:35 +0000 (22:02 +0000)] 
OpenMP: Require target and/or targetsync init modifier [PR118965]

As noted in PR 118965, the initial interop implementation overlooked
the requirement in the OpenMP spec that at least one of the "target"
and "targetsync" modifiers is required in both the interop construct
init clause and the declare variant append_args clause.

Adding the check was fairly straightforward, but it broke about a
gazillion existing test cases.  In particular, things like "init (x, y)"
which were previously accepted (and tested for being accepted) aren't
supposed to be allowed by the spec, much less things like "init (target)"
where target was previously interpreted as a variable name instead of a
modifier.  Since one of the effects of the change is that at least one
modifier is always required, I found that deleting all the code that was
trying to detect and handle the no-modifier case allowed for better
diagnostics.

gcc/c/ChangeLog
PR middle-end/118965
* c-parser.cc (c_parser_omp_clause_init_modifiers): Adjust
error message.
(c_parser_omp_clause_init): Remove code for recognizing clauses
without modifiers.  Diagnose missing target/targetsync modifier.
(c_finish_omp_declare_variant): Diagnose missing target/targetsync
modifier.

gcc/cp/ChangeLog
PR middle-end/118965
* parser.cc (c_parser_omp_clause_init_modifiers): Adjust
error message.
(cp_parser_omp_clause_init): Remove code for recognizing clauses
without modifiers.  Diagnose missing target/targetsync modifier.
(cp_finish_omp_declare_variant): Diagnose missing target/targetsync
modifier.

gcc/fortran/ChangeLog
PR middle-end/118965
* openmp.cc (gfc_parser_omp_clause_init_modifiers): Fix some
inconsistent code indentation.  Remove code for recognizing
clauses without modifiers.  Diagnose prefer_type without a
following paren.  Adjust error message for an unrecognized modifier.
Diagnose missing target/targetsync modifier.
(gfc_match_omp_init): Fix more inconsistent code indentation.

gcc/testsuite/ChangeLog
PR middle-end/118965
* c-c++-common/gomp/append-args-1.c: Add target/targetsync
modifiers so tests do what they were previously supposed to do.
Adjust expected output.
* c-c++-common/gomp/append-args-7.c: Likewise.
* c-c++-common/gomp/append-args-8.c: Likewise.
* c-c++-common/gomp/append-args-9.c: Likewise.
* c-c++-common/gomp/interop-1.c: Likewise.
* c-c++-common/gomp/interop-2.c: Likewise.
* c-c++-common/gomp/interop-3.c: Likewise.
* c-c++-common/gomp/interop-4.c: Likewise.
* c-c++-common/gomp/pr118965-1.c: New.
* c-c++-common/gomp/pr118965-2.c: New.
* g++.dg/gomp/append-args-1.C: Add target/targetsync modifiers
and adjust expected output.
* g++.dg/gomp/append-args-2.C: Likewise.
* g++.dg/gomp/append-args-6.C: Likewise.
* g++.dg/gomp/append-args-7.C: Likewise.
* g++.dg/gomp/append-args-8.C: Likewise.
* g++.dg/gomp/interop-5.C: Likewise.
* gfortran.dg/gomp/append_args-1.f90: Add target/targetsync
modifiers and adjust expected output.
* gfortran.dg/gomp/append_args-2.f90: Likewise.
* gfortran.dg/gomp/append_args-3.f90: Likewise.
* gfortran.dg/gomp/append_args-4.f90: Likewise.
* gfortran.dg/gomp/interop-1.f90: Likewise.
* gfortran.dg/gomp/interop-2.f90: Likewise.
* gfortran.dg/gomp/interop-3.f90: Likewise.
* gfortran.dg/gomp/interop-4.f90: Likewise.
* gfortran.dg/gomp/pr118965-1.f90: New.
* gfortran.dg/gomp/pr118965-2.f90: New.

(cherry picked from commit aca8155c09001f269a20d6df438fa0e749dd5388)

7 months agoGCN: Don't emit weak undefined symbols [PR119369]
Thomas Schwinge [Mon, 31 Mar 2025 07:55:14 +0000 (09:55 +0200)] 
GCN: Don't emit weak undefined symbols [PR119369]

This resolves all instances of PR119369
"GCN: weak undefined symbols -> execution test FAIL, 'HSA_STATUS_ERROR_VARIABLE_UNDEFINED'";
for all affected test cases, the execution test status progresses FAIL -> PASS.

This however also causes a small number of (expected) regressions, very similar
to GCC/nvptx:

    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++26 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++11 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++26 (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++17  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++26  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++26 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++98  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} gcc.dg/attr-weakref-1.c (test for excess errors)
    [-FAIL:-]{+UNRESOLVED:+} gcc.dg/attr-weakref-1.c [-execution test-]{+compilation failed to produce executable+}

    @@ -131211,25 +131211,25 @@ PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?c
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?d
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?e
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?g
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?j
    PASS: gcc.dg/weak/weak-1.c scan-assembler-not weak[^ \t]*[ \t]_?i

    PASS: gcc.dg/weak/weak-12.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-12.c scan-assembler weak[^ \t]*[ \t]_?foo

    PASS: gcc.dg/weak/weak-15.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?d
    PASS: gcc.dg/weak/weak-15.c scan-assembler-not weak[^ \t]*[ \t]_?b

    PASS: gcc.dg/weak/weak-16.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_index
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_table
    PASS: gcc.dg/weak/weak-2.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e
    PASS: gcc.dg/weak/weak-2.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d

    PASS: gcc.dg/weak/weak-3.c  (test for warnings, line 58)
    PASS: gcc.dg/weak/weak-3.c  (test for warnings, line 73)
    PASS: gcc.dg/weak/weak-3.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e
    PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1f
    PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1g
    PASS: gcc.dg/weak/weak-3.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d

    PASS: gcc.dg/weak/weak-4.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f
    @@ -131267,16 +131267,16 @@ PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k

    PASS: gcc.dg/weak/weak-5.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1g
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1h
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1l

These get 'dg-xfail-if'ed or 'dg-skip-if'ed, (mostly) similar to GCC/nvptx.

PR target/119369
gcc/
* config/gcn/gcn-protos.h (gcn_asm_weaken_decl): Declare.
* config/gcn/gcn.cc (gcn_asm_weaken_decl): New.
* config/gcn/gcn-hsa.h (ASM_WEAKEN_DECL): '#define' to this.
gcc/testsuite/
* g++.dg/abi/pure-virtual1.C: 'dg-xfail-if' GCN.
* g++.dg/cpp0x/pr84497.C: 'dg-skip-if' GCN.
* g++.dg/ext/weak2.C: Likewise.
* gcc.dg/attr-weakref-1.c: Likewise.
* gcc.dg/weak/weak-1.c: Likewise.
* gcc.dg/weak/weak-12.c: Likewise.
* gcc.dg/weak/weak-15.c: Likewise.
* gcc.dg/weak/weak-16.c: Likewise.
* gcc.dg/weak/weak-2.c: Likewise.
* gcc.dg/weak/weak-3.c: Likewise.
* gcc.dg/weak/weak-4.c: Likewise.
* gcc.dg/weak/weak-5.c: Likewise.

(cherry picked from commit 2f58d8ac03911063d6a8887a2bee7b4e25ac1871)

7 months agoGCN, libstdc++: '#define _GLIBCXX_USE_WEAK_REF 0' [PR119369]
Thomas Schwinge [Sun, 30 Mar 2025 12:54:01 +0000 (14:54 +0200)] 
GCN, libstdc++: '#define _GLIBCXX_USE_WEAK_REF 0' [PR119369]

This fixes a few hundreds of compilation/linking FAILs (similar to PR69506),
where the GCN/LLVM 'ld' reported:

    ld: error: relocation R_AMDGPU_REL32_LO cannot be used against symbol '_ZGTtnam'; recompile with -fPIC
    >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o)
    >>> referenced by cow-stdexcept.cc:259 ([...]/libstdc++-v3/src/c++11/cow-stdexcept.cc:259)
    >>>               cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a

    ld: error: relocation R_AMDGPU_REL32_HI cannot be used against symbol '_ZGTtnam'; recompile with -fPIC
    >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o)
    >>> referenced by cow-stdexcept.cc:259 ([...]/source-gcc/libstdc++-v3/src/c++11/cow-stdexcept.cc:259)
    >>>               cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a

    [...]

..., which is:

    $ c++filt _ZGTtnam
    transaction clone for operator new[](unsigned long)

..., and similarly for other libitm symbols.

However, the affected test cases, if applicable, then run into execution test
FAILs, due to PR119369
"GCN: weak undefined symbols -> execution test FAIL, 'HSA_STATUS_ERROR_VARIABLE_UNDEFINED'".

PR target/119369
libstdc++-v3/
* config/cpu/gcn/cpu_defines.h: New.
* configure.host [GCN] (cpu_defines_dir): Point to it.

(cherry picked from commit 816335960d020eac92d49bc9cd13729afd313da7)

7 months agoFix PR testsuite/116271, gcc.dg/vect/tsvc/vect-tsvc-s176.c fails
Joern Rennecke [Wed, 28 Aug 2024 00:46:25 +0000 (01:46 +0100)] 
Fix PR testsuite/116271, gcc.dg/vect/tsvc/vect-tsvc-s176.c fails

gcc/testsuite:
PR testsuite/116271
* gcc.dg/vect/tsvc/vect-tsvc-s176.c [TRUNCATE_TEST]: Make sure
that m stays the same as the loop bound of the middle loop.
* gcc.dg/vect/tsvc/tsvc.h (get_expected_result) <s176> [TRUNCATE_TEST]:
Adjust expected value.

(cherry picked from commit beb94f5979953969593a2387561cdbc8fedfaeb1)

7 months agoReduce iteration counts for gcc.dg/vect/tsvc tests.
Joern Rennecke [Mon, 22 Jul 2024 10:02:16 +0000 (11:02 +0100)] 
Reduce iteration counts for gcc.dg/vect/tsvc tests.

testsuite/
* gcc.dg/vect/tsvc/tsvc.h (iterations): Allow to override,
default to 10.
(get_expected_result): Add values for iterations counts
10, 256 and 3200.
(run): Add code to output values for new iterations counts.
* gcc.dg/vect/tsvc/vect-tsvc-s1119.c (dg-additional-options):
Add -Diterations=LEN_2D .
* gcc.dg/vect/tsvc/vect-tsvc-s115.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s119.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s125.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s2102.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s2233.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s2275.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s231.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s235.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s176.c: (dg-additional-options):
Add -Diterations=3200 .
[!run_expensive_tests]: dg-additional-options "-DTRUNCATE_TEST" .
[TRUNCATE_TEST]: Set m to 32.

(cherry picked from commit 8fac69a2dbff98ebe1feb87faba0d9b81a173c40)

7 months agoOpenMP: Reorder diagnostic in modify_call_for_omp_dispatch [PR119559]
Tobias Burnus [Tue, 1 Apr 2025 08:29:27 +0000 (10:29 +0200)] 
OpenMP: Reorder diagnostic in modify_call_for_omp_dispatch [PR119559]

gcc/ChangeLog:

PR middle-end/119559
* gimplify.cc (modify_call_for_omp_dispatch): Reorder checks to avoid
asserts and bogus diagnostic.

(cherry picked from commit de92ac6f11e605987421fe1443b5b81ff172dbb6)

7 months agoOpenMP: modify_call_for_omp_dispatch - fix invalid memory access after 'error' [PR119541]
Tobias Burnus [Mon, 31 Mar 2025 09:44:26 +0000 (11:44 +0200)] 
OpenMP: modify_call_for_omp_dispatch - fix invalid memory access after 'error' [PR119541]

OpenMP requires that the number of dispatch 'interop' clauses (ninterop)
is less or equal to the number of declare variant 'append_args' interop
objects (nappend).

While 'nappend < ninterop' was diagnosed as error, the processing continues,
which lead to an invalid out-of-bounds memory access. Solution: only
process the first nappend 'interop' clauses.

gcc/ChangeLog:

PR middle-end/119541
* gimplify.cc (modify_call_for_omp_dispatch): Limit interop claues
processing by the number of append_args arguments.

(cherry picked from commit f3899e0fd3f9aa6b579a21e87b50c61ea5c448df)

7 months agoOpenACC: array reductions bug fixes
Chung-Lin Tang [Sun, 30 Mar 2025 21:04:45 +0000 (21:04 +0000)] 
OpenACC: array reductions bug fixes

This is a merge of the v4 to v5 diff patch from:
https://gcc.gnu.org/pipermail/gcc-patches/2025-March/679682.html

This patch fixes issues found for NVPTX sm_70 testing, and another issue
related to copying to reduction buffer for worker/vector mode.

gcc/ChangeLog:

* config/gcn/gcn-tree.cc (gcn_goacc_reduction_setup): Fix array case
copy source into reduction buffer.
* config/nvptx/nvptx.cc (nvptx_expand_shared_addr): Move default size
init setting place.
(enum nvptx_builtins): Add NVPTX_BUILTIN_BAR_WARPSYNC.
(nvptx_init_builtins): Add DEF() of nvptx_builtin_bar_warpsync.
(nvptx_expand_builtin): Expand NVPTX_BUILTIN_BAR_WARPSYNC.
(nvptx_goacc_reduction_setup): Fix array case copy source into reduction
buffer.
(nvptx_goacc_reduction_fini): Add bar.warpsync for at end of vector-mode
reductions for sm_70 and above.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-2.c: Adjust test.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-4.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-5.c: Likewise.

7 months agogcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree
Tobias Burnus [Sun, 30 Mar 2025 07:55:29 +0000 (09:55 +0200)] 
gcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree

gcc/testsuite/ChangeLog:

* g++.dg/gomp/append-args-8.C: Remove bogus '3' after \.\[0-9\]+
pattern.

(cherry picked from commit e0886d8ad4c51919c349d0b31f2bec3acbc79e14)

7 months agoMerge commit '8a624a127990aee47d02b3d64892f8de9031975e' into HEAD
Thomas Schwinge [Fri, 28 Mar 2025 11:56:07 +0000 (12:56 +0100)] 
Merge commit '8a624a127990aee47d02b3d64892f8de9031975e' into HEAD

7 months agoOpenMP: Fix C++ template handling with append_args' prefer_type modifier
Tobias Burnus [Thu, 27 Mar 2025 13:09:20 +0000 (14:09 +0100)] 
OpenMP: Fix C++ template handling with append_args' prefer_type modifier

It is possible but not very sensible to use C++ templates with in the
prefer_type modifier to the 'append_args' clause of 'declare variant'.

The commit r15-6336-g12dd892b1a3ad7 added substitution support in pt.cc,
but missed to update afterward the actual data in decl.cc.
As gimplification support was only added in r15-8898-gf016ee89955ab4,
this could not be tested back then. The latter commit added a sorry
for it gimplify.cc and the existing testcase, which this commit now removes.

gcc/cp/ChangeLog:

* cp-tree.h (cp_finish_omp_init_prefer_type): Add.
* decl.cc (omp_declare_variant_finalize_one): Call it.
* pt.cc (tsubst_attribute): Minor rebustification for OpenMP
append_args handling.
* semantics.cc (cp_omp_init_prefer_type_update): Rename to ...
(cp_finish_omp_init_prefer_type): ... this; remove static attribute
and return modified tree. Move clause handling to ...
(finish_omp_clauses): ... the caller.

gcc/ChangeLog:

* gimplify.cc (modify_call_for_omp_dispatch): Remove sorry.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/append-args-1.C: Remove expected dg-sorry.
* g++.dg/gomp/append-args-8.C: New test.

(cherry picked from commit 7e286b56545e1bd28098cc197e674d02f3849ec3)

7 months agotestsuite: Fix up append-args-interop.f90 test
Jakub Jelinek [Wed, 26 Mar 2025 13:41:15 +0000 (14:41 +0100)] 
testsuite: Fix up append-args-interop.f90 test

The gcc/testsuite/*/gomp/ tests aren't compiled with include or module
paths pointing to libgomp, so shouldn't be using omp.h nor use omp_lib
etc.

The following patch adjusts the test to define it locally, like
e.g. recently in interop-5.f90 test or many other tests which have
their own definitions of types or enumerators they need.

2025-03-26  Jakub Jelinek  <jakub@redhat.com>

* gfortran.dg/gomp/append-args-interop.f90: Don't use omp_lib,
instead use iso_c_binding and define omp_interop_kind parameter
locally.

(cherry picked from commit d402a3911d5eeb4680397458aa31dad4c3f5136e)

7 months agoOpenMP: Fix declaration in append-args-interop.c test case
Sandra Loosemore [Thu, 27 Mar 2025 00:59:37 +0000 (00:59 +0000)] 
OpenMP: Fix declaration in append-args-interop.c test case

I ran into this while backporting my declare variant/dispatch/interop
patch f016ee89955ab4da5fe7ef89368e9437bb5ffb13 to the og14 development
branch.  In C dialects prior to C23 (the default on mainline),
functions declared "float f()" and "float g(void)" aren't considered
equivalent for the purpose of the C front end code that checks whether
a type of a variant matches the base function after accounting for the
added interop arguments.  Using "(void)" instead of "()" works in all
C dialects as well as C++, so do that.

gcc/testsuite/ChangeLog
* c-c++-common/gomp/append-args-interop.c: Fix declaration of base
function to be correct for pre-C23 dialects.

(cherry picked from commit 876a521a198130bac638d682444e908b331c1185)

7 months agoOpenMP: Create additional interop objects with append_args
Sandra Loosemore [Wed, 26 Mar 2025 21:09:36 +0000 (21:09 +0000)] 
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.

This is a backport of commit f016ee89955ab4da5fe7ef89368e9437bb5ffb13 from
mainline.

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.
(gimplify_variant_call_expr): Re-work want_value/pointerize logic
and adjust the calls to modify_call_for_omp_dispatch.

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 <tburnus@baylibre.com>
7 months agodriver: Forward '-lstdc++' to offloading compilation [PR101544]
Thomas Schwinge [Tue, 19 Jul 2022 13:42:17 +0000 (15:42 +0200)] 
driver: Forward '-lstdc++' to offloading compilation [PR101544]

..., so that users don't manually need to specify '-foffload-options=-lstdc++'
in addition to '-lstdc++' (specified manually, or implicitly by the driver).
Do like commit 4bcb46b3ade1796c5a57b294f5cca25f00671cac
"driver: Forward '-lgfortran', '-lm' to offloading compilation".

PR driver/101544
gcc/
* gcc.cc (driver_handle_option): Forward host '-lstdc++' to
offloading compilation.
* config/gcn/mkoffload.cc (main): Adjust.
* config/nvptx/mkoffload.cc (main): Likewise.
libgomp/
* testsuite/libgomp.c++/pr101544-1-O0.C: Remove
'-foffload-options=-lstdc++'.
* testsuite/libgomp.c++/pr101544-1.C: Likewise.
* testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise.

(cherry picked from commit 3b36e96b575b493a21510c877b273608113108ed)

7 months agoC++: Adjust implicit '__cxa_bad_typeid' prototype to reality
Thomas Schwinge [Wed, 19 Mar 2025 11:18:26 +0000 (12:18 +0100)] 
C++: Adjust implicit '__cxa_bad_typeid' prototype to reality

In 2001 Subversion r40924 (Git commit 52a11cbfcf0cfb32628b6953588b6af4037ac0b6)
"IA-64 ABI Exception Handling", '__cxa_bad_typeid' changed from
'std::type_info const &' 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" std::type_info const &
    -__cxa_bad_typeid ()
    -{
    -  [...]
    -}
    -[...]

    --- /dev/null
    +++ libstdc++-v3/libsupc++/unwind-cxx.h
    @@ -0,0 +1,163 @@
    +[...]
    +extern "C" void __cxa_bad_typeid ();
    +[...]

    --- /dev/null
    +++ libstdc++-v3/libsupc++/eh_aux_runtime.cc
    @@ -0,0 +1,56 @@
    +[...]
    +extern "C" void
    +__cxa_bad_typeid ()
    +{
    +  [...]
    +}

The implicit prototype in the C++ front end however wasn't likewise adjusted,
and so for nvptx we generate code for 'std::type_info const &' return type:

    // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_typeid
    .extern .func (.param .u64 %value_out) __cxa_bad_typeid;

    {
    .param .u64 %value_in;
    call (%value_in),__cxa_bad_typeid;
    trap;
    // (noreturn)
    exit;
    // (noreturn)
    ld.param.u64 %r39,[%value_in];
    }

..., which is in conflict with the library code with 'void' return type:

    // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_typeid
    .visible .func __cxa_bad_typeid;

    // BEGIN GLOBAL FUNCTION DEF: __cxa_bad_typeid
    .visible .func __cxa_bad_typeid
    {
    [...]
    }

..., and we thus get execution test FAILs for 'g++.dg/rtti/typeid11.C', for
example:

    error   : Prototype doesn't match for '__cxa_bad_typeid' in 'input file 4 at offset 22204', first defined in 'input file 4 at offset 22204'
    nvptx-run: cuLinkAddData failed: unknown error (CUDA_ERROR_UNKNOWN, 999)

With this patched, we get the expected:

     // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_typeid
    -.extern .func (.param .u64 %value_out) __cxa_bad_typeid;
    +.extern .func __cxa_bad_typeid;

     {
    -.param .u64 %value_in;
    -call (%value_in),__cxa_bad_typeid;
    +call __cxa_bad_typeid;
     trap;
     // (noreturn)
     exit;
     // (noreturn)
    -ld.param.u64 %r39,[%value_in];
     }

..., and execution test PASSes for a few test cases.

gcc/cp/
* rtti.cc (throw_bad_typeid): Adjust implicit '__cxa_bad_typeid'
prototype to reality.  Adjust all users.

Co-authored-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit bf1aca4a2a5b68ac731d2a0c966f335e7bc0df2c)

7 months agoOpenMP: interop - fix Fortran test
Paul-Antoine Arras [Mon, 24 Mar 2025 14:53:36 +0000 (15:53 +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)

7 months agolibgomp: Save OpenMP device number when initializing the interop object
Tobias Burnus [Mon, 24 Mar 2025 18:52:10 +0000 (19:52 +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)

7 months agoMerge commit '10041f146132993c328e3112e33e33c08f90ae06' into HEAD
Thomas Schwinge [Tue, 25 Mar 2025 08:16:05 +0000 (09:16 +0100)] 
Merge commit '10041f146132993c328e3112e33e33c08f90ae06' into HEAD

7 months agoAdd 'libgomp.c++/pr96835-1{,-O0}.C', 'libgomp.oacc-c++/pr96835-1.C' [PR96835]
Thomas Schwinge [Tue, 8 Oct 2024 07:59:45 +0000 (09:59 +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)

7 months agoAdd 'libgomp.c++/pr101544-1{,-O0}.C', 'libgomp.oacc-c++/pr101544-1.C' [PR101544]
Thomas Schwinge [Tue, 12 Jul 2022 07:59:10 +0000 (09:59 +0200)] 
Add 'libgomp.c++/pr101544-1{,-O0}.C', 'libgomp.oacc-c++/pr101544-1.C' [PR101544]

PR target/101544
libgomp/
* testsuite/libgomp.c++/pr101544-1.C: New.
* testsuite/libgomp.c++/pr101544-1-O0.C: Likewise.
* testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise.

(cherry picked from commit 62312c778aaf7bc4b33d645188ec8a906fb5711b)

7 months agonvptx: In offloading compilation, special-case certain host-setup symbol aliases...
Thomas Schwinge [Thu, 20 Mar 2025 13:21:26 +0000 (14:21 +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)

7 months agonvptx: Default at least to '-mptx=6.3'
Thomas Schwinge [Thu, 20 Mar 2025 13:21:26 +0000 (14:21 +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)

7 months agoc++: fix return type of __cxa_bad_array_new_length
Jason Merrill [Thu, 20 Mar 2025 13:55:40 +0000 (09:55 -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)

7 months agoC++: Adjust implicit '__cxa_bad_cast' prototype to reality
Thomas Schwinge [Wed, 19 Mar 2025 11:18:26 +0000 (12:18 +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)

7 months agoAdd 'g++.target/nvptx/alias-g++.dg_init_dtor2-2.C'
Thomas Schwinge [Tue, 18 Mar 2025 15:18:54 +0000 (16:18 +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)

7 months agoAdd 'gcc.target/nvptx/alias-unsupported-1.c'
Thomas Schwinge [Tue, 18 Mar 2025 15:14:42 +0000 (16:14 +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)

7 months agolibgomp: Save OpenMP device number when initializing the interop object
Tobias Burnus [Mon, 24 Mar 2025 18:52:10 +0000 (19:52 +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)

7 months agolibgomp/plugin/plugin-nvptx.c: Fix device used for stream creation
Tobias Burnus [Mon, 24 Mar 2025 15:08:20 +0000 (16:08 +0100)] 
libgomp/plugin/plugin-nvptx.c: Fix device used for stream creation

libgomp/ChangeLog:

* plugin/plugin-nvptx.c (GOMP_OFFLOAD_interop): Set context for
stream creation to use the specified device.

(cherry picked from commit 1c5a375c21a262eb636449f88e671a09e140404e)

7 months agolibgomp.fortran/get-mapped-ptr-1.f90: Use -6 for non-conf dev number
Tobias Burnus [Fri, 21 Mar 2025 23:36:44 +0000 (00:36 +0100)] 
libgomp.fortran/get-mapped-ptr-1.f90: Use -6 for non-conf dev number

This is a fix for the GOMP_interop commit r15-8654-g99e2906ae255fc that
added GOMP_DEVICE_DEFAULT_OMP_61 alias omp_default_device, which is a
conforming device number. But that test used -5 as check for a
non-conforming device number.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/get-mapped-ptr-1.f90: Use -6
not -5 as non-conforming device number.

(cherry picked from commit c264df142a850b47135c0c4639d3a539b23149c5)

7 months agolibgomp/plugin: Add initial interop support to nvptx + gcn
Tobias Burnus [Fri, 21 Mar 2025 20:39:42 +0000 (21:39 +0100)] 
libgomp/plugin: Add initial interop support to nvptx + gcn

The interop directive operates on an opaque object that represents a
foreign runtime. This commit adds support for
this to the two offloading plugins.

For nvptx, it supports cuda, cuda_driver and hip; the latter is AMD's
version of CUDA which for Nvidia devices boils down to normal CUDA.
Thus, at the end for this limited use, cuda/cuda_driver/hip are all
the same - and for plugin-nvptx.c, the they differ only in terms of
what gets fr_id, fr_name and get_interop_type_desc return.

For gcn, it supports hip and hsa.

Regarding get-mapped-ptr-1.c: That's actually a fix for the
GOMP_interop commit r15-8654-g99e2906ae255fc that added
GOMP_DEVICE_DEFAULT_OMP_61 alias omp_default_device, which is
a conforming device number. But that test used -5 as check for a
non-conforming device number.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (_LIBGOMP_PLUGIN_INCLUDE): Define.
(struct hsa_runtime_fn_info): Add two queue functions.
(hipError_t, hipCtx_t, hipStream_s, hipStream_t): New types.
(struct hip_runtime_fn_info): New.
(hip_runtime_lib, hip_fns): New global vars.
(init_environment_variables): Handle hip_runtime_lib.
(init_hsa_runtime_functions): Load the two queue functions.
(init_hip_runtime_functions, GOMP_OFFLOAD_interop,
GOMP_OFFLOAD_get_interop_int, GOMP_OFFLOAD_get_interop_ptr,
GOMP_OFFLOAD_get_interop_str,
GOMP_OFFLOAD_get_interop_type_desc): New.
* plugin/plugin-nvptx.c (_LIBGOMP_PLUGIN_INCLUDE): Define.
(GOMP_OFFLOAD_interop, GOMP_OFFLOAD_get_interop_int,
GOMP_OFFLOAD_get_interop_ptr, GOMP_OFFLOAD_get_interop_str,
GOMP_OFFLOAD_get_interop_type_desc): New.
* testsuite/libgomp.c/interop-fr-1.c: New test.
* testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c: Use -6
not -5 as non-conforming device number.

(cherry picked from commit 41b9c3b848c8cbe9cb4b9d923c4e569767284e28)

7 months agoOpenMP: 'interop' construct - add ME support + target-independent libgomp
Paul-Antoine Arras [Thu, 13 Mar 2025 16:16:41 +0000 (17:16 +0100)] 
OpenMP: 'interop' construct - add ME support + target-independent libgomp

This patch partially enables use of the OpenMP interop construct by adding
middle end support, mostly in the omplower pass, and in the target-independent
part of the libgomp runtime. It follows up on previous patches for C, C++ and
Fortran front ends support. The full interop feature requires another patch to
enable foreign runtime support in libgomp plugins.

gcc/ChangeLog:

* builtin-types.def
(BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New.
* gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_INTEROP.
* gimple-pretty-print.cc (dump_gimple_omp_interop): New function.
(pp_gimple_stmt_1): Handle GIMPLE_OMP_INTEROP.
* gimple.cc (gimple_build_omp_interop): New function.
(gimple_copy): Handle GIMPLE_OMP_INTEROP.
* gimple.def (GIMPLE_OMP_INTEROP): Define.
* gimple.h (gimple_build_omp_interop): Declare.
(gimple_omp_interop_clauses): New function.
(gimple_omp_interop_clauses_ptr): Likewise.
(gimple_omp_interop_set_clauses): Likewise.
(gimple_return_set_retval): Handle GIMPLE_OMP_INTEROP.
* gimplify.cc (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_INIT,
OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
(gimplify_omp_interop): New function.
(gimplify_expr): Replace sorry with call to gimplify_omp_interop.
* omp-builtins.def (BUILT_IN_GOMP_INTEROP): Define.
* omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_INIT,
OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
(scan_omp_1_stmt): Handle GIMPLE_OMP_INTEROP.
(lower_omp_interop_action_clauses): New function.
(lower_omp_interop): Likewise.
(lower_omp_1): Handle GIMPLE_OMP_INTEROP.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_destroy): Make addressable.
(c_parser_omp_clause_init): Make addressable.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_clause_init): Make addressable.

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_trans_omp_clauses): Make OMP_CLAUSE_DESTROY and
OMP_CLAUSE_INIT addressable.
* types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR):
New.

include/ChangeLog:

* gomp-constants.h (GOMP_DEVICE_DEFAULT_OMP_61, GOMP_INTEROP_TARGET,
GOMP_INTEROP_TARGETSYNC, GOMP_INTEROP_FLAG_NOWAIT): Define.

libgomp/ChangeLog:

* icv-device.c (omp_set_default_device): Check
GOMP_DEVICE_DEFAULT_OMP_61.
* libgomp-plugin.h (struct interop_obj_t): New.
(enum gomp_interop_flag): New.
(GOMP_OFFLOAD_interop): Declare.
(GOMP_OFFLOAD_get_interop_int): Declare.
(GOMP_OFFLOAD_get_interop_ptr): Declare.
(GOMP_OFFLOAD_get_interop_str): Declare.
(GOMP_OFFLOAD_get_interop_type_desc): Declare.
* libgomp.h (_LIBGOMP_OMP_LOCK_DEFINED): Define.
(struct gomp_device_descr): Add interop_func, get_interop_int_func,
get_interop_ptr_func, get_interop_str_func, get_interop_type_desc_func.
* libgomp.map: Add GOMP_interop.
* libgomp_g.h (GOMP_interop): Declare.
* target.c (resolve_device): Handle GOMP_DEVICE_DEFAULT_OMP_61.
(omp_get_interop_int): Replace stub with actual implementation.
(omp_get_interop_ptr): Likewise.
(omp_get_interop_str): Likewise.
(omp_get_interop_type_desc): Likewise.
(struct interop_data_t): Define.
(gomp_interop_internal): New function.
(GOMP_interop): Likewise.
(gomp_load_plugin_for_device): Load symbols for get_interop_int,
get_interop_ptr, get_interop_str and get_interop_type_desc.
* testsuite/libgomp.c-c++-common/interop-1.c: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/interop-1.c: Remove dg-prune-output "sorry".
* c-c++-common/gomp/interop-2.c: Likewise.
* c-c++-common/gomp/interop-3.c: Likewise.
* c-c++-common/gomp/interop-4.c: Remove dg-message "not supported".
* g++.dg/gomp/interop-5.C: Likewise.
* gfortran.dg/gomp/interop-4.f90: Likewise.
* c-c++-common/gomp/interop-5.c: New test.
* gfortran.dg/gomp/interop-5.f90: New test.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
(cherry picked from commit 99e2906ae255fc7b8edb008d7cd47b28b078a809)

7 months agoipa: target clone and mangling alias [PR114992]
Jason Merrill [Thu, 20 Mar 2025 16:57:15 +0000 (12:57 -0400)] 
ipa: target clone and mangling alias [PR114992]

Since the mangling of the second lambda changed (previously we counted all
lambdas, now we only count lambdas with the same signature), we
generate_mangling_alias for handler<lambda2> for backward compatibility.
Since handler is COMDAT, resolve_alias puts the alias in the same comdat
group as handler itself.  Then create_dispatcher_calls tries to add the
alias to the same comdat group as the dispatcher, but it's already in a
same_comdat_group, so we ICE.

It seems like we're just missing a remove_from_same_comdat_group before
add_to_same_comdat_group.

PR c++/114992

gcc/ChangeLog:

* multiple_target.cc (create_dispatcher_calls):
remove_from_same_comdat_group before add_to_same_comdat_group.

gcc/testsuite/ChangeLog:

* g++.target/i386/mangling-alias1.C: New test.

(cherry picked from commit ab716829da7c885b97ac2649c7c0ff5c7703ffa5)

7 months agogimple: sccopy: Don't increment i after vec::unordered_remove()
Filip Kastl [Thu, 20 Mar 2025 10:54:59 +0000 (11:54 +0100)] 
gimple: sccopy: Don't increment i after vec::unordered_remove()

I increment the index variable in a loop even when I do
vec::unordered_remove() which causes the vector traversal to miss some
elements.  Mikael notified me of this mistake I made in my last patch.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Don't
increment after vec::unordered_remove().

Reported-by: Mikael Morin <mikael@gcc.gnu.org>
Signed-off-by: Filip Kastl <fkastl@suse.cz>
(cherry picked from commit a1363f8dd8037d40e9fbf04c2ba8d6d3e7e5c269)

7 months agolibstdc++: Correct statement about default -std option
Jonathan Wakely [Wed, 19 Mar 2025 23:27:24 +0000 (23:27 +0000)] 
libstdc++: Correct statement about default -std option

The default is -std=gnu++17 now, not -std=gnu++14.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Fix default for -std option.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit b93e60e7901526d7df2d8c0f5e0e46c57e8e3771)

7 months agolibstdc++: Fix comment typo
Jakub Jelinek [Thu, 20 Mar 2025 09:36:29 +0000 (10:36 +0100)] 
libstdc++: Fix comment typo

Another IEE typo.

2025-03-20  Jakub Jelinek  <jakub@redhat.com>

* testsuite/18_support/numeric_limits/traps.cc (main): Fix comment
typo.

(cherry picked from commit d458020e19b686e0d46320e7d26fa876c19965a0)

7 months agolibstdc++: Fix "IEE" typo in comment in std::time_put::do_put
Jonathan Wakely [Wed, 19 Mar 2025 23:26:10 +0000 (23:26 +0000)] 
libstdc++: Fix "IEE" typo in comment in std::time_put::do_put

libstdc++-v3/ChangeLog:

* include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix
typo in comment.

(cherry picked from commit b8e39b4c33ce74c243e467391f6cc0144d4a9477)

7 months agoDaily bump.
GCC Administrator [Fri, 21 Mar 2025 00:22:55 +0000 (00:22 +0000)] 
Daily bump.

7 months agoc++: Don't prune constant capture proxies only used in array dimensions [PR114292]
Simon Martin [Thu, 20 Mar 2025 19:36:26 +0000 (20:36 +0100)] 
c++: Don't prune constant capture proxies only used in array dimensions [PR114292]

We currently ICE upon the following valid (under -Wno-vla) code

=== cut here ===
void f(int c) {
  constexpr int r = 4;
  [&](auto) { int t[r * c]; }(0);
}
=== cut here ===

When parsing the lambda body, and more specifically the multiplication,
we mark the lambda as LAMBDA_EXPR_CAPTURE_OPTIMIZED, which indicates to
prune_lambda_captures that it might be possible to optimize out some
captures.

The problem is that prune_lambda_captures then misses the use of the r
capture (because neither walk_tree_1 nor cp_walk_subtrees walks the
dimensions of array types - here "r * c"), hence believes the capture
can be pruned... and we trip on an assert when instantiating the lambda.

This patch changes cp_walk_subtrees so that (1) when walking a
DECL_EXPR, it also walks the DECL's type, and (2) when walking an
INTEGER_TYPE and processing a template declaration, it also walks its
TYPE_{MIN,MAX}_VALUE.

PR c++/114292

gcc/cp/ChangeLog:

* tree.cc (cp_walk_subtrees): Walk the type of DECL_EXPR
declarations, as well as the TYPE_{MIN,MAX}_VALUE of
INTEGER_TYPEs for template declarations.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-ice4.C: New test.

7 months agod: Merge upstream dmd, druntime af92b68a81, phobos c970ca67f
Iain Buclaw [Thu, 20 Mar 2025 00:09:13 +0000 (01:09 +0100)] 
d: Merge upstream dmd, druntime af92b68a81, phobos c970ca67f

D front-end changes:

- Import dmd v2.108.1.

D runtime changes:

- Import druntime v2.108.1.

Phobos changes:

- Import phobos v2.108.1.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd af92b68a81.
* dmd/VERSION: Bump version to v2.108.1.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime af92b68a81.
* src/MERGE: Merge upstream phobos c970ca67f.

7 months agoDaily bump.
GCC Administrator [Thu, 20 Mar 2025 00:24:19 +0000 (00:24 +0000)] 
Daily bump.

7 months agoc++: mangling of array new [PR119316]
Jason Merrill [Wed, 19 Mar 2025 09:15:00 +0000 (05:15 -0400)] 
c++: mangling of array new [PR119316]

Because we build an array type to represent an array new, we hit a VLA
error in compute_array_index_type for a variable length array new.  To avoid
this, let's build the MINUS_EXPR and index type directly.

I also noticed that the non-constant case in write_array_type was assuming
MINUS_EXPR without verifying it, so I added a checking_assert.

I also noticed that Clang doesn't mangle the length of an array new at all,
so I opened https://github.com/itanium-cxx-abi/cxx-abi/issues/199 to clarify
this.

PR c++/119316

gcc/cp/ChangeLog:

* mangle.cc (write_expression) [NEW_EXPR]: Avoid using
compute_array_index_type.
(write_array_type): Add checking_assert.

gcc/testsuite/ChangeLog:

* g++.dg/abi/mangle-new1.C: New test.

(cherry picked from commit 80e1dac3849b134ebd5e0151e9c9e4b8b091de72)

7 months agoc++: memfn pointer as NTTP argument considered unused [PR119233]
Patrick Palka [Tue, 18 Mar 2025 15:38:33 +0000 (11:38 -0400)] 
c++: memfn pointer as NTTP argument considered unused [PR119233]

This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

PR c++/119233

gcc/cp/ChangeLog:

* pt.cc (mark_template_arguments_used): Also handle member
function pointers.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr5.C: New test.

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

7 months agoFix misoptimization at -O2 in LTO mode
Eric Botcazou [Wed, 19 Mar 2025 07:55:04 +0000 (08:55 +0100)] 
Fix misoptimization at -O2 in LTO mode

This is a regression in recent releases. The problem is that the IPA mod/ref
pass looks through the (nominal) type of a pointer-to-discriminated-type
parameter in a call to a subprogram in order to see the (actual) type used
for the dereferences of the parameter in the callee, which is a
pointer-to-constrained-subtype.

Historically the discriminated type is marked with the may_alias attribute
because of the symmetric effect for the argument in the caller, so we mark
the constrained subtype with the attribute now for the sake of the callee.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
the may_alias attribute if a specific GCC type is built.

7 months agoFix spurious visibility error with partially parameterized formal package
Eric Botcazou [Wed, 19 Mar 2025 07:22:33 +0000 (08:22 +0100)] 
Fix spurious visibility error with partially parameterized formal package

This is not a regression but the issue is quite annoying and the fix is
trivial.  The problem is that a formal parameter covered by a box in the
formal package is not visible in the instance when it comes after another
formal parameter that is also a formal package.

It comes from a discrepancy internal to Instantiate_Formal_Package, where
a specific construct (the abbreviated instance) built for the nested formal
package discombobulates the processing done for the outer formal package.

gcc/ada/
* gen_il-gen-gen_nodes.adb (N_Formal_Package_Declaration): Use
N_Declaration instead of Node_Kind as ancestor.
* sem_ch12.adb (Get_Formal_Entity): Remove obsolete alternative.
(Instantiate_Formal_Package): Take into account the abbreviated
instances in the main loop running over the actuals of the local
package created for the formal package.

gcc/testsuite/
* gnat.dg/generic_inst14.adb: New test.
* gnat.dg/generic_inst14_pkg.ads: New helper.
* gnat.dg/generic_inst14_pkg-child.ads: Likewise.

7 months agoDaily bump.
GCC Administrator [Wed, 19 Mar 2025 00:22:50 +0000 (00:22 +0000)] 
Daily bump.

7 months agoc++: constexpr ref template arg [PR119194]
Jason Merrill [Tue, 18 Mar 2025 18:44:08 +0000 (14:44 -0400)] 
c++: constexpr ref template arg [PR119194]

Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

PR c++/119194

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 145c90720640ec6711ed3e5aa4152bbe1ee21751)

7 months agoc++: ICE with ptr-to-member-fn [PR119344]
Marek Polacek [Mon, 17 Mar 2025 21:46:02 +0000 (17:46 -0400)] 
c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR<CAST_EXPR<>> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1)

7 months agoc++: ICE when substituting packs into type aliases [PR118104]
Marek Polacek [Mon, 17 Mar 2025 16:56:40 +0000 (12:56 -0400)] 
c++: ICE when substituting packs into type aliases [PR118104]

r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> <int, int>, Us -> <A, P...> }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

PR c++/118104

gcc/cp/ChangeLog:

* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

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

7 months agoc++: tweak for -Wrange-loop-construct [PR116731]
Marek Polacek [Tue, 17 Sep 2024 20:58:37 +0000 (16:58 -0400)] 
c++: tweak for -Wrange-loop-construct [PR116731]

This PR reports that the warning would be better off using a check
for trivially constructible rather than trivially copyable.

LLVM accepted a similar fix:
https://github.com/llvm/llvm-project/issues/47355

PR c++/116731

gcc/cp/ChangeLog:

* parser.cc (warn_for_range_copy): Check if TYPE is trivially
constructible, not copyable.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wrange-loop-construct3.C: New test.

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

7 months agoipa: target clone and mangling alias [PR114992]
Jason Merrill [Thu, 20 Mar 2025 16:57:15 +0000 (12:57 -0400)] 
ipa: target clone and mangling alias [PR114992]

Since the mangling of the second lambda changed (previously we counted all
lambdas, now we only count lambdas with the same signature), we
generate_mangling_alias for handler<lambda2> for backward compatibility.
Since handler is COMDAT, resolve_alias puts the alias in the same comdat
group as handler itself.  Then create_dispatcher_calls tries to add the
alias to the same comdat group as the dispatcher, but it's already in a
same_comdat_group, so we ICE.

It seems like we're just missing a remove_from_same_comdat_group before
add_to_same_comdat_group.

PR c++/114992

gcc/ChangeLog:

* multiple_target.cc (create_dispatcher_calls):
remove_from_same_comdat_group before add_to_same_comdat_group.

gcc/testsuite/ChangeLog:

* g++.target/i386/mangling-alias1.C: New test.

(cherry picked from commit ab716829da7c885b97ac2649c7c0ff5c7703ffa5)

7 months agogimple: sccopy: Don't increment i after vec::unordered_remove()
Filip Kastl [Thu, 20 Mar 2025 10:54:59 +0000 (11:54 +0100)] 
gimple: sccopy: Don't increment i after vec::unordered_remove()

I increment the index variable in a loop even when I do
vec::unordered_remove() which causes the vector traversal to miss some
elements.  Mikael notified me of this mistake I made in my last patch.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Don't
increment after vec::unordered_remove().

Reported-by: Mikael Morin <mikael@gcc.gnu.org>
Signed-off-by: Filip Kastl <fkastl@suse.cz>
(cherry picked from commit a1363f8dd8037d40e9fbf04c2ba8d6d3e7e5c269)

7 months agolibstdc++: Correct statement about default -std option
Jonathan Wakely [Wed, 19 Mar 2025 23:27:24 +0000 (23:27 +0000)] 
libstdc++: Correct statement about default -std option

The default is -std=gnu++17 now, not -std=gnu++14.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Fix default for -std option.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit b93e60e7901526d7df2d8c0f5e0e46c57e8e3771)

7 months agolibstdc++: Fix comment typo
Jakub Jelinek [Thu, 20 Mar 2025 09:36:29 +0000 (10:36 +0100)] 
libstdc++: Fix comment typo

Another IEE typo.

2025-03-20  Jakub Jelinek  <jakub@redhat.com>

* testsuite/18_support/numeric_limits/traps.cc (main): Fix comment
typo.

(cherry picked from commit d458020e19b686e0d46320e7d26fa876c19965a0)

7 months agolibstdc++: Fix "IEE" typo in comment in std::time_put::do_put
Jonathan Wakely [Wed, 19 Mar 2025 23:26:10 +0000 (23:26 +0000)] 
libstdc++: Fix "IEE" typo in comment in std::time_put::do_put

libstdc++-v3/ChangeLog:

* include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix
typo in comment.

(cherry picked from commit b8e39b4c33ce74c243e467391f6cc0144d4a9477)

7 months agoDaily bump.
GCC Administrator [Fri, 21 Mar 2025 00:22:55 +0000 (00:22 +0000)] 
Daily bump.

7 months agoc++: Don't prune constant capture proxies only used in array dimensions [PR114292]
Simon Martin [Thu, 20 Mar 2025 19:36:26 +0000 (20:36 +0100)] 
c++: Don't prune constant capture proxies only used in array dimensions [PR114292]

We currently ICE upon the following valid (under -Wno-vla) code

=== cut here ===
void f(int c) {
  constexpr int r = 4;
  [&](auto) { int t[r * c]; }(0);
}
=== cut here ===

When parsing the lambda body, and more specifically the multiplication,
we mark the lambda as LAMBDA_EXPR_CAPTURE_OPTIMIZED, which indicates to
prune_lambda_captures that it might be possible to optimize out some
captures.

The problem is that prune_lambda_captures then misses the use of the r
capture (because neither walk_tree_1 nor cp_walk_subtrees walks the
dimensions of array types - here "r * c"), hence believes the capture
can be pruned... and we trip on an assert when instantiating the lambda.

This patch changes cp_walk_subtrees so that (1) when walking a
DECL_EXPR, it also walks the DECL's type, and (2) when walking an
INTEGER_TYPE and processing a template declaration, it also walks its
TYPE_{MIN,MAX}_VALUE.

PR c++/114292

gcc/cp/ChangeLog:

* tree.cc (cp_walk_subtrees): Walk the type of DECL_EXPR
declarations, as well as the TYPE_{MIN,MAX}_VALUE of
INTEGER_TYPEs for template declarations.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-ice4.C: New test.

7 months agod: Merge upstream dmd, druntime af92b68a81, phobos c970ca67f
Iain Buclaw [Thu, 20 Mar 2025 00:09:13 +0000 (01:09 +0100)] 
d: Merge upstream dmd, druntime af92b68a81, phobos c970ca67f

D front-end changes:

- Import dmd v2.108.1.

D runtime changes:

- Import druntime v2.108.1.

Phobos changes:

- Import phobos v2.108.1.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd af92b68a81.
* dmd/VERSION: Bump version to v2.108.1.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime af92b68a81.
* src/MERGE: Merge upstream phobos c970ca67f.

7 months agoDaily bump.
GCC Administrator [Thu, 20 Mar 2025 00:24:19 +0000 (00:24 +0000)] 
Daily bump.

7 months agoc++: mangling of array new [PR119316]
Jason Merrill [Wed, 19 Mar 2025 09:15:00 +0000 (05:15 -0400)] 
c++: mangling of array new [PR119316]

Because we build an array type to represent an array new, we hit a VLA
error in compute_array_index_type for a variable length array new.  To avoid
this, let's build the MINUS_EXPR and index type directly.

I also noticed that the non-constant case in write_array_type was assuming
MINUS_EXPR without verifying it, so I added a checking_assert.

I also noticed that Clang doesn't mangle the length of an array new at all,
so I opened https://github.com/itanium-cxx-abi/cxx-abi/issues/199 to clarify
this.

PR c++/119316

gcc/cp/ChangeLog:

* mangle.cc (write_expression) [NEW_EXPR]: Avoid using
compute_array_index_type.
(write_array_type): Add checking_assert.

gcc/testsuite/ChangeLog:

* g++.dg/abi/mangle-new1.C: New test.

(cherry picked from commit 80e1dac3849b134ebd5e0151e9c9e4b8b091de72)

7 months agoc++: memfn pointer as NTTP argument considered unused [PR119233]
Patrick Palka [Tue, 18 Mar 2025 15:38:33 +0000 (11:38 -0400)] 
c++: memfn pointer as NTTP argument considered unused [PR119233]

This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

PR c++/119233

gcc/cp/ChangeLog:

* pt.cc (mark_template_arguments_used): Also handle member
function pointers.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr5.C: New test.

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

7 months agoMerge commit '0d5021e1d8ee8c943925ad23c305b6c84962e4b8' into HEAD
Thomas Schwinge [Wed, 19 Mar 2025 09:07:38 +0000 (10:07 +0100)] 
Merge commit '0d5021e1d8ee8c943925ad23c305b6c84962e4b8' into HEAD

7 months agoRevert "GCN, nvptx: Basic '__cxa_guard_{acquire,abort,release}' for C++ static local...
Thomas Schwinge [Sat, 23 Dec 2023 10:01:08 +0000 (11:01 +0100)] 
Revert "GCN, nvptx: Basic '__cxa_guard_{acquire,abort,release}' for C++ static local variables support"

GCN, nvptx now has libstdc++-v3/libsupc++ proper.

This reverts commit c0bf7ea189ecf252152fe15134f70f576bcd20b2.

(cherry picked from commit fad9d58e057e5f976cacdca90e2519ed5f0990ad)

7 months agoGCN, nvptx: Don't default-disable libstdc++ build
Thomas Schwinge [Mon, 11 Jul 2022 20:36:39 +0000 (22:36 +0200)] 
GCN, nvptx: Don't default-disable libstdc++ build

In addition to making libstdc++ itself available, this, via enabling
'build-gcc/*/libstdc++-v3/scripts/testsuite_flags', in particular also makes
the standard C++ headers available to 'make check-gcc-c++'.  With that, there
are a lot of FAIL/UNRESOLVED -> PASS progressions, where we previously ran
into, for example:

    FAIL: g++.dg/coroutines/co-await-syntax-00-needs-expr.C  (test for errors, line 6)
    FAIL: g++.dg/coroutines/co-await-syntax-00-needs-expr.C (test for excess errors)
    Excess errors:
    [...]/gcc/testsuite/g++.dg/coroutines/coro.h:132:10: fatal error: cstdlib: No such file or directory

Similarly, there are a lot of FAIL/UNRESOLVED -> UNSUPPORTED "progressions" due
to 'sorry, unimplemented: exception handling not supported'.

The 'make check-target-libstdc++-v3' results don't look too bad, either.

This also reverts Subversion r221362
(Git commit d94fae044da071381b73a2ee8afa874b14fa3820) "No libstdc++ for nvptx",
and commit 2f4f3c0e9345805160ecacd6de527b519a8c9206 "No libstdc++ for GCN".

With libstdc++ now available, libgrust gets enabled, which we in turn again
have to disable, for 'sorry, unimplemented: exception handling not supported'
reasons.

PR target/92713
PR target/101544
* configure.ac [GCN, nvptx] (noconfigdirs): Don't add
'target-libstdc++-v3'.  Add 'target-libgrust'.
* configure: Regenerate.
gcc/
* config/gcn/gcn.h (LIBSTDCXX): Don't set.
* config/nvptx/nvptx.h (LIBSTDCXX): Likewise.

(cherry picked from commit c650b557cb01f97bebb894aa68e5e74c2147c395)

7 months agoGCN, nvptx: Allow for "hosted" libstdc++ build
Thomas Schwinge [Thu, 20 Feb 2025 15:31:50 +0000 (16:31 +0100)] 
GCN, nvptx: Allow for "hosted" libstdc++ build

We need '-fno-exceptions', '-fno-rtti', disable generation of PCH files, and
for nvptx twiddle some more knobs.

PR target/92713
PR target/101544
libstdc++-v3/
* config/cpu/nvptx/cpu_defines.h: New.
* config/cpu/nvptx/t-nvptx: Likewise.
* configure.host: Handle GCN, nvptx.

(cherry picked from commit 1268924a2eed4e4f4cf1f43cc996b2f0eedeb07e)

7 months agolibstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS', 'EXTRA_CXX_FLAGS'
Thomas Schwinge [Wed, 26 Feb 2025 09:13:51 +0000 (10:13 +0100)] 
libstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS', 'EXTRA_CXX_FLAGS'

In particular, 'GLIBCXX_ENABLE_CXX_FLAGS' shouldn't overwrite 'EXTRA_CXX_FLAGS'
(and instead append any additional '--enable-cxx-flags=[...]').

libstdc++-v3/
* acinclude.m4 (GLIBCXX_ENABLE_CXX_FLAGS): Append to
'EXTRA_CXX_FLAGS' any additional flags.
* configure: Regenerate.
* configure.host: Document 'EXTRA_CFLAGS', 'EXTRA_CXX_FLAGS'.

(cherry picked from commit 5967fe0dd1f3a49176740553cd147e99d6950895)

7 months agoFix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X'...
Jonathan Wakely [Thu, 20 Feb 2025 14:08:11 +0000 (14:08 +0000)] 
Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X' configurations

libstdc++-v3/
* src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use
'__gnu_cxx::__mutex'.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
(cherry picked from commit 780932620d859fa9e0190edd0c408d0bedf9179e)

7 months agolibstdc++: Avoid '-Wunused-parameter' for 'is_directory' in member function 'bool...
Thomas Schwinge [Wed, 19 Feb 2025 19:18:52 +0000 (20:18 +0100)] 
libstdc++: Avoid '-Wunused-parameter' for 'is_directory' in member function 'bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const'

In a newlib configuration:

    ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc: In member function â€˜bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const’:
    ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:147:18: error: unused parameter â€˜is_directory’ [-Werror=unused-parameter]
      147 |   do_unlink(bool is_directory, error_code& ec) const noexcept
          |             ~~~~~^~~~~~~~~~~~

libstdc++-v3/
* src/c++17/fs_dir.cc (do_unlink): Tag 'is_directory' as
'[[maybe_unused]]'.

(cherry picked from commit b122afef2a584d15dbc594074bbe444c4fa74cb7)

7 months agolibstdc++: Avoid '-Wunused-parameter' for 'nofollow' in static member function 'stati...
Thomas Schwinge [Wed, 19 Feb 2025 19:15:30 +0000 (20:15 +0100)] 
libstdc++: Avoid '-Wunused-parameter' for 'nofollow' in static member function 'static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)'

In a newlib configuration:

    In file included from ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:37,
                     from ../../../../../source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc:26:
    ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h: In static member function â€˜static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)’:
    ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h:210:36: error: unused parameter â€˜nofollow’ [-Werror=unused-parameter]
      210 |   openat(const _At_path& atp, bool nofollow)
          |                               ~~~~~^~~~~~~~

libstdc++-v3/
* src/filesystem/dir-common.h (openat): Tag 'nofollow' as
'[[maybe_unused]]'.

(cherry picked from commit 5029c4bd330849fd6513b290d38bce853b320c5b)

7 months agolibstdc++: Avoid '-Wunused-parameter' for '__what' in function 'void std::__throw_for...
Thomas Schwinge [Wed, 19 Feb 2025 19:34:25 +0000 (20:34 +0100)] 
libstdc++: Avoid '-Wunused-parameter' for '__what' in function 'void std::__throw_format_error(const char*)'

In a '-fno-exceptions' configuration:

    In file included from ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc:29:
    [...]/build-gcc/[...]/libstdc++-v3/include/format: In function â€˜void std::__throw_format_error(const char*)’:
    [...]/build-gcc/[...]/libstdc++-v3/include/format:200:36: error: unused parameter â€˜__what’ [-Werror=unused-parameter]
      200 |   __throw_format_error(const char* __what)
          |                        ~~~~~~~~~~~~^~~~~~

libstdc++-v3/
* include/bits/c++config [!__cpp_exceptions]
(_GLIBCXX_THROW_OR_ABORT): Reference '_EXC'.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit d87c0d5443ba860dcbc6be24921e0ffb463cc96f)

7 months agoMove 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp' into 'gcc/testsuite/lib...
Thomas Schwinge [Wed, 5 Mar 2025 17:28:53 +0000 (18:28 +0100)] 
Move 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp' into 'gcc/testsuite/lib/target-supports-dg.exp'

This was added in commit f553b1aaa2b1b925c918e5dcf966290b045321c2
"Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'",
for use by 'gcc/testsuite/lib/target-supports.exp'.  The latter is used by
several test suites, 'gcc/testsuite/lib/gcc-dg.exp' however doesn't get loaded
for 'make check-target-libstdc++-v3', for example, and testing ERRORs out:

    ERROR: (DejaGnu) proc "find-dg-do-what" does not exist.
    The error code is TCL LOOKUP COMMAND find-dg-do-what
    The info on the error is:
    invalid command name "find-dg-do-what"
        while executing
    "::tcl_unknown find-dg-do-what"
        ("uplevel" body line 1)
        invoked from within
    "uplevel 1 ::tcl_unknown $args"

Fix this by moving 'find-dg-do-what' into the DejaGnu interfacing file
corresponding to 'gcc/testsuite/lib/target-supports.exp':
'gcc/testsuite/lib/target-supports-dg.exp' (next to other related procedures).

gcc/testsuite/
* lib/gcc-dg.exp (find-dg-do-what): Move...
* lib/target-supports-dg.exp: ... here.

(cherry picked from commit 6888a4bb584ad3977cb1e8cdefedea70b1f135ea)

7 months agoFix misoptimization at -O2 in LTO mode
Eric Botcazou [Wed, 19 Mar 2025 07:55:04 +0000 (08:55 +0100)] 
Fix misoptimization at -O2 in LTO mode

This is a regression in recent releases. The problem is that the IPA mod/ref
pass looks through the (nominal) type of a pointer-to-discriminated-type
parameter in a call to a subprogram in order to see the (actual) type used
for the dereferences of the parameter in the callee, which is a
pointer-to-constrained-subtype.

Historically the discriminated type is marked with the may_alias attribute
because of the symmetric effect for the argument in the caller, so we mark
the constrained subtype with the attribute now for the sake of the callee.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
the may_alias attribute if a specific GCC type is built.

7 months agoFix spurious visibility error with partially parameterized formal package
Eric Botcazou [Wed, 19 Mar 2025 07:22:33 +0000 (08:22 +0100)] 
Fix spurious visibility error with partially parameterized formal package

This is not a regression but the issue is quite annoying and the fix is
trivial.  The problem is that a formal parameter covered by a box in the
formal package is not visible in the instance when it comes after another
formal parameter that is also a formal package.

It comes from a discrepancy internal to Instantiate_Formal_Package, where
a specific construct (the abbreviated instance) built for the nested formal
package discombobulates the processing done for the outer formal package.

gcc/ada/
* gen_il-gen-gen_nodes.adb (N_Formal_Package_Declaration): Use
N_Declaration instead of Node_Kind as ancestor.
* sem_ch12.adb (Get_Formal_Entity): Remove obsolete alternative.
(Instantiate_Formal_Package): Take into account the abbreviated
instances in the main loop running over the actuals of the local
package created for the formal package.

gcc/testsuite/
* gnat.dg/generic_inst14.adb: New test.
* gnat.dg/generic_inst14_pkg.ads: New helper.
* gnat.dg/generic_inst14_pkg-child.ads: Likewise.

7 months agoDaily bump.
GCC Administrator [Wed, 19 Mar 2025 00:22:50 +0000 (00:22 +0000)] 
Daily bump.

7 months agoc++: constexpr ref template arg [PR119194]
Jason Merrill [Tue, 18 Mar 2025 18:44:08 +0000 (14:44 -0400)] 
c++: constexpr ref template arg [PR119194]

Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

PR c++/119194

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 145c90720640ec6711ed3e5aa4152bbe1ee21751)

7 months agoc++: ICE with ptr-to-member-fn [PR119344]
Marek Polacek [Mon, 17 Mar 2025 21:46:02 +0000 (17:46 -0400)] 
c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR<CAST_EXPR<>> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1)

7 months agoc++: ICE when substituting packs into type aliases [PR118104]
Marek Polacek [Mon, 17 Mar 2025 16:56:40 +0000 (12:56 -0400)] 
c++: ICE when substituting packs into type aliases [PR118104]

r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> <int, int>, Us -> <A, P...> }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

PR c++/118104

gcc/cp/ChangeLog:

* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

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

7 months agoc++: tweak for -Wrange-loop-construct [PR116731]
Marek Polacek [Tue, 17 Sep 2024 20:58:37 +0000 (16:58 -0400)] 
c++: tweak for -Wrange-loop-construct [PR116731]

This PR reports that the warning would be better off using a check
for trivially constructible rather than trivially copyable.

LLVM accepted a similar fix:
https://github.com/llvm/llvm-project/issues/47355

PR c++/116731

gcc/cp/ChangeLog:

* parser.cc (warn_for_range_copy): Check if TYPE is trivially
constructible, not copyable.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wrange-loop-construct3.C: New test.

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

7 months agoMerge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14
Tobias Burnus [Tue, 18 Mar 2025 18:43:23 +0000 (19:43 +0100)] 
Merge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14

Merge up to r14-11414-ga3c01af5e34801 (18th March 2025)

7 months agoMove gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ [PR115271]
Tobias Burnus [Mon, 17 Mar 2025 09:12:44 +0000 (10:12 +0100)] 
Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ [PR115271]

The test is a supposed to be a compile-only test but as dg-additional-sources
does not work with dg-compile (due to compiling with '-o'), dg-link had to
be used; as the code actually compiles (no diagnostic error), the linker
is actually invoked, which fails unless the system compiler by chance
provides the required files. Solution: move the test to libgomp.

PR fortran/115271

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-variant-mod-1-use.f90: Move to
libgomp/testsuite/libgomp.fortran/.
* gfortran.dg/gomp/declare-variant-mod-1.f90: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/declare-variant-mod-1-use.f90: Moved
from gcc/testsuite/gfortran.dg/gomp/.
* testsuite/libgomp.fortran/declare-variant-mod-1.f90: Likewise.

(cherry picked from commit 2d5c1e5149809f978ea2c07517de13fdbb925de6)

7 months agoFortran: Store OpenMP's 'declare variant' in module file [PR115271]
Tobias Burnus [Sat, 15 Mar 2025 07:28:11 +0000 (08:28 +0100)] 
Fortran: Store OpenMP's 'declare variant' in module file [PR115271]

Write the 'omp declare variant' data into the .mod file: Base function,
variant function(s), supporting the clauses match, append_args, and
adjust_args.

PR fortran/115271

gcc/fortran/ChangeLog:

* module.cc (mio_omp_declare_simd_clauses): New, moved from ...
(mio_omp_declare_simd): ... here. Update call, write empty '( )'
if there is no declare simd but a declare variant.
(mio_omp_declare_variant): New.
(mio_symbol): Call it.
* openmp.cc (gfc_match_omp_context_selector): Add comment about
module.cc to TODO note.
* trans-stmt.h (gfc_trans_omp_declare_variant): Take additional
parent_ns argument.
* trans-decl.cc (create_function_arglist,
gfc_create_function_decl): Update call.
* trans-openmp.cc (gfc_trans_omp_declare_variant): Take new
argument, add some special case handling for attr.use_assoc.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-variant-mod-1-use.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-1.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-2-use.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-2.f90: New test.

(cherry picked from commit 6f3bca0db8645c2556e5a01669af4384bb230d87)

7 months agoOpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579]
Sandra Loosemore [Tue, 11 Mar 2025 16:36:22 +0000 (16:36 +0000)] 
OpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579]

This patch is the C equivalent of commit r15-6512-gcf94ba812ca496 for C++,
to improve the location information for individual items in an OpenMP
variable list.

gcc/c/ChangeLog
PR c/118579
* c-parser.cc (c_parser_omp_variable_list): Capture location
information when KIND is OMP_CLAUSE_ERROR.
(c_parser_oacc_data_clause_deviceptr): Use the improved location
for diagnostics, and remove the FIXME.
(c_finish_omp_declare_variant): Likewise.
(c_parser_omp_threadprivate): Likewise.

gcc/testsuite/ChangeLog
PR c/118579
* c-c++-common/gomp/pr118579.c: New testcase.

(cherry picked from commit f74ed83e287dbaa20e9649df6cda631ee461ecf5)

7 months agolibstdc++: Fix constraint recursion in basic_const_iterator relops [PR112490]
Patrick Palka [Fri, 28 Feb 2025 14:39:57 +0000 (09:39 -0500)] 
libstdc++: Fix constraint recursion in basic_const_iterator relops [PR112490]

Here for

  using RCI = reverse_iterator<basic_const_iterator<vector<int>::iterator>>
  static_assert(std::totally_ordered<RCI>);

we effectively need to check the requirement

  requires (RCI x) { x RELOP x; }  for each RELOP in {<, >, <=, >=}

which we expect to be straightforwardly satisfied by reverse_iterator's
namespace-scope relops.  But due to ADL we find ourselves also
considering the basic_const_iterator relop friends, which before CWG
2369 would be quickly discarded since RCI clearly isn't convertible to
basic_const_iterator.  After CWG 2369 though we must first check these
relops' constraints (with _It = vector<int>::iterator and _It2 = RCI),
which entails checking totally_ordered<RCI> recursively.

This patch fixes this by turning the problematic non-dependent function
parameters of type basic_const_iterator<_It> into dependent ones of
type basic_const_iterator<_It3> where _It3 is constrained to match _It.
Thus the basic_const_iterator relop friends now get quickly discarded
during deduction and before the constraint check if the second operand
isn't a specialization of basic_const_iterator (or derived from one)
like before CWG 2369.

PR libstdc++/112490

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (basic_const_iterator::operator<):
Replace non-dependent basic_const_iterator function parameter with
a dependent one of type basic_const_iterator<_It3> where _It3
matches _It.
(basic_const_iterator::operator>): Likewise.
(basic_const_iterator::operator<=): Likewise.
(basic_const_iterator::operator>=): Likewise.
* testsuite/24_iterators/const_iterator/112490.cc: New test.

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

7 months agoDaily bump.
GCC Administrator [Tue, 18 Mar 2025 00:23:27 +0000 (00:23 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Mon, 17 Mar 2025 00:21:57 +0000 (00:21 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Sun, 16 Mar 2025 00:22:35 +0000 (00:22 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Sat, 15 Mar 2025 00:23:47 +0000 (00:23 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Fri, 14 Mar 2025 00:21:46 +0000 (00:21 +0000)] 
Daily bump.

7 months agoPlug small loophole in the pattern matching done by -fdump-ada-spec
Eric Botcazou [Thu, 13 Mar 2025 23:01:46 +0000 (00:01 +0100)] 
Plug small loophole in the pattern matching done by -fdump-ada-spec

gcc/c-family/
PR ada/119265
* c-ada-spec.cc (dump_ada_node) <INTEGER_TYPE>: Deal with typedefs
of unsigned __int128.

7 months agoOpenMP: Integrate dynamic selectors with dispatch argument handling [PR118457]
Sandra Loosemore [Thu, 13 Mar 2025 19:41:15 +0000 (19:41 +0000)] 
OpenMP: Integrate dynamic selectors with dispatch argument handling [PR118457]

Support for dynamic selectors in "declare variant" was developed in
parallel with support for the adjust_args/append_args clauses and the
dispatch construct; they collided in a bad way.  This patch fixes the
"sorry" for calls that need both by removing the adjust_args/append_args
code from gimplify_call_expr and invoking it from the new variant
substitution code instead.

This is a backport of commit 44b1d52e2f4db57849ca54b63c52a687294b1793
from mainline, done by hand instead of cherry-picking because of
differences in the dynamic selector code between OG14 and mainline.

gcc/ChangeLog
PR middle-end/118457
* gimplify.cc (modify_call_for_omp_dispatch): New, containing
code split from gimplify_call_expr and modified to emit tree
instead of gimple.  Remove the error for falling through to a call
to the base function.
(gimplify_variant_call_expr):  Add omp_dispatch_p argument and
call modify_call_for_omp_dispatch if needed.
(gimplify_call_expr): Adjust call to gimplify_variant_call_expr.
Move adjust_args/append_args code to modify_call_for_omp_dispatch.

gcc/testsuite/ChangeLog
PR middle-end/118457
* c-c++-common/gomp/adjust-args-6.c: New.
* c-c++-common/gomp/append-args-5.c: Adjust expected output.
* c-c++-common/gomp/append-args-dynamic.c: New.
* c-c++-common/gomp/dispatch-11.c: Adjust expected output.
* gfortran.dg/gomp/dispatch-11.f90: Likewise.

7 months agoDaily bump.
GCC Administrator [Thu, 13 Mar 2025 00:22:45 +0000 (00:22 +0000)] 
Daily bump.

7 months agoc++: ICE with aligned member and trivial assign op [PR117512]
Marek Polacek [Wed, 12 Mar 2025 18:49:53 +0000 (14:49 -0400)] 
c++: ICE with aligned member and trivial assign op [PR117512]

build_over_call has:

  t = build2 (MODIFY_EXPR, void_type_node,
      build2 (MEM_REF, array_type, arg0, alias_set),
      build2 (MEM_REF, array_type, arg, alias_set));
  val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);

which creates an expression that can look like:

  d = MEM <unsigned char[4]> [(struct A *)&TARGET_EXPR <D.2894, foo()]
    = MEM <unsigned char[4]> [(struct A *)(const struct A &) &e],
      TARGET_EXPR <D.2894, foo()>

that is, a COMPOUND_EXPR where a TARGET_EXPR is used twice, and its
address is taken in the left-hand side operand, so it can't be elided.
But set_target_expr_eliding simply recurses on the second operand of
a COMPOUND_EXPR and marks the TARGET_EXPR as eliding.  This then causes
a crash.

cp_build_indirect_ref_1 should not be changing the value category.
While *&TARGET_EXPR is an lvalue, folding it into TARGET_EXPR would
render is a prvalue of class type.

PR c++/117512

gcc/cp/ChangeLog:

* typeck.cc (cp_build_indirect_ref_1): Only do the *&e -> e
folding if the result would be an lvalue.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alignas23.C: New test.
* g++.dg/ext/align3.C: New test.
* g++.dg/ext/align4.C: New test.
* g++.dg/ext/align5.C: New test.

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

7 months agoc++: ICE with lambda in fold expression in requires [PR119134]
Marek Polacek [Fri, 7 Mar 2025 16:26:46 +0000 (11:26 -0500)] 
c++: ICE with lambda in fold expression in requires [PR119134]

The r12-8258 fix assumes that DECL_CONTEXT of 'pack' in
check_for_bare_parameter_packs is going to be an operator()
but as this test shows, it can be empty.

PR c++/119134

gcc/cp/ChangeLog:

* pt.cc (check_for_bare_parameter_packs): Check DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval24.C: New test.

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

7 months agoarm: testsuite: fix arm_neon_h checks with conflicting cpu/arch
Richard Earnshaw [Tue, 11 Mar 2025 10:48:54 +0000 (10:48 +0000)] 
arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch

GCC will complain if the -mcpu flag specifies a different architecture
to that specified in -march, but if the floating-point ABI is "soft",
then differences in the floating-point architecture features are
ignored.

However, the arm_libc_fp_abi checks whether we change the FP ABI by
adding -mfloat-abi=hard/softfp to override the defaults.  If that
fails it won't add anything.

Unfortunately arm_neon_h_ok wasn't correctly checking whether the libc
check had worked and just assumed that it would always add something
to enable FP.  That's insufficient and we need to consider this failure.
We simply mark tests as unsupported in this case.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_arm_neon_h_ok_nocache): Return zero if
check_effective_target_arm_libc_fp_abi_ok reports failure.

(cherry picked from commit 1b7a05770833eb210783ec8babd0027ec237d191)

7 months agoarm: testsuite: improve guard checks for arm_neon.h
Richard Earnshaw [Tue, 4 Mar 2025 16:17:32 +0000 (16:17 +0000)] 
arm: testsuite: improve guard checks for arm_neon.h

The header file arm_neon.h provides the Advanced SIMD intrinsics that
are available on armv7 or later A & R profile cores.  However, they
are not compatible with M-profile and we also need to ensure that the
FP instructions are enabled (with -mfloat-abi=softfp/hard).  That
leads to some complicated checking as arm_neon.h includes stdint.h
and, at least on linux, that can require that the appropriate ABI
bits/ headers are also installed.

This patch adds a new check to target-supports.exp to establish the
minimal set of option overrides needed to enable use of this header in
a test.

gcc/testsuite:
* lib/target-supports.exp
(check_effective_target_arm_neon_h_ok_nocache): New function.
(check_effective_target_arm_neon_h_ok): Likewise.
(add_options_for_arm_neon_h): Likewise.
(check_effective_target_arm_libc_fp_abi_ok_nocache): Allow any
Arm target, not just arm32.
* gcc.target/arm/attr-neon-builtin-fail.c: Use it.
* gcc.target/arm/attr-neon-builtin-fail2.c: Likewise.
* gcc.target/arm/attr-neon-fp16.c: Likewise.
* gcc.target/arm/attr-neon2.c: Likewise.

(cherry picked from commit b7f5d9114801716924a67ea393f0c30ab793e505)

7 months agoDaily bump.
GCC Administrator [Wed, 12 Mar 2025 00:23:02 +0000 (00:23 +0000)] 
Daily bump.

7 months agod: Fix regression returning from function with invariants [PR119139]
Iain Buclaw [Tue, 11 Mar 2025 16:56:18 +0000 (17:56 +0100)] 
d: Fix regression returning from function with invariants [PR119139]

An optimization was added in GDC-12 which sets the TREE_READONLY flag on
all local variables with the storage class `const' assigned.  For some
reason, const is also being added by the front-end to `__result'
variables in non-virtual functions, which ends up getting wrong code by
the gimplify pass promoting the local to static storage.

A bug has been raised upstream, as this looks like an error in the AST.
For now, turn off setting TREE_READONLY on all result variables.

PR d/119139

gcc/d/ChangeLog:

* decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result
declarations.

gcc/testsuite/ChangeLog:

* gdc.dg/pr119139.d: New test.

(cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3)

7 months agoDaily bump.
GCC Administrator [Tue, 11 Mar 2025 00:22:48 +0000 (00:22 +0000)] 
Daily bump.

7 months agolibphobos: Default to libc closefrom in spawnProcessPosix [PR119112]
Iain Buclaw [Mon, 10 Mar 2025 19:52:49 +0000 (20:52 +0100)] 
libphobos: Default to libc closefrom in spawnProcessPosix [PR119112]

This is a backport of two changes in upstream Phobos.

- The current implementation of spawnProcessPosix is broken on systems
with a large `ulimit -n' because it always OOMs making it impossible to
spawn processes. Using the libc implementation, when available, for
doing file descriptor operations en-mass solves this problem.

- The fallback code now reads the list of file descriptors in use from
/dev/fd or /proc/this/fd, avoiding the need to scroll through the entire
list of possible file descriptors. This fixes the fork process being
very slow and memory intensive when RLIMIT_NOFILE is too high.

PR d/119112

libphobos/ChangeLog:

* libdruntime/core/sys/freebsd/unistd.d (closefrom): Add binding.
* libdruntime/core/sys/linux/unistd.d (closefrom): Likewise.
* libdruntime/core/sys/openbsd/unistd.d (closefrom): Likewise.
* src/std/process.d (enum InternalError): Add closefds_dup2.
(spawnProcessPosix): Use closefrom when available.

Reviewed-on: https://github.com/dlang/phobos/pull/9048
Reviewed-on: https://github.com/dlang/phobos/pull/9077

7 months agoFortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
Paul Thomas [Mon, 27 Jan 2025 09:55:26 +0000 (09:55 +0000)] 
Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]

2025-01-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/118640
* resolve.cc (generate_component_assignments): Make sure that
the rhs temporary does not pick up the optional attribute from
the lhs.

gcc/testsuite/
PR fortran/118640
* gfortran.dg/pr118640.f90: New test.

(cherry picked from commit 3600b1ff14a459e84bb40bdfea7cd8d2ffd73d8d)