Commit Graph

226794 Commits

Author SHA1 Message Date
Jakub Jelinek
1297b7204a libcpp: Fix up comment handling in -fdirectives-only preprocessing [PR123273]
Back in 2020 Nathan rewrote the -E -fdirectives-only preprocessing.
In PR103130 a year and half later I've fixed the handling of comments
so that /* \*/ is considered as full comment even when * is escaped,
to match the normal preprocessing.
The following testcases shows further bugs in the comment handling.
One is that /* *\/ should not be considered as full comment (i.e.
when the / after * is escaped).  And another one is that the code
was treating any number of backslashes as escape, which is wrong,
only a single backslash is an escape, two backslashes preprocess as
one backslash, three as one backslash and one escape, etc.
So, while /* *\
/ is a full comment, /* *\\
/ or /* *\\\\\\\\\\\\\
/ is not.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/123273
	* lex.cc (cpp_directive_only_process): Only go to done_comment
	for '/' if star is true and esc is false.  When seeing '\\' with
	esc set to true, clear esc as well as star instead of keeping esc
	set.

	* c-c++-common/cpp/dir-only-10.c: New test.
	* c-c++-common/cpp/dir-only-11.c: New test.
2026-01-30 10:56:10 +01:00
Alex Coplan
0779f13125 aarch64: Fix gating of fp8 intrinsics [PR123206]
As it stands, there are several intrinsics in
aarch64-simd-pragma-builtins.def which have the following form:

  #define REQUIRED_EXTENSIONS nonstreaming_only (TARGET_SIMD)
  [...]
  #undef REQUIRED_EXTENSIONS

the problem being that nonstreaming_only expects an instance of
aarch64_feature_flags which (statically) describes the required
extensions for the intrinsics.  Instead, we were passing TARGET_SIMD,
which computes a boolean telling us dynamically whether the simd feature
is currently available.

This patch fixes the issue by simply doing
s/TARGET_SIMD/AARCH64_FL_SIMD/ in that file.  We also add a simple test
which checks that we now diagnose the missing extension instead of
ICEing when compiling with +nosimd.

As an additional conservative hardening step (to prevent a similar issue
from re-occurring), this patch adjusts the aarch64_pragma_builtins table
to make it constexpr.  This makes the bug a compile-time error.

The next patch in the series adjusts the ctor of bbitmap to make it
explicit (and deals with the fallout), this patch however is
deliberately a minimal fix which is suitable for backporting.

gcc/ChangeLog:

	PR target/123206
	* config/aarch64/aarch64-builtins.cc (struct aarch64_pragma_builtins_data):
	Declare array as CONSTEXPR.
	* config/aarch64/aarch64-simd-pragma-builtins.def: Update
	incorrect uses of TARGET_SIMD to use AARCH64_FL_SIMD instead.

gcc/testsuite/ChangeLog:

	PR target/123206
	* gcc.target/aarch64/pr123206.c: New test.
2026-01-30 08:37:22 +00:00
Iain Buclaw
6f3d4f1258 d: Refactor for changes to dmd front-end inteface
There are a number of interface changes being made to the dmd front-end
interface. This makes any necessary refactorings ahead of the merge to
reduce the size of the diff.

gcc/d/ChangeLog:

	* decl.cc (DeclVisitor::visit (EnumDeclaration *)): Treat sinit member
	field as a generic pointer.
	(enum_initializer_decl): Likewise.
	* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Compute static
	array length separately from creating type.
	* modules.cc (struct module_info): Add ctor_decl, dtor_decl,
	sharedctor_decl, shareddtor_decl, standalonector_decl, and
	unittest_decl.
	(layout_moduleinfo_fields): Add mi argument. Use it to check whether
	module helpers have been generated.
	(layout_moduleinfo): Likewise.
	(build_module_tree): Cache generated module helpers in module_info.
	* typeinfo.cc (cpp_type_info_ptrs): New variable.
	(get_cpp_typeinfo_decl): Cache generated C++ type_info references in
	cpp_type_info_ptrs.
	* types.cc (TypeVisitor::visit (TypeEnum *)): Separate getting
	front-end member value from building its CST tree.
2026-01-30 09:06:39 +01:00
Iain Buclaw
9f0f81c515 d: Fix ICE in dwarf2out_abstract_function, at dwarf2out.cc:23771 [PR123263]
Emit artificial functions as being part of the module context, so that
they are unaffected by dwarf early_finish pass removing the parent type
that they were generated for.

	PR d/123263

gcc/d/ChangeLog:

	* d-codegen.cc (d_decl_context): Set DECL_CONTEXT of compiler
	generated functions to that of parent module.

gcc/testsuite/ChangeLog:

	* gdc.dg/debug/pr123263.d: New test.
2026-01-30 08:31:12 +01:00
Richard Biener
4fe48225fa tree-optimization/109410 - ICE with noreturn and -g
This fixes the -g variant of the original testcase.

	PR tree-optimization/109410
	* tree-ssa-reassoc.cc (build_and_add_sum): Use
	gsi_start_nondebug_after_labels_bb to look for a possible
	returns-twice call.

	* gcc.dg/pr109410-2.c: New testcase.
2026-01-30 07:59:04 +01:00
Iain Buclaw
44a5be2f2d d, darwin: Add Apple as a predefined version
This is a new predefined version identifier intended to be turned on if
any of the OSX, iOS, TVOS, WatchOS, or VisionOS versions are predefined.

gcc/ChangeLog:

	* config/darwin-d.cc (darwin_d_os_builtins): Add Apple.
2026-01-30 07:35:52 +01:00
Iain Buclaw
94d887ec2b d: Fix infinite loop in dump_generic_node [PR123264]
PR d/123264

gcc/d/ChangeLog:

	* types.cc (finish_aggregate_type): Propagate struct TYPE_NAME to all
	TYPE_NEXT_VARIANT types.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr123264.d: New test.
2026-01-30 07:30:39 +01:00
Andrew Pinski
40f6ae0165 ifcvt: Improve noce_can_force_operand in ifcvt [PR122170]
Currently if the rtl is either an arithmetic or an unary
rtl, noce_can_force_operand checks to see if there is an
optab for that rtl code. This works for more things except
on some targets they have a ss_minus instruction but don't
implement the optab for it. In the case of arm you can
generate a ss_minus with a builtin and then when it comes
to trying to do ifcvt, force_operand fails over.
In this case the optab, sssub was only supported for
fixed-point modes before and it was working as code_to_optab
would return there was not optabs. But after r15-1030-gabe6d39365476e,
the optab will be return. What the backend is doing is correct and will
most likely happen with other rtl codes/optabs later on.

To fix this instead of just returning true if the optab exists, we need
to check if the optab entry for the mode exists.

	PR rtl-optimization/122170

gcc/ChangeLog:

	* ifcvt.cc (noce_can_force_operand): Don't only check if
	there is an optab for the code check the entry for the
	mode is non-null. Handle non integral div by checking
	optab like force_operand does.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-01-29 19:52:03 -08:00
Lulu Cheng
a57199cec3 LoongArch: Remove unused function type.
gcc/ChangeLog:

	* config/loongarch/loongarch-ftypes.def: Remove unused type.
2026-01-30 11:09:16 +08:00
Lulu Cheng
fde8a30085 LoongArch: Fix bug123766.
The pointer parameter type for the original store class builtin
functions is CVPOINTER (const volatile void *).
Taking the following test as an example:

	```
	v4i64 v = {0, 0, 0, 0};
	void try_store() {
  	  long r[4];
  	  __lasx_xvst(v, r, 0);
	}
	```
At this point, the type of r is CVPOINTER, which means data in memory
can only be read through r.  Therefore, if the array r is not
initialized, an uninitialized warning will be issued.
This patch changes the pointer type of store-class builtin functions
from CVPOINTER to VPOINTER (volatile void *).

	PR target/123766

gcc/ChangeLog:

	* config/loongarch/loongarch-builtins.cc
	(loongarch_build_vpointer_type): New function.  Return a type
	for 'volatile void *'.
	(LARCH_ATYPE_VPOINTER): New macro.
	* config/loongarch/loongarch-ftypes.def: Change the pointer
	type of the store class function from CVPOINTER to VPOINTER.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lasx/pr123766.c: New test.
	* gcc.target/loongarch/vector/lsx/pr123766.c: New test.
2026-01-30 11:09:11 +08:00
Lulu Cheng
4df77a2542 LoongArch: Fix bug123807.
In the function loongarch_expand_vector_init_same, if same is MEM and
the mode of same does not match imode, it will cause an ICE
in force_reg (imode, same).

	PR target/123807

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_expand_vector_init_same): When same is MEM and
	GET_MODE(same) != imode, first load the data from memory
	and then process it further.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lsx/pr123807.c: New test.
2026-01-30 09:23:45 +08:00
mengqinggang
599659fb10 LoongArch: Fix movsf in lp64s abi
When adding LoongArch32 ilp32s abi support, add TARGET_HARD_FLOAT condition for
movsf to prevent matching in target without FPU.
But movsf also needs to be used in lp64s abi, it can expand to some
non float instructions.
Delete TARGET_HARD_FLOAT condition.

gcc/ChangeLog:

	* config/loongarch/loongarch.md: Delete movsf TARGET_HARD_FLOAT
	condition.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/la64/movsf.c: New test.
2026-01-30 09:21:21 +08:00
GCC Administrator
aeba874068 Daily bump. 2026-01-30 00:16:31 +00:00
Andrew Pinski
41f293e72c optabs: Fix expansion of abs and neg for Float16 [PR123869]
The problem here is we try to use the widening type before
doing the bitwise expansion of neg/and for floating point types.
This moves the code around to try the bitwise expansion first.

Note this mostly matters for NaNs where you widening (promotion)
would cause a NaN to be slightly different when doing the rounding
back.

Bootstrapped and tested on x86_64-linux-gnu.

	PR middle-end/123869

gcc/ChangeLog:

	* optabs.cc (expand_unop): Move the NEG optab
	handling before the widening code.
	Move the ABS bitwise expansion from expand_abs_nojump
	to before the widening code.
	(expand_abs_nojump): Remove the bitwise expansion trial
	since expand_unop is called right above.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-01-29 13:50:47 -08:00
Jonathan Wakely
57f571f728 libstdc++: Make std::expected trivially copy/move assignable (LWG 4026)
This is the subject of two NB comments on C++26 which seem likely to be
approved. We're allowed to make this change as QoI anyway, even if it
isn't approved for the standard, and it should apply to C++23 as well to
avoid ABI changes between C++23 and C++26.

As shown in the updates to the test, defaulted special members can have
noexcept(false) even if they would be noexcept(true) by default. The new
defaulted operator= overloads added by this commit have conditional
noexcept-specifiers that match the conditions of the non-trivial
assignments, propagating any noexcept(false) on trivial special members
of the T and E types. We could strengthen the noexcept for the trivial
operators, but propagating the conditions from the underlying types is
probably what users expect, if they've bothered to put noexcept(false)
on their defaulted special members.

libstdc++-v3/ChangeLog:

	* include/std/expected (__expected::__trivially_replaceable)
	(__expected::__usable_for_assign)
	(__expected::__usable_for_trivial_assign)
	(__expected::__can_reassign_type): New concepts.
	(expected::operator=): Adjust constraints
	on existing overloads and add defaulted overload.
	(expected<cv void, E>::operator=): Likewise.
	* testsuite/20_util/expected/requirements.cc: Check for trivial
	and nothrow properties of assignments.
2026-01-29 20:17:40 +00:00
Andrew Pinski
c906b8f019 testsuite: Move pr116353.c from being x86 specific to being generic
While working on ifcvt's noce_can_force_operand, I noticed that
the testcase pr116353.c was added as x86 specific testcase but
it has nothing in it that is x86 specific. It is currently
compiled at -O2 but there is no reason why it can't be compiled
at any other optimization level.
So this moves the testcase to be a torture testcase.

The original issue showed up on x86 with respect to ifcvt
where there was a vec_select which does not have an optab for it
but it might show up on other targets too.

Tested on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr116353.c: Move to...
	* gcc.dg/torture/pr116353.c: ...here.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-01-29 12:01:17 -08:00
Roger Sayle
9f9b5d6946 Allow CONCATs in emit_group_load_1.
This one line patch is a pre-requisite to a solution to PR target/123506;
an effort to improve middle-end code for returning structures.  Currently,
emit_group_load_1 contains code to handle a CONCAT returned by force_reg.
This tweak avoids the call for force_reg if the source is already a CONCAT,
which allows this subroutine to be re-used by target-specific implementations
of emit_group_load.  Many thanks to Jeff Law for cross-platform testing.

2026-01-29  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* expr.cc (emit_group_load_1): Don't call force_reg if orig_src
	is already a CONCAT.
2026-01-29 18:48:14 +00:00
Eric Botcazou
59145b089d Ada: Fix internal error on equality test with empty container
This is a regression present on the mainline and 15 branch, although the
root cause has been present for years: the Sem_Type.Covers predicate
returns true for the type of an aggregate (Any_Composite) and any type
declared with the Aggregate aspect (when invoked in Ada 2022 or later),
but its companion function Sem_Type.Specific_Type punts when it is called
on the same combination.

gcc/ada/
	PR ada/123861
	* sem_type.adb (Covers): Fix couple of typos in comment.
	(Specific_Type): Adjust to Covers' handling of types declared
	with the Aggregate aspect in Ada 2022.

gcc/testsuite/
	* gnat.dg/specs/aggr11.ads: New test.
2026-01-29 18:31:25 +01:00
Richard Earnshaw
74907f407d testsuite: arm: rework some target-supports checks to use -mfpu=auto
Several target-supports checks for Arm are still using the antiquated
-mfpu=... setting rather than picking up FPU extensions via the
architecture specification.  This causes problems when tests are
layered because they do not consistently override each other.

Arguably, that is incorrect anyway: you can't test two sets of flag
combinations independently and then expect to be able to apply both
of them, but this change at least makes this behave in a reasonable
way provided the second set of flags fully overrides the first.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp:
	(check_effective_target_arm_v8_3a_complex_neon_ok_nocache):
	Split and fill in arm and aarch64 compile options.  Remove the
	cpu_unset variable.
	(check_effective_target_arm_v8_2a_fp16_neon_ok_nocache): Likewise.
	(check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache):
	Likewise.
	(check_effective_target_arm_neon_ok_nocache): Rework to use
	-mfpu=auto.
	(check_effective_target_arm_neon_fp16_ok_nocache): Likewise.

Co-authored-by: Artemiy Volkov <artemiy.volkov@arm.com>
2026-01-29 17:20:59 +00:00
Artemiy Volkov
31875b910c testsuite: require arm_v8_3a_fp16_complex_neon for complex fp16 tests
Changes to target-supports.exp from r16-6519-g56dd47c073cabf introduced
some new failures for complex fp16 tests with some arm-eabi targets
configured with -mfpu=auto.  This patch fixes those by (a) requiring the
full arm_v8_3a_fp16_complex_neon_ok target instead of just float16 in
vect/complex fp16 tests, and (b) simplifying down to one
dg-require-effective-target and one dg-add-options and removing the
explicit -march in advsimd-intrinsics/vector-complex_f16.c.

Regtested on aarch64, and the Linaro CI also delivers a positive verdict
for the relevant cortex-m33/-m3/-m55/-m7 configurations (after the
accompanying patch to target-supports.exp that follows).  Huge thanks to
Christophe for testing this on arm.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c:
	Adjust testcase.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-half-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c:
	Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vector-complex_f16.c:
	Likewise.
2026-01-29 17:19:14 +00:00
Jonathan Wakely
a111fd4d47 libstdc++: Fix use of feature test macro in <source_location>
libstdc++-v3/ChangeLog:

	* include/std/source_location: Check __glibcxx_contracts instead
	of __cpp_lib_contracts.
	* testsuite/18_support/contracts/includes.cc: New test.
2026-01-29 17:14:03 +00:00
vspefs
4e47e85dd8 libstdc++: fix a wrong export of a contracts facility in std module
This patch fixes a wrong export name in std module. std module currently
exports std::contracts::invoke_default_violation_handler, which is wrong.
The correct name is std::contracts::invoke_default_contract_violation_handler.

libstdc++-v3/ChangeLog:

	* src/c++23/std.cc.in (invoke_default_violation_handler): Change
	to invoke_default_contract_violation_handler.

Signed-off-by: Xie Han <vspefs@protonmail.com>
2026-01-29 17:13:27 +00:00
Christopher Bazley
32852e2f47 arm: testsuite: Use test framework to set arch in stack-protector-7
This test was trying to set the architecture directly instead of
using the framework. The queried options were previously ignored.

gcc/testsuite/ChangeLog:
	* gcc.target/arm/stack-protector-7.c: Fix dgdirectives.
2026-01-29 16:45:30 +00:00
Sandra Loosemore
f101d3478e doc: Add "user experience" documentation for options
After working through PR122243, it seems appropriate to write down
some guidelines for adding/maintaining options and options
documentation so that we can at least point to procedures to keep
things from getting out of sync again.

Thanks to jemarch@gnu.org and dmalcolm@redhat.com for their suggestions
to improve this patch.

gcc/ChangeLog
	* doc/options.texi (Options): Point to the "user experience"
	documentation.
	* doc/ux.texi (Guidelines for Options): Add some.
2026-01-29 16:42:23 +00:00
Robin Dapp
6a1578c1f6 RISC-V: Handle VL-setting FoF loads. [PR123806]
For PR122869 I thought I fixed the issue of VL-spills clobbering
explicit VL reads after fault-only-first (FoF) loads but it turns
out the fix is insufficient.  Even though it avoided the original
issue, we can still have spills that clobber VL before the read_vl
RTL pattern.  That's mostly due to us hiding the VL data flow from
the optimizers so a regular spill to memory can and will introduce
a VL clobber.  In vsetvl we catch all the regular cases but not the
FoF-load case of PR123806 and PR122869.

This patch adds specific FoF patterns that emit the same instruction but
have a register-setting VL pattern inside the insn's PARALLEL.
It serves as a marker for the vsetvl pass that can recognize that we
clobber VL before reading its value.  In that case we now emit an
explicit csrr ..,vl.

After vsetvl it's safe to emit the read_vls because at that point the
VL dataflow has been established and we can be sure to not clobber VL
anymore.

Thus, the main changes are:
 - Unify read_vl si and di and make it an UNSPEC.  We don't optimize
   it anyway so a unified one is easier to include in the new FoF
   VL-setter variants.
 - Introduce VL-setting variants of FoF loads and handle them like
   read_vl()s in the vsetvl pass.
 - Emit read_vl()s after vsetvl insertion is done.

What this doesn't get rid of is the XFAIL in ff-load-3.c that I
introduced for PR122869.  The code is still "good" at -O1 and
"bad" at -O2 upwards.

	PR target/123806

gcc/ChangeLog:

	* config/riscv/riscv-string.cc (expand_rawmemchr): Use unified
	vl_read.
	(expand_strcmp): Ditto.
	* config/riscv/riscv-vector-builtins-bases.cc:
	* config/riscv/riscv-vector-builtins.cc (function_expander::use_fof_load_insn):
	Only emit the store and not the VL read.
	* config/riscv/riscv-vsetvl.cc (get_fof_set_vl_reg): New
	function.
	(init_rtl_ssa): New wrapper.
	(finish_rtl_ssa): Ditto.
	(emit_fof_read_vls): Emit read_vl after each fault-only-first
	load.
	(pass_vsetvl::simple_vsetvl): Call emit_fof_read_vls ().
	(pass_vsetvl::lazy_vsetvl): Ditto.
	* config/riscv/vector-iterators.md: Add read_vl unspec.
	* config/riscv/vector.md (read_vlsi): Unify.
	(@read_vl<mode>): Ditto.
	(read_vldi_zero_extend): Ditto.
	(@pred_fault_load_set_vl<V_VLS:mode><P:mode>): New FoF variant
	that saves VL in a register.
	(@pred_fault_load_set_vl<VT:mode><P:mode>): Ditto.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/pr123806.C: New test.
	* g++.target/riscv/rvv/base/pr123808.C: New test.
	* g++.target/riscv/rvv/base/pr123808-2.C: New test.
2026-01-29 17:37:50 +01:00
Robin Dapp
a7d442ab31 RISC-V: testsuite: Add zvl requirement to PR123626.
This adds a new require-effective-target check to pr123626.c.
As the test is a run test compiled with _zvl256b we need
to ensure the target actually supports 256b vectors.

We can only check for exactly 256b right now
(rvv_zvl256b_ok), i.e. "VLS".  Therefore, the patch also adds
a new target check rvv_zvl_ge_256b_ok where ge means greater
or equal.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp: Add rvv_zvl_ge_256b_ok.
	* gcc.target/riscv/rvv/base/pr123626.c: Use new target check.
2026-01-29 17:37:49 +01:00
Iain Buclaw
172634608a d: Fix Segmentation fault with redeclared symbols [PR123407]
Issue an error if two symbols with the same assembler name have a
mismatched TREE_CODE.

	PR d/123407

gcc/d/ChangeLog:

	* decl.cc (get_symbol_decl): Handle declarations with matching
	assembler names, but different TREE_CODE.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr123407a.d: New test.
	* gdc.dg/pr123407b.d: New test.
2026-01-29 17:12:23 +01:00
Filip Kastl
07cbb8cdce pta: Fix comment of intra_create_variable_infos
The comment says that this function creates varinfos for *all*
variables in a function.  Meanwhile, it only creates varinfos for
parameters, the return value and the static chain.

Commiting as obvious.

gcc/ChangeLog:

	* gimple-ssa-pta-constraints.cc (make_param_constraints): Adjust
	comment: The function only creates varinfos for the parameters,
	the return value and the static chain.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2026-01-29 16:03:52 +01:00
Marek Polacek
6f7c038eee c++/reflection: add fixed test [PR123871]
Incredibly, a patch that I just pushed (r16-7140-g101f2970adc0a7) fixed
this ICE.

I notice that we don't emit the diag_array_subscript diagnostic because
slice calls fold_non_dependent_expr which calls _eval_outermost with
allow_non_constant=true.  I wonder if we want to change this.

	PR c++/123871

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/error11.C: New test.
2026-01-29 09:48:48 -05:00
Iain Buclaw
b4ee1a549e d: Fix ICE in gimplify_expr with const ref noreturn parameters [PR123046]
The ICE was caused by references to const/immutable qualified `noreturn'
declarations that were being leaked to the code generation when they
should have been omitted or replaced with `assert(0)'.

	PR d/123046

gcc/d/ChangeLog:

	* d-codegen.cc (build_address): Return `null' when generating the
	address of a `noreturn' declaration.
	(d_build_call): Compare TYPE_MAIN_VARIANT of type with `noreturn'.
	* decl.cc (get_fndecl_arguments): Likewise.
	* types.cc (finish_aggregate_mode): Likewise.
	(TypeVisitor::visit (TypeFunction *)): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr123046.d: New test.
2026-01-29 15:27:18 +01:00
Richard Biener
06320fa8b3 tree-optimization/122537 - do not elide maybe_zero condition for wrapping IV
The following removes the optimization eliding the maybe_zero condition
from number_of_iterations_lt_to_ne when the IV can overflow since the
IV delta input is not accurately reflecting this.

	PR tree-optimization/122537
	* tree-ssa-loop-niter.cc (number_of_iterations_lt_to_ne): Register
	may_be_zero condition when the IV may overflow.

	* gcc.dg/torture/pr122537.c: New testcase.
2026-01-29 15:17:06 +01:00
Marek Polacek
397b0827bc c++/reflection: tweak for eval_has_template_arguments
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:

> For reflection it's probably best to go with
>
> if (TYPE_P (r) && typedef_variant_p (r))
>   return alias_template_specialization_p (r, nt_opaque);
>
> and not get into primary_template_specialization_p at all.

Here in a patch form.

gcc/cp/ChangeLog:

	* reflect.cc (eval_has_template_arguments): Return immediately after
	checking alias_template_specialization_p.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-29 08:45:20 -05:00
Marek Polacek
ec8ec2755f c++/reflection: add assert to eval_type_trait
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>.

Since we check eval_is_type in process_metafunction:

  if (eval_is_type (ht) != boolean_true_node)
     return throw_exception_nontype (loc, ctx, fun, non_constant_p,
				     jump_target);

finish_trait_expr should never return error_mark_node.  We can ensure
that it's so by adding an assert.

gcc/cp/ChangeLog:

	* reflect.cc (eval_type_trait): Assert that finish_trait_expr didn't
	return error_mark_node.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-29 08:44:00 -05:00
Marek Polacek
101f2970ad c++/reflection: enhance splice error checking
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:

> Absolutely, I mean anything other than REFLECT_EXPR or error_mark_node
> should be an error.

I'm not giving another error for error_mark_node since we've already
complained (but make sure we have).

gcc/cp/ChangeLog:

	* reflect.cc (class_members_of): Adjust comment.
	(splice): Give an error if the expression doesn't evaluate to
	a REFLECT_EXPR_P.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-29 08:42:04 -05:00
Sangamesh Mallayya
bc10a49c37 Fix AIX build break in gcc/diagnostics/sarif-sink.cc.
In AIX, build fails while trying to compile gcc/diagnostics/sarif-sink.cc.
Here is the snapshot of the error we are getting.

In file included from /opt/freeware/src/packages/BUILD/gcc/gcc/system.h:46,
                 from /opt/freeware/src/packages/BUILD/gcc/gcc/diagnostics/sarif-sink.cc:34:
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/include-fixed/stdio.h:593:12: error: conflicting declaration of C function 'int fgetpos64(FILE*, fpos64_t*)'
  593 | extern int fgetpos64(FILE *, fpos64_t *);
      |            ^~~~~~~~~

This happens when we include sys/types.h before defining _LARGE_FILES.
We can see similar errors with this sample program.

#include <sys/types.h>
#define _LARGE_FILES 1
#include <stdio.h>
int main()
{
   return 0;
}

In gcc/diagnostics/sarif-sink.cc we are including config.h after #include <sys/un.h> which intern
 including sys/types.h and causing the conflicting errors.
Including config.h before including sys/un.h should solve this error.

The patch is to fix the build break on AIX.

gcc/ChangeLog:
	* diagnostics/sarif-sink.cc: Move config.h at the begining.
2026-01-29 07:08:03 -06:00
Iain Buclaw
a492b8c171 d: Fix buffer overflow detected with -defaultlib= and -debuglib= [PR123349]
PR d/123349

gcc/d/ChangeLog:

	* d-spec.cc (lang_specific_driver): Use xstrdup to copy -defaultlib
	and -debuglib argument, and unconditionally free the old value.

gcc/testsuite/ChangeLog:

	* gdc.dg/driver_debuglib.d: New test.
	* gdc.dg/driver_defaultlib.d: New test.
2026-01-29 13:16:31 +01:00
Jonathan Wakely
95ed4da229 libstdc++: Fix non-ASCII characters in <contracts> header
This fixes:
FAIL: 17_intro/headers/c++1998/charset.cc  -std=gnu++26 (test for excess errors)

libstdc++-v3/ChangeLog:

	* include/std/contracts: Replace non-ASCII characters.
2026-01-29 12:13:43 +00:00
Richard Biener
4c49f8e536 tree-optimization/123596 - fix partial virtual SSA update in eh_cleanup
The following replaces the not quite correct use of
mark_virtual_operand_for_renaming by an appropriate way of dealing
with a possibly partially up-to-date virtual SSA form.  Namely
when we just move stmts and not remove a VDEF we should arrange
for missing virtual PHIs to be created and just queue its arguments
for possible renaming.  For the testcase at hand there's no renaming
necessary in the end when done this way.

	PR tree-optimization/123596
	* tree-eh.cc (sink_clobbers): Create a virtual PHI when
	one is required but not present, queuing arguments
	for renaming.

	* g++.dg/torture/pr123596.C: New testcase.
2026-01-29 12:37:47 +01:00
Richard Biener
312ba8d740 tree-optimization/116747 - ICE in cselim due to duplicate sinking
The following avoids queueing duplicate stmts in the set of sinkings
to consider as well as pick candidates in an order that ensures
we don't unnecessarily re-order stores.  While we currently only can
trigger the ICE with out-of-bound accesses future enhancements
to how we deal with dependence analysis in this pass could expose
the issue to a wider range of testcases, so this makes it future-proof.

	PR tree-optimization/116747
	* tree-ssa-phiopt.cc (cond_if_else_store_replacement): Avoid
	duplicate stmts in the set of store pairs to process.

	* gcc.dg/tree-ssa/cselim-4.c: New testcase.
2026-01-29 12:37:47 +01:00
Jakub Jelinek
4f2a04726b c++: Fix ICE in eval_annotations_of [PR123866]
eval_annotations_of throws if the passed in reflection handle is not
eval_is_function (and various others).  Now, eval_is_function uses
maybe_get_first_fn to look through BASELINK/OVERLOAD etc., but
eval_annotations_of wasn't doing that and ICEd on
  else if (TYPE_P (r))
    r = TYPE_ATTRIBUTES (r);
  else if (DECL_P (r))
    r = DECL_ATTRIBUTES (r);
  else
    gcc_unreachable ();
because r isn't a decl nor type (nor REFLECT_BASE earlier).

2026-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/123866
	* reflect.cc (eval_annotations_of): Use maybe_get_first_fn.

	* g++.dg/reflect/annotations10.C: New test.
2026-01-29 12:34:59 +01:00
Jose E. Marchesi
7632c2e12b a68: implement GNU68-2026-001-short-of-symbol
This patch implements the GNU extension:

  GNU68-2026-001-brief-selection - Brief style for selection

which adds the preferred brief style for selection recommended by
Hansen in "ALGOL 68 Hardware Represenatation Recommendations"
published in the Algol Bulletin issue 42.

This extension is already listed in https://algol68-lang.org.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/algol68/ChangeLog

	* ga68.vw: Update formal grammar to express the GNU extension.
	* a68-parser.cc (a68_dont_mark_here): Likewise.
	* a68-parser-scanner.cc (SINGLE_QUOTE_CHAR): Define.
	(get_next_token): Recognize ' as QUOTE_SYMBOL.
	(tokenise_source): Acknowledge QUOTE_SYMBOL.
	* a68-parser-keywords.cc (a68_set_up_tables): Likewise.
	* a68-parser-bottom-up.cc (reduce_primary_parts): Adjust parser to
	brief form of selection.
	* a68-parser-attrs.def (QUOTE_SYMBOL): New attribute.
	* ga68.texi (Brief selection): New section.

gcc/testsuite/ChangeLog

	* algol68/compile/error-selector-1.a68: New test.
	* algol68/execute/selection-2.a68: Update test.
	* algol68/execute/selection-5.a68: Likewise.
2026-01-29 12:06:10 +01:00
Jakub Jelinek
ef8af34e0d c++: Implement CWG3131 - Value categories and types for the range in iterable expansion statements
For the https://gcc.gnu.org/pipermail/gcc/2025-November/246977.html
issues I've filed https://github.com/cplusplus/CWG/issues/805
which resulted in two CWG issues,
https://cplusplus.github.io/CWG/issues/3131.html
and
https://cplusplus.github.io/CWG/issues/3140.html
This patch implements the former, changing
the iterating expansion statement http://eel.is/c++draft/stmt.expand#5.2
line from
constexpr auto&& range = expansion-initializer;
to
constexpr decltype(auto) range = (expansion-initializer);
(for our partly pre-CWG3044 implementation with static before it).

2026-01-29  Jakub Jelinek  <jakub@redhat.com>

	* cp-tree.h (build_range_temp): Implement CWG3131 - Value
	categories and types for the range in iterable expansion statements.
	Add bool argument defaulted to false.
	* parser.cc (build_range_temp): Add expansion_stmt_p argument,
	if true build const decltype(auto) __for_range = range_expr instead of
	auto &&__for_range = range_expr.
	(cp_build_range_for_decls): For expansion stmts build __for_range as
	static constexpr decltype(auto) __for_range = (range_expr);
	rather than static constexpr auto &&__for_range = range_expr;.

	* g++.dg/cpp26/expansion-stmt1.C (N::begin, N::end, O::begin,
	O::end): Change argument type from B & to const B & or from
	D & to const D &.
	* g++.dg/cpp26/expansion-stmt2.C (N::begin, N::end, O::begin,
	O::end): Likewise.
	* g++.dg/cpp26/expansion-stmt3.C (N::begin, N::end, O::begin,
	O::end): Likewise.
	* g++.dg/cpp26/expansion-stmt16.C: Expect different diagnostics
	for C++11.
	* g++.dg/cpp26/expansion-stmt18.C (N::begin, N::end): Change
	argument type from B & to const B &.
	* g++.dg/cpp26/expansion-stmt25.C (N::begin, N::end): Likewise.
	* g++.dg/cpp26/expansion-stmt26.C: New test.
	* g++.dg/reflect/p3491-2.C (baz): Move workaround to a new
	function garply, use the previously #if 0 guarded implementation.
	(garply): New function.
2026-01-29 09:49:51 +01:00
Pietro Monteiro
73650105ba libffi: Remove more unneeded files when merging
Delete .allow-ai-service and .gail-labels which are present in newer
versions of libffi.

libffi/ChangeLog:
	PR libffi/117635
	* merge.sh: Delete .allow-ai-service and .gail-labels when
	merging new upstream versions.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2026-01-28 20:16:04 -05:00
Pietro Monteiro
f32faca4e8 libffi: Add missing GCC patches to LOCAL_PATCHES
Add all the patches to GCC's copy of libffi to LOCAL_PATCHES.  I
skipped patches that only regenerate the configure script because it
doesn't come from upstream.

libffi/ChangeLog:
	PR libffi/117635
	* LOCAL_PATCHES: Add missing patches.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2026-01-28 20:16:04 -05:00
Jose E. Marchesi
e41a344ccf a68: support FFI with C via formal holes
This commit adds FFI support to access C variables and call C
functions from Algol 68, using the construct specified by the Modules
and Separated compilation facilities intended to that effect: formal
holes (`nest' constructs).

Briefly put, an `int foo' C variable can be accessed from Algol 68
like:

  int foo = nest C "foo";
  if foo > 10 then ... fi;

A ref to a C variable `int counter', that allows to modify it as well
as read it:

  ref int counter = nest C "&counter";
  counter +:= 1;

The address stored in an `int *ptr' variable, as an Algol 68
reference:

  ref int ptr = nest C "ptr";
  ptr := 100; { Changes the integer pointed by the C ptr }

Calling the standard C `random' function:

  proc long int random = nest C "random";
  if random < 100 then ... fi;

Some tests and an sketchy section in the manual are also included.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/algol68/ChangeLog

	* ga68.vw: Fix grammar for formal holes.
	* ga68.texi (Particular programs): New section.
	(Comments): Likewise.
	* a68.h: Prototypes for a68_is_c_mode, a68_make_fomal_hole_decl,
	a68_lower_formal_hole.
	* a68-parser-attrs.def (FORMAL_HOLE): New attribute.
	(LANGUAGE_INDICANT): Likewise.
	* a68-parser-extract.cc (a68_elaborate_bold_tags): Elaborate
	language indicants.
	* a68-parser-moids-check.cc (mode_check_unit): Check mode in
	formal holes.
	* a68-low-units.cc (a68_lower_formal_hole): New function.
	* a68-low.cc (a68_make_formal_hole_decl): Likewise.
	* a68-moids-misc.cc (a68_is_c_mode): Likewise.
	* a68-parser-bottom-up.cc (reduce_formal_holes): Likewise.

gcc/testsuite/ChangeLog

	* algol68/compile/error-nest-1.a68: New test.
	* algol68/compile/nest-c-1.a68: Likewise.
	* algol68/compile/error-nest-5.a68: Likewise.
	* algol68/compile/error-nest-4.a68: Likewise.
	* algol68/compile/error-nest-3.a68: Likewise.
	* algol68/compile/error-nest-2.a68: Likewise.
2026-01-29 01:37:57 +01:00
GCC Administrator
67bb07e672 Daily bump. 2026-01-29 00:16:45 +00:00
Eric Botcazou
a697610ed4 Ada: Fix crash on Unchecked_Union parameter with -gnateV -gnata
The problem is that the compiler generates 'Valid_Scalars for a formal
parameter of an Unchecked_Union type, which cannot work because it is not
possible to find out where the scalars are in it, given that the parameter
does not contain the discriminants of its Unchecked_Union type.  This also
changes -gnateV to work without the need for -gnata, as there is no mention
of this dependence in the documentation.

gcc/ada/
	PR ada/123857
	* checks.adb (Apply_Parameter_Validity_Checks.Add_Validity_Check):
	Set Is_Checked on the generated {Pre,Post}_Condition pragma and
	bail out if the parameter is of an Unchecked_Union type.

gcc/testsuite/
	* gnat.dg/unchecked_union4.adb: New test.
2026-01-28 23:56:27 +01:00
Eric Botcazou
ea0f31d040 Ada: Fix stack corruption with concatenation and 'Image of composite type
The issue is that the expansion of 'Image for composite types is heavyweight
and involves a mix of Expression_With_Actions and controlled object that
does not work properly when it is the argument of a call to a subprogram,
so this replaces it by the canonical scheme used for controlled temporaries.

gcc/ada/
	PR ada/123832
	* exp_imgv.adb: Add with and use clauses for Exp_Ch7.
	(Expand_Image_Attribute): Establish a transient scope before
	rewriting the attribute as a call to Put_Image.
	(Expand_Wide_Image_Attribute): Likewise.
	(Expand_Wide_Wide_Image_Attribute): Likewise.
	* exp_put_image.ads (Build_Image_Call): Add note about the
	need for a transient scope when the function is invoked.
	* exp_put_image.adb (Build_Image_Call): Call Insert_Actions
	to immediately insert the actions instead of wrapping them
	in an Expression_With_Actions node.

gcc/testsuite/
	* gnat.dg/put_image2.adb: New test.
2026-01-28 23:56:27 +01:00
Iain Buclaw
ddf94524f9 d: Fix ICE in ExprVisitor::visit, at d/expr.cc:2224 [PR123419]
The original assert expected the type of `__traits(initSymbol)' to be
exactly `const(void[])', but because D strips const from arrays to allow
passing slices as mutable ranges to template functions, so it got turned
into `const(void)[]'.

	PR d/123419

gcc/d/ChangeLog:

	* expr.cc (ExprVisitor::visit (VarExp *)): Adjust assertion.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr123419.d: New test.
2026-01-28 23:26:47 +01:00
Iain Buclaw
a1adc5aa30 d: Fix ICE: in output_constructor_regular_field, at varasm.cc:5500 [PR123798]
PR d/123798

gcc/d/ChangeLog:

	* types.cc (insert_aggregate_bitfield): Set DECL_NONADDRESSABLE_P and
	DECL_PADDING_P on bit-field decls.
	(finish_aggregate_type): Pass the aligned bit offset to layout_decl.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr123798.d: New test.
2026-01-28 22:35:31 +01:00