Andrew Stubbs [Fri, 28 Jun 2024 10:24:43 +0000 (10:24 +0000)]
openmp, nvptx: ompx_gnu_managed_mem_alloc
This adds support for using Cuda Managed Memory with omp_alloc. AMD support
will be added in a future patch.
There is one new predefined allocator, "ompx_gnu_managed_mem_alloc", plus a
corresponding memory space, which can be used to allocate memory in the
"managed" space.
The nvptx plugin is modified to make the necessary Cuda calls, via two new
(optional) plugin interfaces.
gcc/fortran/ChangeLog:
* openmp.cc (is_predefined_allocator): Use GOMP_OMP_PREDEF_ALLOC_MAX
and GOMP_OMPX_PREDEF_ALLOC_MIN/MAX instead of hardcoded values in the
comment.
include/ChangeLog:
* cuda/cuda.h (cuMemAllocManaged): Add declaration and related
CU_MEM_ATTACH_GLOBAL flag.
* gomp-constants.h (GOMP_OMPX_PREDEF_ALLOC_MAX): Update to 201.
(GOMP_OMP_PREDEF_MEMSPACE_MAX): New constant.
(GOMP_OMPX_PREDEF_MEMSPACE_MIN): New constant.
(GOMP_OMPX_PREDEF_MEMSPACE_MAX): New constant.
libgomp/ChangeLog:
* allocator.c (ompx_gnu_max_predefined_alloc): Update to
ompx_gnu_managed_mem_alloc.
(_Static_assert): Fix assertion messages for allocators and add
new assertions for memspace constants.
(omp_max_predefined_mem_space): New define.
(ompx_gnu_min_predefined_mem_space): New define.
(ompx_gnu_max_predefined_mem_space): New define.
(MEMSPACE_ALLOC): Add check for non-standard memspaces.
(MEMSPACE_CALLOC): Likewise.
(MEMSPACE_REALLOC): Likewise.
(MEMSPACE_VALIDATE): Likewise.
(predefined_ompx_gnu_alloc_mapping): Add ompx_gnu_managed_mem_space.
(omp_init_allocator): Add ompx_gnu_managed_mem_space validation.
* config/gcn/allocator.c (gcn_memspace_alloc): Add check for
non-standard memspaces.
(gcn_memspace_calloc): Likewise.
(gcn_memspace_realloc): Likewise.
(gcn_memspace_validate): Update to validate standard vs non-standard
memspaces.
* config/linux/allocator.c (linux_memspace_alloc): Add managed
memory space handling.
(linux_memspace_calloc): Likewise.
(linux_memspace_free): Likewise.
(linux_memspace_realloc): Likewise (returns NULL for fallback).
* config/nvptx/allocator.c (nvptx_memspace_alloc): Add check for
non-standard memspaces.
(nvptx_memspace_calloc): Likewise.
(nvptx_memspace_realloc): Likewise.
(nvptx_memspace_validate): Update to validate standard vs non-standard
memspaces.
* env.c (parse_allocator): Add ompx_gnu_managed_mem_alloc,
ompx_gnu_managed_mem_space, and some static asserts so I don't forget
them again.
* libgomp-plugin.h (GOMP_OFFLOAD_managed_alloc): New declaration.
(GOMP_OFFLOAD_managed_free): New declaration.
* libgomp.h (gomp_managed_alloc): New declaration.
(gomp_managed_free): New declaration.
(struct gomp_device_descr): Add managed_alloc_func and
managed_free_func fields.
* libgomp.texi: Document ompx_gnu_managed_mem_alloc and
ompx_gnu_managed_mem_space, add C++ template documentation, and
describe NVPTX and AMD support.
* omp.h.in: Add ompx_gnu_managed_mem_space and
ompx_gnu_managed_mem_alloc enumerators, and gnu_managed_mem C++
allocator template.
* omp_lib.f90.in: Add Fortran bindings for new allocator and
memory space.
* omp_lib.h.in: Likewise.
* plugin/cuda-lib.def: Add cuMemAllocManaged.
* plugin/plugin-nvptx.c (nvptx_alloc): Add managed parameter to
support cuMemAllocManaged.
(GOMP_OFFLOAD_alloc): Move contents to ...
(cleanup_and_alloc): ... this new function, and add managed support.
(GOMP_OFFLOAD_managed_alloc): New function.
(GOMP_OFFLOAD_managed_free): New function.
* target.c (gomp_managed_alloc): New function.
(gomp_managed_free): New function.
(gomp_load_plugin_for_device): Load optional managed_alloc
and managed_free plugin APIs.
* testsuite/lib/libgomp.exp: Add check_effective_target_omp_managedmem.
* testsuite/libgomp.c++/alloc-managed-1.C: New test.
* testsuite/libgomp.c/alloc-managed-1.c: New test.
* testsuite/libgomp.c/alloc-managed-2.c: New test.
* testsuite/libgomp.c/alloc-managed-3.c: New test.
* testsuite/libgomp.c/alloc-managed-4.c: New test.
* testsuite/libgomp.fortran/alloc-managed-1.f90: New test.
Co-authored-by: Kwok Cheung Yeung <kcyeung@baylibre.com> Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
gcc/fortran/gfortran.texi:1842: First argument to cross-reference may not be empty.
gcc/fortran/gfortran.texi:1903: First argument to cross-reference may not be empty.
gcc/fortran/intrinsic.texi:15549: Unknown command `cindex,'.
However, install.texi states that makeinfo >= 4.7 is required, so this
should work.
This patch fixes those errors.
Tested on x86_64-apple-darwin17.7.0 (makeinfo 4.8), i386-pc-solaris2.11
(makeinfo 7.2), and x86_64-pc-linux-gnu (makeinfo 7.1).
Filip Kastl [Thu, 13 Nov 2025 13:43:07 +0000 (14:43 +0100)]
contrib/check-params-in-docs.py: Compensate for r16-5132
r16-5132-g6786a073fcead3 added mention of the '=' variant of the
'--param' command line option to gcc/doc/invoke.texi. This confused
contrib/check-params-in-docs.py. Fix that.
Commiting as obvious.
contrib/ChangeLog:
* check-params-in-docs.py: Start parsing from
@itemx --param=@var{name}=@var{value} instead of
@item --param @var{name}=@var{value}.
Tomasz Kamiński [Fri, 7 Nov 2025 17:17:56 +0000 (18:17 +0100)]
libstdc++: Optimize handling of optional for views: take, drop, reverse and as_const.
This implements P3913R1: Optimize for std::optional in range adaptors.
Specifically, for an opt of type optional<T> that is a view:
* views::reverse(opt), views::take(opt, n), and views::drop(opt, n) returns
optional<T>.
* views::as_const(opt), optional<T&> is converted into optional<const T&>.
optional<T const> is not used in the non-reference case because, such
type is not move assignable, and thus not a view.
libstdc++-v3/ChangeLog:
* include/std/optional (__is_optional_ref): Define.
* include/std/ranges (_Take::operator(), _Drop::operator())
(_Reverse::operator()): Handle optional<T> that are view.
(_AsConst::operator()): Handle optional<T&>.
* testsuite/20_util/optional/range.cc: New tests.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Alice Carlotti [Mon, 10 Nov 2025 16:15:34 +0000 (16:15 +0000)]
aarch64: Extend syntax for cpuinfo feature string checks
Some SVE features in the toolchain need to be enabled when either of two
different kernel HWCAPS (and corresponding cpuinfo strings) are enabled
(one for non-streaming mode and one for streaming mode).
Add support for using "|" to separate alternative lists of required
features.
Tomasz Kamiński [Wed, 12 Nov 2025 10:16:58 +0000 (11:16 +0100)]
libtdc++: Test atomic_ref<volatile T> only if operations are lock-free [PR122584]
For non-templated tests, a volatile_<T> alias is used. This alias expands to
volatile T if std::atomic_ref<T>::is_always_lock_free is true, and to T
otherwise. For templated functions, testing is controlled using if constexpr.
PR libstdc++/115402
PR libstdc++/122584
libstdc++-v3/ChangeLog:
* testsuite/29_atomics/atomic_ref/address.cc: Guard test for
volatile with if constexpr.
* testsuite/29_atomics/atomic_ref/deduction.cc: Likewise.
* testsuite/29_atomics/atomic_ref/op_support.cc: Likewise.
* testsuite/29_atomics/atomic_ref/requirements.cc: Likewise.
* testsuite/29_atomics/atomic_ref/bool.cc: Use volatile_t alias.
* testsuite/29_atomics/atomic_ref/generic.cc: Likewise.
* testsuite/29_atomics/atomic_ref/integral.cc: Likewise.
* testsuite/29_atomics/atomic_ref/pointer.cc: Likewise.
* testsuite/29_atomics/atomic_ref/float.cc: Likewise, and remove
not discarding if constexpr.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Nathaniel Shead [Tue, 11 Nov 2025 06:13:46 +0000 (17:13 +1100)]
c++/modules: Maintain attachment of temploid friends after duplicate_decls [PR122551]
The ICE in the PR is because we're attempting to create a binding for an
imported declaration. This is problematic because if there are
duplicates we'll stream via a tt_entity, but won't enable deduplication
on the relevant binding vectors which can cause issues.
The root cause seems to stem from us forgetting that we've produced a
declaration for this entity within our own module, and so the active
declaration is not purely from an imported entity. We also didn't
properly track that this entity has unusual module attachment and
despite being declared here without being an instantiation actually is
attached to a different module than the current one (which may have
caused other problems down the line). This patch fixes both of these
issues.
PR c++/122551
gcc/cp/ChangeLog:
* cp-tree.h (transfer_defining_module): Declare.
* decl.cc (duplicate_decls): Call it for all decls.
Remove now unnecessary equivalent logic for templates.
* module.cc (mangle_module): Add assertion.
(transfer_defining_module): New function.
gcc/testsuite/ChangeLog:
* g++.dg/modules/tpl-friend-20_a.C: New test.
* g++.dg/modules/tpl-friend-20_b.C: New test.
* g++.dg/modules/tpl-friend-20_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Andre Vieira [Thu, 13 Nov 2025 10:46:56 +0000 (10:46 +0000)]
aarch64: Use eor3 for more double xor cases
Expands the use of eor3 where we'd otherwise use two vector eor's.
gcc/ChangeLog:
* config/aarch64/aarch64-simd.md (*eor3q<mode>4): New insn to be used by
combine after reload to optimize any grouping of eor's that are using FP
registers for scalar modes.
James K. Lowden [Wed, 12 Nov 2025 22:48:34 +0000 (17:48 -0500)]
cobol: Introduce vendor-compatibility layer as user-defined functions.
Install COBOL UDFs in a target directory that includes the GCC version
in its path, to permit side-by-side installation. Support compat
library with COBOL POSIX bindings; support those binding with C
functions in libgcobol as needed.
Changes to the compiler to support POSIX binding and testing.
Include developer conveniences -- Makefiles, bin/ and t/ directories --
to ensure UDFs compile and return reasonable results. These are
not installed and do not affect how libgcobol is built.
gcc/cobol/ChangeLog:
* cdf.y: Install literals in symbol table.
* genapi.cc (parser_alphabet): Use std::string for currency.
(initialize_the_data): Rely on constructor.
(parser_file_add): Better #pragma message.
(parser_exception_file): Return early if not generating code.
* parse.y: Allow library programs to act as functions.
* parse_ante.h (dialect_proscribed): Standardize message.
(intrinsic_call_2): Correct s/fund/func/ misspelling.
* scan.l: Comment.
* symbols.cc (symbols_update): Add unreachable assertion.
(symbol_field_parent_set): Reduce error to debug message.
(cdf_literalize): Declare.
(symbol_table_init): Insert CDF constants as literals.
* symbols.h (cbl_dialect_str): Provide string values for enum.
(is_working_storage): Remove function.
(struct cbl_field_data_t): Add manhandle_initial for Numeric Edited.
(struct cbl_field_t): Initialize name to zeros.
(struct cbl_section_t): Delete unused attr() function.
(symbol_unique_index): Declare.
* token_names.h: Regenerate.
* util.cc (cdf_literalize): Construct a cbl_field_t from a CDF literal.
(symbol_unique_index): Supply "globally" unique number for a program.
libgcobol/ChangeLog:
* Makefile.am: Move UDF-support to posix/shim, add install targets
* Makefile.in: Regenerate
* charmaps.cc (__gg__currency_signs): Use std::string.
* charmaps.h: Include string and vector headers.
(class charmap_t): Use std::string and vector for currency.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for libxml2.
* intrinsic.cc (numval_c): Constify.
* libgcobol.cc (struct program_state): Use std::string and vector.
(__gg__inspect_format_2): Add debug messages.
* libgcobol.h (__gg__get_default_currency_string): Constify.
* valconv.cc (expand_picture): Use std::string and vector.
(__gg__string_to_numeric_edited): Use std::string and vector.
(__gg__currency_sign_init): Use std::string and vector.
(__gg__currency_sign): Use std::string and vector.
* xmlparse.cc (xml_push_parse): Reformat.
* posix/stat.cc: Removed.
* posix/stat.h: Removed.
* .gitignore: New file.
* compat/README.md: New file.
* compat/lib/gnu/CBL_ALLOC_MEM.cbl: New file.
* compat/lib/gnu/CBL_CHECK_FILE_EXIST.cbl: New file.
* compat/lib/gnu/CBL_DELETE_FILE.cbl: New file.
* compat/lib/gnu/CBL_FREE_MEM.cbl: New file.
* compat/t/Makefile: New file.
* compat/t/smoke.cbl: New file.
* posix/README.md: New file.
* posix/bin/Makefile: New file for UDF-developer.
* posix/bin/headers: New file.
* posix/bin/scrape.awk: New file.
* posix/bin/sizeofs.c: New file.
* posix/bin/udf-gen: New file.
* posix/cpy/posix-errno.cbl: New file.
* posix/cpy/statbuf.cpy: New file.
* posix/cpy/tm.cpy: New file.
* posix/errno.cc: Removed.
* posix/localtime.cc: Removed.
* posix/shim/stat.cc: New file.
* posix/shim/stat.h: New file.
* posix/t/Makefile: New file.
* posix/t/errno.cbl: New file.
* posix/t/exit.cbl: New file.
* posix/t/localtime.cbl: New file.
* posix/t/stat.cbl: New file.
* posix/tm.h: Removed.
* posix/udf/posix-exit.cbl: New file.
* posix/udf/posix-localtime.cbl: New file.
* posix/udf/posix-mkdir.cbl: New file.
* posix/udf/posix-stat.cbl: New file.
* posix/udf/posix-unlink.cbl: New file.
David Malcolm [Wed, 12 Nov 2025 21:51:16 +0000 (16:51 -0500)]
EXPERIMENTAL_SARIF_SOCKET: decode errno when reporting errors [PR115970]
gcc/ChangeLog:
PR diagnostics/115970
* diagnostics/sarif-sink.cc (maybe_open_sarif_sink_for_socket):
Add "%m" to error messages, so that we print the string form of
errno.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Wed, 12 Nov 2025 21:51:16 +0000 (16:51 -0500)]
diagnostics: add class unique_fd
No functional change intended.
gcc/ChangeLog:
* diagnostics/sarif-sink.cc (class unique_fd): New.
(sarif_socket_sink::sarif_socket_sink): Convert "fd" arg and m_fd
from int to unique_fd.
(~sarif_socket_sink): Drop.
(sarif_socket_sink::dump_kind): Update for m_fd becoming a
unique_fd.
(sarif_socket_sink::m_fd): Convert from "int" to "unique_fd".
(maybe_open_sarif_sink_for_socket): Likewise for "sfd".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Philipp Tomsich [Thu, 30 Oct 2025 00:03:03 +0000 (01:03 +0100)]
aarch64: Add support for -mcpu=ampere1c
This adds support for the Ampere1c core to the AArch64 backend. The
initial patch only adds the core feature set (ARMv9.2 + extensions)
and does not add any special tuning decisions, and those may come
later.
Bootstrapped and tested on aarch64-none-linux-gnu.
Arthur Cohen [Wed, 12 Nov 2025 16:18:14 +0000 (17:18 +0100)]
gccrs: Fmt: Simplify pragma diagnostic setup
There was a typo in the original commit where the diagnostic context was not being popped,
however popping the context still causes issues while bootstrapping.
For now, just mark -Warray-bounds as a warning to fix bootstrap on trunk and think about
a proper fix (probably adding a push and pop on every file including rust-fmt.h...) later if
the C++ warning issue is still not fixed.
Add documentation for options -mstack-protector-guard= and
-mstack-protector-guard-record which were added in commit r16-5192-g0cd1f03939d and regenerate .opt.urls.
gcc/ChangeLog:
* config/i386/i386.opt.urls: Regenerate.
* config/s390/s390.opt.urls: Ditto.
* doc/invoke.texi: Add documentation for
-mstack-protector-guard= and -mstack-protector-guard-record.
Antoni Boucher [Wed, 12 Feb 2025 22:32:41 +0000 (17:32 -0500)]
libgccjit: Add the function attributes for setting the ABI
gcc/jit/ChangeLog
* jit-playback.cc: Support new function attributes.
* jit-recording.cc: Support new function attributes.
* libgccjit.h: Support new function attributes.
gcc/testsuite/ChangeLog:
* jit.dg/all-non-failing-tests.h: Mention new test.
* jit.dg/test-abi.c: New test.
A constant value with the top bit of a 16-bit const passed to vbicq_n_u16 will
generate invalid assembly. Avoid this by masking the constant during assembly
generation.
The same applies to vorrq_n and vmvnq_n.
gcc/ChangeLog:
PR target/122175
* config/arm/iterators.md (asm_const_size): New mode attr.
* config/arm/mve.md (@mve_<mve_insn>q_n_<supf><mode>): Use it.
gcc/testsuite/ChangeLog:
PR target/122175
* gcc.target/arm/mve/intrinsics/pr122175.c: New test.
Co-authored-by: Richard Earnshaw <rearnsha@arm.com>
Tobias Burnus [Wed, 12 Nov 2025 13:15:43 +0000 (14:15 +0100)]
libgomp.{c-c++-common,fortran}/target-is-accessible-1.c: Fix testcases for omp_default_device [P119677]
Commit r16-5188-g5da963d988e8ea added omp_default_device such that -5
became a conforming device number, but the tests used them to test
for as non-conforming number; now -6 is used.
libgomp/ChangeLog:
PR libgomp/119677
* testsuite/libgomp.c-c++-common/target-is-accessible-1.c: Modify
test as -5 is now a conforming device number.
* testsuite/libgomp.fortran/target-is-accessible-1.f90: Likewise.
Andre Vieira [Wed, 12 Nov 2025 10:33:09 +0000 (10:33 +0000)]
arm: Fix out of bounds when using cmse with FP types in aggregates [PR122539]
Skip partial register clearing logic when dealing with FP_REGS in aggregates as
these are always fully cleared and the logic assumes a mask for each of the 4
argument GPR_REGS.
Andre Vieira [Wed, 12 Nov 2025 10:25:14 +0000 (10:25 +0000)]
arm: Fix CMSE clearing of union members with no padding [PR122539]
This patch fixes the CMSE register clearing to make sure we don't clear
registers used by a function call. Before this patch the algorithm would only
correctly handle registers with padding bits to clear, any registers that were
fully utilised would be wrongfully cleared.
gcc/ChangeLog:
PR target/122539
* config/arm/arm.cc (comp_not_to_clear_mask_str_un): Update
not_to_clear_reg_mask for union members.
gcc/testsuite/ChangeLog:
* gcc.target/arm/cmse/union-3.x: New test.
* gcc.target/arm/cmse/baseline/union-3.c: New test.
* gcc.target/arm/cmse/mainline/8m/union-3.c: New test.
* gcc.target/arm/cmse/mainline/8_1m/union-3.c: New test.
So far only a per thread canary in the TLS block is supported. This
patch adds support for a global canary, too. For this the new option
-mstack-protector-guard={global,tls} is added which defaults to tls.
The global canary is expected at symbol __stack_chk_guard which means
for a function prologue instructions larl/l(g)fr + mvc are emitted and
for an epilogue larl/l(g)fr + clc.
Furthermore, option -mstack-protector-guard-record is added which is
inspired by -mrecord-mcount and generates section __stack_protector_loc
containing pointers to all instructions which load the address of the
global guard. Thus, this option has only an effect in conjunction with
-mstack-protector-guard=global. The intended use is for the Linux
kernel in order to support run-time patching. In each task_struct of
the kernel a canary is held which will be copied into the lowcore.
Since the kernel supports migration of the lowcore at boot time,
addresses are not necessarily constant. Therefore, the kernel expects
that all instructions loading the address of the canary to be of format
RIL or more precisely are either larl or lgrl and that the instructions
addresses are recorded in section __stack_protector_loc. The kernel is
then required to patch those instructions e.g. to llilf during boot.
In total this means -mstack-protector-guard=global emits code suitable
for user and kernel space.
gcc/ChangeLog:
* config/s390/s390-opts.h (enum stack_protector_guard): Define
SP_TLS and SP_GLOBAL.
* config/s390/s390.h (TARGET_SP_GLOBAL_GUARD): Define predicate.
(TARGET_SP_TLS_GUARD): Define predicate.
* config/s390/s390.md (stack_protect_global_guard_addr<mode>):
New insn.
(stack_protect_set): Also deal with a global guard.
(stack_protect_test): Also deal with a global guard.
* config/s390/s390.opt (-mstack-protector-guard={global,tls}):
New option.
(-mstack-protector-guard-record) New option.
gcc/testsuite/ChangeLog:
* gcc.target/s390/stack-protector-guard-global-1.c: New test.
* gcc.target/s390/stack-protector-guard-global-2.c: New test.
* gcc.target/s390/stack-protector-guard-global-3.c: New test.
* gcc.target/s390/stack-protector-guard-global-4.c: New test.
Richard Biener [Wed, 12 Nov 2025 09:03:23 +0000 (10:03 +0100)]
tree-optimization/122647 - missing bool pattern for bool -> float conversion
The following adds missing support for bool to float conversion which
can be exposed via C++ __builtin_bit_cast. It also corrects a too
lose check in vectorizable_conversion which would have resolved the
ICE but left us with the missed optimization.
PR tree-optimization/122647
* tree-vect-stmts.cc (vectorizable_conversion): Fix guard on
bool to non-bool conversion.
* tree-vect-patterns.cc (vect_recog_bool_pattern): Also handle
FLOAT_EXPR from bool.
Tomasz Kamiński [Thu, 6 Nov 2025 14:22:12 +0000 (15:22 +0100)]
libstdc++: optional<T&> for function and unbounded array should not be range [PR122396]
This implements proposed resolution for LWG4308 [1].
For T denoting either function type or unbounded array, the optional<T&> no
longer exposes iterator, and viable begin/end members. The conditionally
provided iterator type, it is now defined in __optional_ref_base
base class.
Furthermore, range support for optional<T&> is now also guarded by
__cpp_lib_optional_range_support.
[1] https://cplusplus.github.io/LWG/issue4308
PR libstdc++/122396
libstdc++-v3/ChangeLog:
* include/std/optional (__optional_ref_base): Define.
(std::optional<_Tp&>): Inherit from __optional_ref_base<_Tp>.
(optional<_Tp&>::iterator): Move to base class.
(optional<_Tp&>::begin, optional<_Tp&>::end): Use deduced return
type and constrain accordingly.
* testsuite/20_util/optional/range.cc: Add test for optional<T&>.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Eric Botcazou [Wed, 12 Nov 2025 08:03:18 +0000 (09:03 +0100)]
Ada: Fix variable initialized with if-expression not flagged as constant
This is a regression present on the mainline and 15 branch: the -gnatwk
switch no longer flags a string variable initialized with an if-expression
as constant when it is not modified in the program. The fix is to set the
Has_Initial_Value and Never_Set_In_Source flags earlier during analysis in
the Analyze_Object_Declaration procedure.
gcc/ada/
PR ada/122640
* sem_ch3.adb (Analyze_Object_Declaration): Set Is_True_Constant
on entry for constants and Never_Set_In_Source in all cases.
If an initialization expression is present, set Has_Initial_Value
and Is_True_Constant on variables.
Jason Merrill [Fri, 7 Nov 2025 13:16:30 +0000 (18:46 +0530)]
libstdc++: use -Wno-deprecated-declarations
-Wno-deprecated doesn't work with header units, since the testcase can't
change the header unit's version of the __DEPRECATED macro. But
-Wno-deprecated-declarations works just fine to avoid warning about
deprecated things.
Jason Merrill [Tue, 11 Nov 2025 13:15:31 +0000 (18:45 +0530)]
libstdc++: sync prune.exp with GCC
I needed to add module context to dg-prune for libstdc++, and figured it
made sense to sync it with the GCC version rather than maintain slightly
different approaches to stripping the same messages.
libstdc++-v3/ChangeLog:
* testsuite/lib/prune.exp: Sync with gcc prune.exp.
fortran: Fix ICE and self-assignment bugs with recursive allocatable finalizers [PR90519]
Derived types with recursive allocatable components and FINAL procedures
trigger an ICE in gimplify_call_expr because the finalizer wrapper's result
symbol references itself (final->result = final), creating a cycle. This
patch creates a separate __result_<typename> symbol to break the cycle.
Self-assignment (a = a) with such types causes use-after-free because the
left-hand side is finalized before copying, destroying the source. This
patch adds detection using gfc_dep_compare_expr at compile time and pointer
comparison at runtime to skip finalization when lhs == rhs.
Parenthesized self-assignment (a = (a)) creates a temporary, defeating the
simple self-assignment detection. This patch adds strip_parentheses() to
look through INTRINSIC_PARENTHESES operators and ensure deep_copy is enabled
for such cases.
Test pr112459.f90 now expects 6 _final calls instead of 12 because separate
result symbols eliminate double-counting in tree dumps.
PR fortran/90519
gcc/fortran/ChangeLog:
* trans-expr.cc (strip_parentheses): New helper function to strip
INTRINSIC_PARENTHESES operators from expressions.
(is_runtime_conformable): Use strip_parentheses to handle cases
like a = (a) when checking for self-assignment.
(gfc_trans_assignment_1): Strip parentheses before checking if
expr2 is a variable, ensuring deep_copy is enabled for cases like
a = (a). Also strip parentheses when checking for self-assignment
to avoid use-after-free in finalization.
(gfc_trans_scalar_assign): Add comment about parentheses handling.
* class.cc (generate_finalization_wrapper): Create separate result
symbol for finalizer wrapper functions instead of self-referencing
the procedure symbol, avoiding ICE in gimplify_call_expr.
gcc/testsuite/ChangeLog:
* gfortran.dg/finalizer_recursive_alloc_1.f90: New test for ICE fix.
* gfortran.dg/finalizer_recursive_alloc_2.f90: New execution test.
* gfortran.dg/finalizer_self_assign.f90: New test for self-assignment
including a = a, a = (a), and a = (((a))) cases using if/stop pattern.
* gfortran.dg/pr112459.f90: Update to expect 6 _final calls instead
of 12, reflecting corrected self-assignment behavior.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Jerry DeLisle [Tue, 11 Nov 2025 18:47:31 +0000 (10:47 -0800)]
fortran: Implement optional type spec for DO CONCURRENT [PR96255]
This patch adds support for the F2008 optional integer type specification
in DO CONCURRENT and FORALL headers, allowing constructs like:
do concurrent (integer :: i=1:10)
The implementation handles type spec matching, creates shadow variables
when the type spec differs from any outer scope variable, and converts
iterator expressions to match the specified type.
Shadow variable implementation:
When a type-spec is provided and differs from an outer scope variable,
a shadow variable with the specified type is created (with _ prefix).
A recursive expression walker substitutes all references to the outer
variable with the shadow variable throughout the DO CONCURRENT body,
including in array subscripts, substrings, and nested operations.
Constraint enforcement:
Sets gfc_do_concurrent_flag properly (1 for block context, 2 for mask
context) to enable F2008 C1139 enforcement, ensuring only PURE procedures
are allowed in DO CONCURRENT constructs.
Additional fixes:
- Extract apply_typespec_to_iterator() helper to eliminate duplicated
shadow variable creation code (~70 lines)
- Add NULL pointer checks for shadow variables
- Fix iterator counting to handle both EXEC_FORALL and EXEC_DO_CONCURRENT
- Skip FORALL obsolescence warning for DO CONCURRENT (F2018)
- Suppress many-to-one assignment warning for DO CONCURRENT (reductions
are valid, formalized with REDUCE locality-spec in F2023)
PR fortran/96255
gcc/fortran/ChangeLog:
* gfortran.h (gfc_forall_iterator): Add bool shadow field.
* match.cc (apply_typespec_to_iterator): New helper function to
consolidate shadow variable creation logic.
(match_forall_header): Add type-spec parsing for DO CONCURRENT
and FORALL. Create shadow variables when type-spec differs from
outer scope. Replace duplicated code with apply_typespec_to_iterator.
* resolve.cc (replace_in_expr_recursive): New function to recursively
walk expressions and replace symbol references.
(replace_in_code_recursive): New function to recursively walk code
blocks and replace symbol references.
(gfc_replace_forall_variable): New entry point for shadow variable
substitution.
(gfc_resolve_assign_in_forall): Skip many-to-one assignment warning
for DO CONCURRENT.
(gfc_count_forall_iterators): Handle both EXEC_FORALL and
EXEC_DO_CONCURRENT with assertion.
(gfc_resolve_forall): Skip F2018 obsolescence warning for DO
CONCURRENT. Fix memory allocation check. Add NULL checks for shadow
variables. Implement shadow variable walker.
(gfc_resolve_code): Set gfc_do_concurrent_flag for DO CONCURRENT
constructs to enable constraint checking.
gcc/testsuite/ChangeLog:
* gfortran.dg/do_concurrent_typespec_1.f90: New test covering all
shadowing scenarios: undeclared variable, same kind shadowing, and
different kind shadowing.
Co-authored-by: Steve Kargl <kargl@gcc.gnu.org> Co-authored-by: Jerry DeLisle <jvdelisle@gcc.gnu.org> Signed-off-by: Christopher Albert <albert@tugraz.at>
* c-warn.cc (warn_parms_array_mismatch): Split out body of
per-pair in parameter lists iteration into...
(warn_parm_array_mismatch): ...this new function.
Jason Merrill [Mon, 10 Nov 2025 13:02:53 +0000 (18:32 +0530)]
c++/modules: avoid too many hidden friends in ADL
Most of the add_fns calls in adl_namespace_fns also call ovl_skip_hidden,
but we were forgetting that in the case of imports, which meant that for
24_iterators/const_iterator/112490.cc we were considering the
unreachable_sentinel_t hidden friend operator== and therefore failing.
gcc/cp/ChangeLog:
* name-lookup.cc (name_lookup::adl_namespace_fns): Also skip hidden
in the module case.
Jason Merrill [Sat, 8 Nov 2025 23:45:00 +0000 (05:15 +0530)]
c++/modules: use set_cfun
Assigning directly to cfun doesn't properly update the target and
optimization options for the new function, which causes trouble if we load a
function from a module that has different options than the one we were in
the middle of when the load happened. This broke the use of #pragma
optimize in 23_containers/array/iterators/begin_end.cc.
Nathan's comment in module.cc complained about the API doing too much, but
set_cfun seems to me to be exactly what we want here.
gcc/cp/ChangeLog:
* module.cc (module_state::read_cluster): Use set_cfun.
(post_load_processing): Likewise.
Andrew Stubbs [Tue, 11 Nov 2025 15:04:09 +0000 (15:04 +0000)]
amdgcn: Consolidate mkoffload setup constructors
We don't need every mkoffload runtime setting to use it's own constructor.
There was only two committed, but I have more uses for this soon. In theory,
we could also use this setup to choose not to register the kernel with libgomp.
The behaviour is not changed, just the generated code structure.
gcc/ChangeLog:
* config/gcn/mkoffload.cc (process_asm): Replace "configure_stack_size"
constructor with a new regular function, "mkoffload_setup".
(process_obj): Call mkoffload_setup from the "init" constructor.
David Malcolm [Tue, 11 Nov 2025 15:20:47 +0000 (10:20 -0500)]
diagnostics: add experimental SARIF JSON-RPC notifications for IDEs [PR115970]
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3358r0.html#msvc
describes a feature of Visual Studio 2022 version 17.8. which can send its
diagnostics in SARIF form to a pipe when setting the environment variable
SARIF_OUTPUT_PIPE:
https://learn.microsoft.com/en-us/cpp/build/reference/sarif-output?view=msvc-170#retrieving-sarif-through-a-pipe
The precise mechanism above involves Windows-specific details (windows pipes
and HANDLEs).
The following patch implements an analogous feature for GCC, using Unix
domain sockets rather than the Windows-specific details.
With this patch, GCC's cc1, cc1plus, etc will check if
EXPERIMENTAL_SARIF_SOCKET is set in the environment, and if so,
will attempt to connect to that socket. It will send a JSON-RPC
notification to the socket for every diagnostic emitted. Like the
MSVC feature, the diagnostics are sent one-at-a-time as SARIF
"result" objects, rather than sending a full SARIF "log" object.
The patch includes a python test script which runs a server.
Tested by running the script in one terminal:
$ ../../src/contrib/sarif-listener.py
listening on socket: /tmp/tmpjgts0u0i/socket
and then invoking a build in another terminal with the envvar
set to the pertinent socket:
$ EXPERIMENTAL_SARIF_SOCKET=/tmp/tmpjgts0u0i/socket \
make check-gcc RUNTESTFLAGS="analyzer.exp=*"
and watching as all the diagnostics generated during the build
get sent to the listener.
The idea is that an IDE ought to be able to create a socket and
set the environment variable when invoking a build, and then listen
for all the diagnostics, without needing to manually set build flags
to inject SARIF output.
This feature is experimental and subject to change or removal
without notice; I'm adding it to make it easier for IDE developers to
try it out and give feedback.
contrib/ChangeLog:
PR diagnostics/115970
* sarif-listener.py: New file.
gcc/ChangeLog:
PR diagnostics/115970
* diagnostics/sarif-sink.cc: Include <sys/un.h> and <sys/socket.h>.
(sarif_builder::end_group): Update comment.
(sarif_sink::on_end_group): Drop "final".
(class sarif_socket_sink): New subclass.
(maybe_open_sarif_sink_for_socket): New function.
* diagnostics/sarif-sink.h: (maybe_open_sarif_sink_for_socket):
New decl.
* doc/invoke.texi (EXPERIMENTAL_SARIF_SOCKET): Document new
environment variable.
* toplev.cc: Define INCLUDE_VECTOR. Add include of
"diagnostics/sarif-sink.h".
(toplev::main): Call
diagnostics::maybe_open_sarif_sink_for_socket.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Richard Biener [Fri, 7 Nov 2025 12:52:09 +0000 (13:52 +0100)]
Use ranger when simplifying conditions during niter analysis
The following uses ranger to try to simplify boolean expressions
in simplify_using_initial_conditions as used by niter analysis.
We also try to simplify niter expressions themselves, but we cannot
use ranger directly for this.
* tree-ssa-loop-niter.cc (simplify_using_initial_conditions):
Use the active ranger to simplify boolean expressions.
Jeff Law [Tue, 11 Nov 2025 14:19:03 +0000 (07:19 -0700)]
[RISC-V] Improve detection of packw
More infrastructure on the way to eliminating the define_insn_and_split
for zero-extensions.
Exposing the shift-pair approach in the expander may change the order in which
operands appear in later RTL. In the case of packw detection order matters.
It shouldn't, it's an IOR after all, but it does. So we should fix that.
In addition to the ordering issue it slightly changes the form of one operand.
So we want to handle that too. So there's a total of 3 new patterns.
There isn't commonly available hardware with zbkb and it's only lightly tested
in the testsuite. So I wouldn't be terribly surprised to find out there's
other ways we want to represent those operands to ultimately generate a pack
instruction.
Built and tested on riscv32-elf and riscv64-elf in my tester. I'll wait for
pre-commit CI to render a verdict before moving forward.
gcc/
* config/riscv/crypto.md (packf splitters): Variant with
operands reversed. Add variants with the ashift/sign extend
exchanged as well.
Jeff Law [Tue, 11 Nov 2025 14:17:12 +0000 (07:17 -0700)]
[RISC-V] Simplify riscv_extend_to_xmode_reg
So I was trying to untangle our define_insn_and_split situation for
zero-extensions and stumbled over some code we need to adjust & simplify in the
RISC-V backend. I probably should have caught this earlier.
riscv_extend_to_xmode_reg is just a poor implementation of convert_modes; we
can replace the whole thing will a call to convert_modes + force_reg.
Why is this important beyond code hygene?
convert_modes works with the expansion code wheres extend_to_xmode_reg makes
assumptions about the kinds of insns the target directly supports.
This shows up if you try to untangle the zero-extension support where the base ISA doesn't support zero extensions and should be going through an expander rather than using a define_insn_and_split.
The define_insn_and_split for the reg->reg case isn't split until after reload.
Naturally this inhibits some optimizations and forces further work in this
space that should be simple define_splits into also needing to be
define_insn_and_splits.
Anyway, without going further into the zero-extend rathole, this removes the
assumption that the target is providing a single insn zero/sign extension thus
allowing me to continue to untangle that mess.
Bootstrapped and regression tested on the Pioneer (which thoroughly exercises
this code as it does not have the B extension. I don't think the BPI has
picked up this one yet. Also built and regression tested riscv32-elf and
riscv64-elf.
Waiting on pre-commit CI before moving forward.
* config/riscv/riscv.cc (riscv_extend_to_xmode_reg): Simplify
by using convert_modes + force_reg.
Richard Biener [Fri, 7 Nov 2025 12:50:02 +0000 (13:50 +0100)]
Improve range_on_edge for GENERIC expressions
When feeding non-SSA names to range_on_edge we degrade to a
non-contextual query. The following uses the argument added in
the previous patch to indicate the edge as the location of the
range query.
* gimple-range.cc (gimple_ranger::range_on_edge): Pass
the edge as 'edge' to get_tree_range.
(dom_ranger::range_on_edge): Likewise.
Andrew MacLeod [Tue, 11 Nov 2025 07:27:43 +0000 (08:27 +0100)]
Support edge query for range_query::get_tree_range
The following adds an edge argument to get_tree_range and invoke_range_of_expr
to support range_on_edge queries for GENERIC expressions.
* value-query.cc (range_query::invoke_range_of_expr): New
edge argument. If set invoke range_on_edge.
(range_query::get_tree_range): Likewise and adjust.
* value-query.h (range_query::invoke_range_of_expr): New
edge argument.
(range_query::get_tree_range): Likewise.
Lulu Cheng [Thu, 16 Oct 2025 03:26:45 +0000 (11:26 +0800)]
LoongArch: doc: Add description of function attrubute.
Added implementation description of function attributes
target_clones and target_version under LoongArch.
Include the list of supported options and their corresponding
priorities, as well as the rules for setting priorities.
gcc/ChangeLog:
* doc/extend.texi: Add description for LoongArch function
attributes.
* g++.target/loongarch/mv-symbols1.C: New test.
* g++.target/loongarch/mv-symbols2.C: New test.
* g++.target/loongarch/mv-symbols3.C: New test.
* g++.target/loongarch/mv-symbols4.C: New test.
* g++.target/loongarch/mv-symbols5.C: New test.
* g++.target/loongarch/mv-symbols6.C: New test.
* g++.target/loongarch/mvc-symbols1.C: New test.
* g++.target/loongarch/mvc-symbols2.C: New test.
* g++.target/loongarch/mvc-symbols3.C: New test.
* g++.target/loongarch/mvc-symbols4.C: New test.
* g++.target/loongarch/mvc-symbols5.C: New test.
* gcc.target/loongarch/attr-check-error-message1.c: New test.
* gcc.target/loongarch/attr-check-error-message2.c: New test.
* gcc.target/loongarch/attr-check-error-message3.c: New test.
* gcc.target/loongarch/attr-check-error-message4.c: New test.
* gcc.target/loongarch/attr-check-error-message5.c: New test.
* gcc.target/loongarch/attr-check-error-message6.c: New test.
* gcc.target/loongarch/attr-check-error-message7.c: New test.
* gcc.target/loongarch/attr-check-error-message8.c: New test.
* gcc.target/loongarch/attr-check-error-message9.c: New test.
* config/loongarch/loongarch.cc
(loongarch_option_same_function_versions): Compare the target
attributes in two functions to determine which function’s
features get higher priority.
(TARGET_OPTION_SAME_FUNCTION_VERSIONS): Define.
Lulu Cheng [Wed, 15 Oct 2025 08:53:16 +0000 (16:53 +0800)]
LoongArch: Add support for setting priority in fmv.
gcc/ChangeLog:
* config/loongarch/loongarch-protos.h
(loongarch_parse_fmv_features): Modify the type of parameter.
(loongarch_compare_version_priority): Function declaration.
* config/loongarch/loongarch-target-attr.cc
(enum features_prio): Define LA_PRIO_MAX to indicate the
highest priority of supported attributes.
(loongarch_parse_fmv_features): Added handling of setting
priority in attribute string.
(loongarch_compare_version_priority): Likewise.
* config/loongarch/loongarch.cc
(loongarch_process_target_version_attr): Likewise.
(get_feature_mask_for_version): Likewise.
(loongarch_compare_version_priority): Delete.
This patch can obtain the CPUCFG and HWCAP value at runtime and
extract the flag bits of features for function selection.
HWCAP is used to obtain the support of LSX and LASX because the
kernel can control the enable/disable of these two features.
Note that this requires glibc version 2.38 or higher to compile
and run.
libgcc/ChangeLog:
* config/loongarch/t-loongarch64: Add cpuinfo.c to LIB2ADD.
* config/loongarch/cpuinfo.c: New file.
* config/loongarch/loongarch.cc
(loongarch_compare_version_priority): Returns true if DECL1
and DECL2 are versions of the same function.
(TARGET_COMPARE_VERSION_PRIORITY): Define.
* config/loongarch/genopts/gen-evolution.awk:
* config/loongarch/loongarch-evol-attr.def: Regenerate.
* config/loongarch/loongarch-protos.h
(loongarch_parse_fmv_features): Function declaration.
(get_feature_mask_for_version): Likewise.
* config/loongarch/loongarch-target-attr.cc
(enum features_prio): Defining the priority of features.
(struct loongarch_attribute_info): Add members about
features.
(LARCH_ATTR_MASK): Likewise.
(LARCH_ATTR_ENUM): Likewise.
(LARCH_ATTR_BOOL): Likewise.
(loongarch_parse_fmv_features): Parse a function
multiversioning feature string STR.
* config/loongarch/loongarch.cc
(get_suffixed_assembler_name): Return an identifier for the
base assembler name of a versioned function.
(get_feature_mask_for_version): Get the mask and priority of
features.
(add_condition_to_bb): Insert judgment statements for different
features functions.
(dispatch_function_versions): Generates the dispatch function for
multi-versioned functions.
(make_resolver_func): Make the resolver function decl to dispatch
the versions of a multi-versioned function.
(loongarch_generate_version_dispatcher_body): Generate the
dispatcher logic to invoke the right function version at run-time
for a given set of function versions.
(TARGET_GENERATE_VERSION_DISPATCHER_BODY): Define.
* common/config/loongarch/cpu-features.h: New file.
Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P for LoongArch.
This is used to determine whether the attribute ((target_version ("...")))
is valid and process it.
Define TARGET_HAS_FMV_TARGET_ATTRIBUTE to 0 to use "target_version"
for function versioning.
gcc/ChangeLog:
* config/loongarch/loongarch.cc
(loongarch_process_target_version_attr): New function.
(loongarch_option_valid_version_attribute_p): New function.
(TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P): Define.
* config/loongarch/loongarch.h
(TARGET_HAS_FMV_TARGET_ATTRIBUTE): Define it to 0.
* config/loongarch/genopts/gen-evolution.awk: Output the
info needed for handling evolution features when parsing
the target pragma and attribute.
* config/loongarch/genopts/genstr.sh: Add support for
generating *.def files.
* config/loongarch/loongarch-target-attr.cc
(struct loongarch_attribute_info): Add structure member
record option mask.
(LARCH_ATTR_MASK): New macro.
(LARCH_ATTR_ENUM): Likewise.
(LARCH_ATTR_BOOL): Likewise.
(loongarch_handle_option): Support for new options.
(loongarch_process_one_target_attr): Added support for
the la64v1.1 extended instruction set.
* config/loongarch/t-loongarch: Generate loongarch-evol-attr.def.
* doc/extend.texi: Add new attribute description information.
* config/loongarch/loongarch-evol-attr.def: Generate.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/pragma-la64V1_1.c: New test.
* gcc.target/loongarch/pragma-la64V1_1-2.c: New test.
Andrew Pinski [Mon, 10 Nov 2025 20:22:28 +0000 (12:22 -0800)]
ifcvt: Fix factor_out_operators for BIT_FIELD_REF and BIT_INSERT_EXPR [PR122629]
So factor_out_operators will factor out some expressions but in the case
of BIT_FIELD_REF and BIT_INSERT_EXPR, this only allowed for operand 0 as the
other operands need to be constant.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122629
gcc/ChangeLog:
* tree-if-conv.cc (factor_out_operators): Reject
BIT_FIELD_REF and BIT_INSERT_EXPR if operand other
than 0 is different.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr122629-1.c: New test.
* gcc.dg/torture/pr122629-2.c: New test.
* gcc.dg/tree-ssa/pr122629-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jakub Jelinek [Tue, 11 Nov 2025 07:29:22 +0000 (08:29 +0100)]
gimplify-me: Fix regimplification of gimple-reg-type clobbers [PR122620]
Since r11-2238-ge443d8213864ac337c29092d4767224f280d2062 the C++ FE
emits clobbers like *_1 = {CLOBBER}; where *_1 MEM_REF has some scalar
type like int for -flifetime-dse={1,2} and most of the compiler manages
to cope with that.
If we are very unlucky, we trigger an ICE while trying to regimplify it
(at least during inlining), as happens with GCC 15.2 on firefox-145.0
built with LTO+PGO.
I haven't managed to reduce that to a small testcase that would ICE though,
the clobber certainly appears in code like
template <typename T>
struct S {
T *p;
union { char a; T b; };
static S foo (T *x) { S s; s.p = x; s.b.~T (); return s; }
~S ();
};
void
bar ()
{
int i = 42;
S <int> s = S <int>::foo (&i);
}
but convincing inliner that it should id->regimplify = true; on exactly
that stmt has been difficult.
The ICE is because we try (in two spots) to regimplify the rhs of the
gimple_clobber_p stmt if gimple-reg-type type (i.e. the TREE_CLOBBER),
because it doesn't satisfy the is_gimple_mem_rhs_or_call predicate
returned by rhs_predicate_for for the MEM_REF lhs. And regimplify it
by trying to gimplify SSA_NAME = {CLOBBER}; INIT_EXPR and in there reach
a special case which stores that freshly made SSA_NAME into memory and
loads it from memory, so uses a SSA_NAME without SSA_NAME_DEF_STMT.
Fixed thusly by saying clobbers are ok even for the gimple-reg-types.
2025-11-11 Jakub Jelinek <jakub@redhat.com>
PR lto/122620
* gimplify-me.cc (gimple_regimplify_operands): Don't try to regimplify
TREE_CLOBBER on rhs of gimple_clobber_p if it has gimple_reg_type.
Hu, Lin1 [Tue, 28 Oct 2025 08:11:47 +0000 (16:11 +0800)]
i386: Support C++ template parameters in AMX intrinsics [PR122446]
The AMX intrinsics previously used string concatenation with the '#'
operator to construct register names, which prevented their use with
C++ template non-type parameters. This patch converts all AMX intrinsics
to use inline assembly constraints with the %c format specifier.
And Intel style registers also have % prefix, update Intel syntax to use plain
register names without % preifx.
Nathaniel Shead [Mon, 10 Nov 2025 12:41:25 +0000 (23:41 +1100)]
c++/modules: Propagate purviewness to all parent namespaces
In PR c++/100134, tsubst_friend_function was adjusted to ensure that
instantiating a friend function in an unopened namespace still correctly
marked the namespace as purview. This adjusts the fix to also apply
to nested namespaces.
gcc/cp/ChangeLog:
* pt.cc (tsubst_friend_function): Mark all parent namespaces as
purview if needed.
Store the 'rid' value in a local variable, and pass it to functions that
handle various keywords. This simplifies the code, and removes some
wrappers.
No functional change intended.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_sizeof_expression): Remove function.
(c_parser_countof_expression): Remove function.
(c_parser_unary_expression): Store the 'rid', and pass it
directly to the function calls, without calling wrappers.
Suggested-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sam James [Sun, 9 Nov 2025 02:00:52 +0000 (02:00 +0000)]
gcc: quote some expressions in `test x...`
$gcc_cv_nm may contain a string with spaces since r16-4178-g6051a849aa1e8e and r16-5013-gf8bb20167f8127. It was possible for this to happen via strange user
input in the past too. `test x$gcc_cv_nm != x` therefore produces some noise
like:
```
checking assembler for working .subsection -1...
/usr/m68k-unknown-linux-gnu/tmp/portage/sys-devel/gcc-16.0.9999/work/gcc-16.0.9999/gcc/configure: line 26132: test: syntax error: `--plugin' unexpected
```
Quote a bunch of such tests. I've drive-by quoted other such tests where
they're for a program and may have a similar problem, but not all other
such tests (much larger patch and not at least strictly necessary).
Andrew Pinski [Sat, 8 Nov 2025 05:08:42 +0000 (21:08 -0800)]
builtins: Fix atomics expansion after build_call_nary change [PR122605]
So before r16-5089-gc66ebc3e22138, we could call build_call_nary with more
arguments than was passed as the nargs. Afterwards we get an assert if there
were not exactly that amount.
In this case the code is easier to read when passing the correct number of args
in the first place.
This fixes the two places in builtins.cc where this pattern shows up.
Bootstrapped and tested on x86_64-linux-gnu (and tested the testcase with -m32 where
the failure showed up).
PR middle-end/122605
gcc/ChangeLog:
* builtins.cc (expand_ifn_atomic_bit_test_and): Split out the call to
build_call_nary into two different statements.
(expand_ifn_atomic_op_fetch_cmp_0): Likewise.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Sandra Loosemore [Thu, 30 Oct 2025 00:56:22 +0000 (00:56 +0000)]
Documentation for -fident and -Qy/-Qn options [PR122243]
I noticed that the comments for -fident in common.opt were garbled,
and its description is confusing; this is classed as a code generation
option rather than a preprocessor option, and it controls emission of all
".ident" directives in the assembly file, not just those inserted by the
"#ident" preprocessor directive. Also, the -Qy/-Qn options which have the
same effect as -fident/-fno-ident were documented as System V Options when
in fact they are available on all targets. Fixed thusly.
gcc/ChangeLog
PR other/122243
* common.opt: Clean up comments/documentation for -fident.
* doc/invoke.texi: Move -Qy/-Qn documentation from System V options
and combine with -fident/-fno-ident entry.
Sandra Loosemore [Wed, 29 Oct 2025 22:11:44 +0000 (22:11 +0000)]
Document linker options + -Q and -S [PR122243]
This patch adds documentation for several options that the GCC driver
passes to the linker via specs without further interpretation. I've
also added some comments/documentation strings to common.opt for these
and a couple other options that previously didn't have any.
GCC has long supported long-form command-line options with the same
meanings as its traditional one-character options, e.g. --output as an
alias for -o, --language for -x, and so on. However, these have never
been documented in the manual. This patch adds the missing
documentation for these options, plus some additional options that
have previously undocumented two-dash aliases with the same names as
the one-dash form (e.g., -dumpdir and --dumpdir).
Sandra Loosemore [Wed, 22 Oct 2025 01:58:01 +0000 (01:58 +0000)]
Only document -A/--assert options in cpp manual [PR122243]
Assertions are a preprocessor feature that has been declared obsolete
with strong warnings not to use them since 2001. The main GCC manual
documents the -A command-line option but doesn't include the section
that explains the purpose of the feature or that it is obsolete; that
material appears only in the preprocessor manual. It seems rather pointless
to clutter up the GCC manual with unhelpful documentation of an obsolete
feature, so I've restricted the option documentation to the
preprocessor manual too. I've also added the missing documentation
entries for the long form of the option, --assert.
gcc/ChangeLog
PR other/122243
* doc/cppopts.texi (-A): Restrict option documentation to the CPP
manual. Also document the --assert form.
* doc/invoke.texi (Option Summary): Don't list the -A option.
I noticed that several options (mostly C++ options, including those
for contracts) were documented in the manual but were not listed in
the corresponding option summary table. Besides adding the entries, I
also corrected the alphabetization in the C++ option table and some
formatting issues for option arguments.
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary): Add missing entries,
also correct alphabetization and formatting of the C++ options.
(C++ Language Options): Fix some formatting issues.
Sandra Loosemore [Tue, 28 Oct 2025 22:38:08 +0000 (22:38 +0000)]
Mark some undocumented options as such [PR122243]
We have a number of command-line options that are undocumented (either
intentionally or because they are obsolete and retained only for
compatibility), that ought to be marked as "Undocumented". I've also
added some comments to the .opt files.
gcc/c-family/ChangeLog
PR other/122243
* c.opt (fmodule-version-ignore): Mark as "Undocumented".
gcc/ChangeLog
PR other/122243
* common.opt (fhelp, fhelp=, ftarget-help, fversion): Mark as
"Undocumented".
(fbounds-check): Update comments.
(flag-graphite, fsel-sched-reschedule-pipelined): Mark as
"Undocumented".
(fstack-limit): Add comment.
Sandra Loosemore [Fri, 17 Oct 2025 15:11:47 +0000 (15:11 +0000)]
Add "RejectNegative" to some options where it doesn't make sense [PR122243]
This patch adds the "RejectNegative" property to several options where
it doesn't make sense. These are either options of the form
"name=value" rather than an on/off switch, those that are already in a
"no-" form, or options that form a mutually-exclusive set.
Also, the fhelp, ftarget-help, and fversion options that do not take
arguments ignore the "-no" prefix so that even "-fno-help" (etc)
causes help to be printed instead of suppressing help output. Since that
behavior is not useful, I've added RejectNegative to those options as well.
Sandra Loosemore [Wed, 15 Oct 2025 23:30:00 +0000 (23:30 +0000)]
Add some missing @opindex entries [PR122243]
The options handled in this patch already have documentation but are
either missing an @opindex entry entirely, or index only the negative
option form.