Commit Graph

226751 Commits

Author SHA1 Message Date
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
Uros Bizjak
b20e68022a i386: Use x >> ~y for x >> 31-y [PR36503]
x86 targets mask 32-bit shifts with a 5-bit mask (and 64-bit with 6-bit mask),
so they can use x >> ~y instead of x >> 31-y.

The optimization converts:

	movl    $31, %ecx
        subl    %esi, %ecx
        sall    %cl, %eax

to:
        notl    %ecx
        sall    %cl, %eax

	PR target/36503

gcc/ChangeLog:

	* config/i386/i386.md (*<insn:any_shift><mode:SWI48>3_sub):
	Also allow operands[3] & (<mode_bitsize>-1) == (<mode_bitsize>-1)
	in insn condition. Emit NOT RTX instead of NEG RTX in this case.
	(*<insn:any_shift><mode:SWI48>3_sub_1): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr36503-5.c: New test.
	* gcc.target/i386/pr36503-6.c: New test.
2026-01-28 21:59:19 +01:00
Robin Dapp
cb0d29db88 RISC-V: Fix ABI vector passing on stack and GPR [PR123824].
Krister reported that we violate the psABI when one vector argument
halfway fits into a register:

"Aggregates whose total size is no more than 2×XLEN bits are passed in a
pair of registers; if only one register is available, the first XLEN
bits are passed in a register and the remaining bits are passed on the
stack. If no registers are available, the aggregate is passed on the
stack."

This patch fixes this oversight and adds a few tests.

Regtested on rv64gcv_zvl512b.

	PR target/123824

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_vls_mode_fits_in_gprs_p): New
	helper.
	(riscv_pass_vls_aggregate_in_gpr): Use helper and distribute
	half-fitting vector to GPR and stack.
	(riscv_pass_aggregate_in_vr): Reformat comment.
	(riscv_get_arg_info): Use helper.
	(riscv_pass_by_reference): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/abi/vls-gpr-1.c: New test.
	* gcc.target/riscv/abi/vls-gpr-10.c: New test.
	* gcc.target/riscv/abi/vls-gpr-11.c: New test.
	* gcc.target/riscv/abi/vls-gpr-12.c: New test.
	* gcc.target/riscv/abi/vls-gpr-13.c: New test.
	* gcc.target/riscv/abi/vls-gpr-14.c: New test.
	* gcc.target/riscv/abi/vls-gpr-2.c: New test.
	* gcc.target/riscv/abi/vls-gpr-3.c: New test.
	* gcc.target/riscv/abi/vls-gpr-4.c: New test.
	* gcc.target/riscv/abi/vls-gpr-5.c: New test.
	* gcc.target/riscv/abi/vls-gpr-6.c: New test.
	* gcc.target/riscv/abi/vls-gpr-7.c: New test.
	* gcc.target/riscv/abi/vls-gpr-8.c: New test.
	* gcc.target/riscv/abi/vls-gpr-9.c: New test.
2026-01-28 20:04:50 +01:00
Andrew Pinski
00956e55dd C/C++: Better notification if misused a function like macro [PR102846]
Currently if assert is misused, e.g. like passing to a function like a
function pointer, GCC suggests to include assert.h/cassert. But since
it is already included that is just a bogus suggestion. Instead we should
see if a function-like macro is that same name (in the case of assert it will be),
and inform the user that it is being mis-used.

	PR c++/102846
	PR c/102846

gcc/c-family/ChangeLog:

	* known-headers.cc (macro_like_function_used::macro_like_function_used): New.
	(macro_like_function_used::~macro_like_function_used): New.
	* known-headers.h (class macro_like_function_used): New class.

gcc/c/ChangeLog:

	* c-decl.cc (lookup_name_fuzzy): Lookup function-like macro and
	notify of misuse there.

gcc/cp/ChangeLog:

	* name-lookup.cc (lookup_name_fuzzy): Lookup function-like macro and
	notify of misuse there.

gcc/testsuite/ChangeLog:

	* c-c++-common/function-like-macro-1.c: New test.
	* c-c++-common/function-like-macro-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-01-28 10:20:38 -08:00
Iain Buclaw
baaa412ae7 d: Fix ICE: in expand_asm_stmt, at cfgexpand.cc:3445 [PR121477]
The d_mark_addressable routine that sets TREE_ADDRESSABLE in the D
front-end did not handle DECL_BIT_FIELD.

	PR d/121477

gcc/d/ChangeLog:

	* d-codegen.cc (d_mark_addressable): Give an error if taking the
	address of a DECL_BIT_FIELD.

gcc/testsuite/ChangeLog:

	* gdc.dg/pr121477.d: New test.
2026-01-28 18:41:27 +01:00
Vladimir N. Makarov
da65c9d0ae [PR121571, LRA]: Reprocess asm insn with different preferences when there are no enough regs for the asm-insn
The test for the PR contains asm insn requiring 7 general regs but
three operands can be in memory too ('g' constraint).  There are only
6 available general regs.  IRA in the test case assigns a mask reg to
one pseudo.  When LRA reloads the pseudo assigned to mask reg, it
frees general reg assigned to another pseudo in the asm and assigns
mask reg to another pseudo.  After a few iterations, we have asm all
operands of which are reload pseudos assigned to general regs and one
pseudo assigned to mask reg.  After that LRA can do nothing and
reports "not enough regs".  The patch recognizes situation when there
are not enough regs for an asm insn and makes 2nd attempt to find
reloads when memory for operands with 'g' or 'rm' constraint is
preferred.

gcc/ChangeLog:

	PR target/121571
	* lra-constraints.cc (process_alt_operands): Reprocess asm insn
	when there are no enough regs for the asm-insn.

gcc/testsuite/ChangeLog:

	PR target/121571
	* gcc.target/i386/pr121571.c: New.
2026-01-28 11:01:51 -05:00
Iain Buclaw
92f976fc2a d: RVO/NRVO not done when returning a copy constructor
RVO was already being done when returning a constructor call via a
temporary, which in the front-end AST looks like:

    return S.this((__tmp = {}, &__tmp), args...);

But this was not being done for copy construction calls, which instead
looks like:

    return __copytmp = {}, S.this(&__copytmp, V(1).s), __copytmp;

This pattern is now matched and the temporary gets set up as a
DECL_VALUE_EXPR of the RESULT_DECL.

	PR d/123422

gcc/d/ChangeLog:

	* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Don't add
	TARGET_EXPR around constructor.
	* toir.cc (IRVisitor::visit (ReturnStatement *)): Recognize more
	patterns for return value optimization.

gcc/testsuite/ChangeLog:

	* gdc.dg/torture/pr123422.d: New test.
2026-01-28 15:50:00 +01:00
Senthil Kumar Selvaraj
3090d28ab3 c: Fix parser error on address space names [PR 123583]
This patch fixes a regression introduced by PR 67784
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67784) - it broke
recognition of named address space qualifiers (such as __memx on
AVR or __seg_gs on x86) after certain statements.

The fix for PR 67784 attempts to reclassify tokens whose
token->id_kind could have been set incorrectly (because of possibly
wrong scope when peeking ahead). c_parser_maybe_reclassify_token
only skips reclassification for C_ID_CLASSNAME though - a token with
id_kind = C_ID_ADDRSPACE ends up getting reclassified as C_ID_ID,
eventually causing a ": error: '<address space name>' undeclared"
error later down the line.

Rather than explicitly excluding C_ID_ADDRSPACE, the patch modifies
the check to reclassify only tokens kinds that could potentially get
incorrectly classified - C_ID_ID and C_ID_TYPENAME.

Bootstrapped and regtested on x86_64-linux.

	PR c/123583

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_maybe_reclassify_token): Reclassify only
	C_ID_ID and C_ID_TYPENAME tokens.

gcc/testsuite/ChangeLog:

	* gcc.target/avr/pr123583.c: New test.
	* gcc.target/i386/pr123583.c: New test.
2026-01-28 19:35:44 +05:30
Richard Biener
2672387929 middle-end/123575 - fix ABS_EXPR folding for vectors
Folding away a conversion requires an optab check for vectors.

	PR middle-end/123575
	* match.pd (abs ((T)x) -> absu (x)): For vector type
	arguments require the resulting operation is supported.

	* g++.dg/pr123575.C: New testcase.
2026-01-28 14:56:22 +01:00
Jonathan Wakely
833cbd870f libstdc++: Default to C++20 in src/experimental/Makefile.am
r16-7089-gfbde291af66e02 had a stray change to the Makefile.in but
actually we probably should change that directory to use C++20, now that
it's the default. So this updates the Makefile.am, and the Makefile.in
doesn't need to be regenerated now.

libstdc++-v3/ChangeLog:

	* src/experimental/Makefile.am: Change AM_CXXFLAGS to use C++20
	by default.
2026-01-28 12:19:37 +00:00
Jonathan Wakely
f362763f62 libstdc++: Do not allow contract26.cc to build without -fcontracts
It seems prefereable to get a hard error if this file is built
incorrectly, rather than failing to define any symbols.

libstdc++-v3/ChangeLog:

	* src/experimental/contract26.cc: Use #error if built without
	contracts support enabled.
	* include/std/source_location: Remove stray whitespace.
2026-01-28 12:19:08 +00:00
Richard Biener
8c0458505a ipa/111036 - strip nop conversions around __builtin_constant_p arguments
The PR is about inconsistent behavior wrt inline predicate analysis
and later folding of __builtin_constant_p which ultimatively results
from fold_builtin_constant_p stripping nops off its argument but
this not being done on GIMPLE.  The following adds a match.pd pattern
for this.

	PR ipa/111036
	* match.pd (__builtin_constant_p ((T)x)): Strip nop-conversions
	from __builtin_constant_p arguments.

	* gcc.dg/torture/pr111036.c: New testcase.
2026-01-28 12:52:30 +01:00
Richard Biener
974182ec09 rtl-optimization/106859 - fix location dumping from var-tracking
We currently ICE when the locations include one without a setting insn.
Looking at cselib this seems to be a supported state so the following
arranges for this and dumps -1 as UID.

	PR rtl-optimization/106859
	* var-tracking.cc (val_store): Dump -1 as UID if setting_insn
	is NULL.
2026-01-28 12:52:30 +01:00
Richard Biener
6868526bb7 tree-optimization/123537 - fix too permissive .REDUC_* folding
The following restricts the allowed conversions to those maintaining
the element type size.

	PR tree-optimization/123537
	* match.pd (REDUC (@0 & @1) -> @0[I] & @1[I]): Restrict
	allowed conversions.

	* gcc.dg/pr123537.c: New testcase.
2026-01-28 12:52:30 +01:00
Karl Meakin
70870cc59e aarch64: FEAT_SVE_BFSCALE support
Add support for the `SVE_BFSCALE` architecture extension.

gcc/ChangeLog:

	* doc/invoke.texi: Document `+sve-bfscale` flag.
	* config/aarch64/aarch64.h (TARGET_SVE_BFSCALE): New macro.
	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
	Define `__AARCH64_FEATURE_SVE_BFSCALE`.
	* config/aarch64/aarch64-sve-builtins-base.cc: Skip constant
	folding for floating-point or unpredicated multiplications.
	* config/aarch64/aarch64-sve-builtins-sve2.def: New `SVE_FUNCTION`s.
	* config/aarch64/aarch64-sve.md: Modify insns for
	`SVE_COND_FP_BINARY_INT` to handle BF16 modes.
	* config/aarch64/aarch64-sve2.md
	(@aarch64_sve_<optab><mode>, @aarch64_sve_<optab><mode>_single): New insn for `BFSCALE`.
	Modify insns for `UNSPEC_FSCALE` to handle BF16 modes.
	* config/aarch64/iterators.md (SVE_FULL_F_SCALAR): Add `VNx8BF` to iterator.
	(SVE_FULL_F_BFSCALE): New iterator.
	(SVE_Fx24_BFSCALE): New iterator.
	(SVE_BFx24): New iterator.
	(UNSPEC_FMUL): New unspec.
	(V_INT_EQUIV): Add entries for BF16 modes.
	(b): Add entries for scalar float modes.
	(is_bf16): Add entries for BF16 modes and reformat.
	(SVSCALE_SINGLE_INTARG): Likewise.
	(SVSCALE_INTARG): Likewise.
	(SVE_FP_MULL): New iterator.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp: Add `sve-bfscale` to `sve_exts`.
	* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add test for `__ARM_SVE_FEATURE_BFSCALE`.
	* gcc.target/aarch64/sme2/acle-asm/mul_bf16_x2.c: New test.
	* gcc.target/aarch64/sme2/acle-asm/mul_bf16_x4.c: New test.
	* gcc.target/aarch64/sme2/acle-asm/scale_bf16_x2.c: New test.
	* gcc.target/aarch64/sme2/acle-asm/scale_bf16_x4.c: New test.
	* gcc.target/aarch64/sve/acle/asm/scale_bf16.c: New test.
	* gcc.target/aarch64/sve/acle/general-c/bfscale.c: New test.
2026-01-28 11:40:02 +00:00
Pengfei Li
7b29e31e69 expand: Increase stack slot alignment for STRICT_ALIGNMENT targets [PR123447]
PR123447 reports an ICE on AArch64 with "-O2 -mstrict-align" in subreg
lowering while decomposing the following multiword store RTL:

(insn 12 11 13 2 (set (mem/c:XI (plus:DI (reg/f:DI 64 sfp)
                (const_int -96 [0xffffffffffffffa0])) [0  S64 A8])
        (reg:XI 103)) "a.c":14:6 4861 {*aarch64_movxi}

This RTL originates from expanding the following GIMPLE statement:

_1 = BIT_FIELD_REF <{ 9, -64497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 256, 0>;

The operand is a constant _Decimal64 vector with BLKmode, so expand has
to materialize it in memory. Current get_object_alignment() returns a
1-byte guaranteed alignment for this VECTOR_CST, as indicated by A8 in
the RTL dump above. However, with "-mstrict-align" enabled, later subreg
lowering pass expects at least 64-bit alignment when it constructs a new
RTX to decompose the store into pieces. Because the original alignment
is too small, simplify_gen_subreg() returns NULL_RTX and an assertion is
hit.

This patch increases the stack slot alignment for STRICT_ALIGNMENT
targets, when the operand is forced into memory. The increased alignment
is capped by MAX_SUPPORTED_STACK_ALIGNMENT so it won't be too large.

Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.

gcc/ChangeLog:

	PR middle-end/123447
	* expr.cc (expand_expr_real_1): Increase stack slot alignment
	for STRICT_ALIGNMENT targets.

gcc/testsuite/ChangeLog:

	PR middle-end/123447
	* gcc.dg/pr123447.c: New test.
2026-01-28 11:36:39 +00:00
Iain Sandoe
bd0dde45a3 options: Fix a missing period on and option message.
As per subject.

gcc/c-family/ChangeLog:

	* c.opt: Append a period to the message for
	-fcontracts-client-check=.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 11:16:15 +00:00
Andre Vieira
aa8811570c vect: reconstruct vectype for non scalar masks
This reconstructs the masks vectype based on the the type set by the backend
for any non scalar masks, which resolves the ICE caused by the sve type
attribute in SVE types used for simdclones.

gcc/ChangeLog:

	PR target/123016
	* tree-vect-stmts.cc (vectorizable_simd_clone_call): use
	'build_truth_vector_type_for_mode' to reconstruct mask's vectype for
	non-scalar masks.

gcc/testsuite/ChangeLog:

	* gfortran.dg/vect/pr123016.f90: New test.
2026-01-28 11:13:44 +00:00
Jonathan Wakely
74e0bb3faa libstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197]
Speculative devirtualization in GCC 16 causes some false positive
warnings for unreachable paths. Use diagnostic pragmas to suppress
those warnings until the regression is fixed.

libstdc++-v3/ChangeLog:

	PR tree-optimization/122197
	* include/bits/shared_ptr_base.h (~_Sp_counted_deleter): Use
	diagnostic pragam to disable -Wfree-nonheap-object false
	positive.
	(~_Sp_counted_ptr_inplace): Likewise for -Warray-bounds false
	positive.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-01-28 10:28:09 +00:00
Jonathan Wakely
975025de35 libstdc++: Avoid -Wtype-limits warnings in locale/gnu/ctype_members.cc
On targets where wchar_t is unsigned we get warnings during the
libstdc++ build:

ctype_members.cc: In member function ‘virtual char std::ctype<wchar_t>::do_narrow(wchar_t, char) const’:
ctype_members.cc:224:14: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  224 |     if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
      |         ~~~~~^~~~
ctype_members.cc: In member function ‘virtual const wchar_t* std::ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*, char, char*) const’:
ctype_members.cc:247:21: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  247 |           if (*__lo >= 0 && *__lo < 128)
      |               ~~~~~~^~~~

This introduces a helper function that converts the wchar_t to an
unsigned type and then does the comparison. This means the comparison is
not target-dependent, and there's no more warning.

libstdc++-v3/ChangeLog:

	* config/locale/gnu/ctype_members.cc (use_table): New function.
	(ctype<wchar_t>::do_narrow): Use use_table.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-01-28 10:28:05 +00:00
Jakub Jelinek
bb5ebc9373 c++: Implement C++23 P2246R1 - Character encoding of diagnostic text
The following patch attempts to implement the C++23 P2246R1
Character encoding of diagnostic text paper.
Initially I thought there is nothing to do, but this patch shows
that there is (and I wonder if we shouldn't backport it to release
branches).  Though the patch is on top of the cpp_translate_string
libcpp addition from the reflection patchset (though, that is
quite small change that could be backported too).

We have various different encodings in play in GCC.
There is -finput-charset= defaulting to SOURCE_CHARSET, which is
almost always UTF-8 (but in theory could be UTF-EBCDIC if that really
works).  libcpp converts source from the input charset to SOURCE_CHARSET
initially.  And then we have -fexec-charset=, again defaulting to
SOURCE_CHARSET, -fwide-exec-charset=, then UTF-8, UTF-16 and UTF-32
for u8, u and U string literals and constants and finally user uses
some character set in the terminal in which gcc is running.

Now, I think we mostly just emit diagnostics in SOURCE_CHARSET,
there is identifier_to_locale function which uses UCNs if LC_CTYPE
CODESET is not UTF-8-ish, but I think we don't use it all the time.
Even then, there is really no support for outputing from SOURCE_CHARSET
UTF-8 to non-ASCII compatible terminal charsets.
So for now let's pretend that we are emitting diagnostics to UTF-8
capable terminal.

When reporting errors about identifiers in the source (which are in
SOURCE_CHARSET), we just emit those.  The paper talks about
deprecated & nodiscard attribute msgs, static_assert, #error (and for
C++26 it would talk about #warning, delete (reason) and static_assert
with constexpr user messages).  #error/#warning works fine on UTF-8
terminals, delete (reason) too (we don't translate the string literal
from SOURCE_CHARSET to exec-charset in that case), static_assert
with a string literal too (again, notranslate), __attribute__ form
of deprecated attribute too (again, !parser->translate_strings_p).
What doesn't work properly are C++11 attributes (standard or gnu::),
we do translate those to exec charset, except for C++26
standard deprecated/nodiscard (which aren't translated).  And static_assert
with user messages doesn't work, those really have to be in exec-charset
because we have no control on how user constructs the messages during
constexpr evaluation.

So, this patch for C++11 attributes if they have the first argument
of a CPP_STRING temporarily disables translation of that string, which
fixes [[gnu::deprecated ("foo")]], [[gnu::unavailable ("foo")]]
and for C++ < 26 also [[deprecated ("foo")]] and [[nodiscard ("foo")]].
And another change is convert back from exec-charset to SOURCE_CHARSET
the custom user static_assert messages (and also inline asm strings).
For diagnostics without this patch worst case we show garbage, but
for inline asm we actually then fail to assemble stuff when users
use the constexpr created string views with non-ASCII exec charsets.

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

	PR c++/102613
	* parser.cc: Implement C++23 P2246R1 - Character encoding of
	diagnostic text.
	(cp_parser_parenthesized_expression_list): For std attribute
	argument where the first argument is CPP_STRING, ensure the
	string is not translated.
	* semantics.cc: Include c-family/c-pragma.h.
	(cexpr_str::extract): Use cpp_translate_string to translate
	string from ordinary literal encoding to SOURCE_CHARSET.

	* g++.dg/cpp1z/constexpr-asm-6.C: New test.
	* g++.dg/cpp23/charset2.C: New test.
	* g++.dg/cpp23/charset3.C: New test.
	* g++.dg/cpp23/charset4.C: New test.
	* g++.dg/cpp23/charset5.C: New test.
2026-01-28 10:23:20 +01:00
Jakub Jelinek
72c20dda8e c++: Implement part of CWG3044
The following patch implements part of CWG3044 resolution.
Small part of it has been implemented already earlier (using ptrdiff_t
as the type of i rather than leaving that unspecified), part of it
can't be implemented until constexpr references are supported
(removal of static keywords), but the final CWG3044 resolution
wording states that it is begin + decltype(begin - begin){i}
rather than just begin + i.

The following patch implements that.

It broke a bunch of tests because I haven't implemented operator -
for those. fixed that too (plus added a testcase expected to fail
now with operator - not implemented).

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

	* pt.cc (finish_expansion_stmt): Implement part of CWG3044.
	Add to begin decltype(begin - begin){i} with std::ptrdiff_t
	i instead of just i.

	* g++.dg/cpp26/expansion-stmt1.C (A::operator -, C::operator -): New.
	* g++.dg/cpp26/expansion-stmt2.C (A::operator -, C::operator -): New.
	* g++.dg/cpp26/expansion-stmt3.C (A::operator -, C::operator -): New.
	* g++.dg/cpp26/expansion-stmt18.C  (A::operator -): New.
	* g++.dg/cpp26/expansion-stmt25.C: New test.
2026-01-28 10:08:14 +01:00
Jakub Jelinek
3d2a91a376 c, c++: Use c*_build_qualified_type instead of build_qualified_type from within build_type_attribute_qual_variant [PR101312]
The following testcases ICE in various ways because of the interaction
between attributes and C/C++ c*_build_qualified_type behavior on array
types and how they affect TYPE_CANONICAL.
For array types, C/C++ moves qualifiers to the element type, but
when a cv qualified array build that way has an attribute applied to it,
we call build_type_attribute_qual_variant and that doesn't have that
handling and builds non-qualified version of the array type with qualified
element type and puts it as TYPE_CANONICAL of the type with attribute
which is a distinct type copy.

The following patch adds a langhook, so that even
build_type_attribute_qual_variant uses for C/C++ for array types
c*_build_qualified_type.
There has been already a related langhook
lang_hooks.types.copy_lang_qualifiers used solely for C++, so instead
of adding another langhook this adds a combined langhook for those two,
where C can handle array types specially and otherwise build_qualified_type,
while C++ ditto + do the function/method type modifiers propagation as
well.

Unfortunately there is a terrible array_as_string hack used by some
of the middle-end warnings which creates some array type with sometimes
an artificial attribute and then has hacks in the c-family type printing
to tweak the printed form, and this hack relies on the previous behavior
of build_type_attribute_qual_variant where it even for C/C++ kept
element type quals unmodified and added normally invalid quals on the
array type itself.  The patch stops using build_type_attribute_qual_variant
for that and instead uses copy_node on the type and adjusts the quals and
adds the attribute to the copy and then ggc_frees it.  Also it renames the
attribute from "array" to "array " to make it clear it is internal
attribute users can't specify even in vendor attributes.

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

	PR c/101312
gcc/
	* langhooks.h (struct lang_hooks_for_types): Remove
	copy_lang_qualifiers.  Add build_lang_qualified_type.
	* langhooks.cc (lhd_build_lang_qualified_type): New function.
	* langhooks-def.h (lhd_build_lang_qualified_type): Declare.
	(LANG_HOOKS_COPY_LANG_QUALIFIERS): Remove.
	(LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Add.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Use
	LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE instead of
	LANG_HOOKS_COPY_LANG_QUALIFIERS.
	* attribs.cc (build_type_attribute_qual_variant): Use
	lang_hooks.types.build_lang_qualified_type instead of
	build_qualified_type and/or build_qualified_type with
	optional lang_hooks.types.copy_lang_qualifiers call.
	(attr_access::array_as_string): Use "array " attribute instead of
	"array".  If attribute has been created or intended quals differ
	from quals of build_array_type, use copy_node and adjust quals and
	attributes on the copy, print and then ggc_free.
gcc/c-family/
	* c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
	Look up "array " attribute instead of "array".
gcc/c/
	* c-tree.h (c_build_lang_qualified_type): Declare.
	* c-objc-common.h (LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Define.
	* c-objc-common.cc (c_build_lang_qualified_type): New function.
gcc/cp/
	* cp-tree.h (cxx_build_lang_qualified_type): Declare.
	* cp-objcp-common.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Remove.
	(LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Define.
	* tree.cc (cxx_build_lang_qualified_type): New function.
gcc/testsuite/
	* c-c++-common/pr101312-1.c: New test.
	* c-c++-common/pr101312-2.c: New test.
2026-01-28 09:50:26 +01:00
Jakub Jelinek
5c2a5bfcd4 free-lang-data: Remove C++ annotations [PR123837]
As mentioned in the PR and reproduced on the testcase, we ICE during
LTO streaming because C++ annotation arguments can contain trees LTO
streaming doesn't handle.
We don't really need annotations when the FE is done with the whole
TU, annotations are always TU local and not exposed to the rest and
used in consteval only stuff, so the following patch just removes
all annotations at free-lang-data time.

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

	PR c++/123837
	* ipa-free-lang-data.cc (find_decls_types_r): Remove C++ annotations
	from {DECL,TYPE}_ATRIBUTES.

	* g++.dg/reflect/annotations9.C: New test.
2026-01-28 09:48:10 +01:00
Andrew Pinski
5957ce932f waccess: Fix handling of extended builtin types [PR123849]
So DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE is not being handled
from the demangler in new_delete_mismatch_p. This adds the handling,
just like DEMANGLE_COMPONENT_BUILTIN_TYPE as there is no simple way
to compare the type you have to call into the demanager to do it
instead.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/123849

gcc/ChangeLog:

	* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE like DEMANGLE_COMPONENT_BUILTIN_TYPE.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wmismatched-new-delete-11.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-01-28 00:32:11 -08:00
Richard Biener
7fdb0e1b18 tree-optimization/110043 - avoid overflow in pointer-query
pointer-query is built around using offset_int to avoid needing
to deal with overflow.  This falls apart when trying to analyze
array accesses indexed by __int128.  So don't.

	PR tree-optimization/110043
	* pointer-query.cc (get_offset_range): Fail for integer
	types with precision larger than ptrdiff_type_node.

	* gcc.dg/torture/pr110043.c: New testcase.
2026-01-28 09:11:26 +01:00
Hongyu Wang
11ef3c2e4f i386: Drop mask subst for define_insn_and_split of extend [PR123779]
For define_insn_and_split, the subst applied only for the define_insn
part, not the define_split part. So several define_insn_and_split with
mask_name is actually producing non-splitable insns, resulting ICE in
lra. Separate them to define_insn_and_split for mask/nonmask variants
to generate corresponding splitters.

	PR target/123779

gcc/ChangeLog:

	* config/i386/sse.md (*sse4_1_<code>v8qiv8hi2<mask_name>_2):
	Rename to ...
	(*sse4_1_<code>v8qiv8hi2_2): ... this, and drop mask conditions.
	(*avx2_<code>v8qiv8si2<mask_name>_2): Rename to ...
	(*avx2_<code>v8qiv8si2_2): ... this, and likewise.
	(*sse4_1_<code>v4qiv4si2<mask_name>_2): Rename to ...
	(*sse4_1_<code>v4qiv4si2_2): ... this, and likewise.
	(*sse4_1_<code>v4hiv4si2<mask_name>_2): Rename to ...
	(*sse4_1_<code>v4hiv4si2_2): ... this, and likewise.
	(*avx2_<code>v4qiv4di2<mask_name>_2): Rename to ...
	(*avx2_<code>v4qiv4di2_2): ... this, and likewise.
	(*avx2_<code>v4hiv4di2<mask_name>_2): Rename to ...
	(*avx2_<code>v4hiv4di2_2): ... this, and likewise.
	(*sse4_1_<code>v2hiv2di2<mask_name>_2): Rename to ...
	(*sse4_1_<code>v2hiv2di2_2): ... this, and likewise.
	(*sse4_1_<code>v2siv2di2<mask_name>_2): Rename to ...
	(*sse4_1_<code>v2siv2di2_2): ... this, and likewise.
	(*avx512f_<code>v8qiv8di2<mask_name>_2): Rename to ...
	(*avx512f_<code>v8qiv8di2_2): ... this.
	(*avx512vl_<code>v8qiv8hi2_mask_2): New define_insn_and_split.
	(*avx512vl_<code>v8qiv8si2_mask_2): Likewise.
	(*avx512vl_<code>v4qiv4si2_mask_2): Likewise.
	(*avx512vl_<code>v4hiv4si2_mask_2): Likewise.
	(*avx512f_<code>v8qiv8di2_mask_2): Likewise.
	(*avx512vl_<code>v4qiv4di2_mask_2): Likewise.
	(*avx512vl_<code>v4hiv4di2_mask_2): Likewise.
	(*avx512vl_<code>v2hiv2di2_mask_2): Likewise.
	(*avx512vl_<code>v2siv2di2_mask_2): Likewise.

gcc/testsuite/ChangeLog:

	* g++.target/i386/pr123779.C: New test.
2026-01-28 14:03:48 +08:00
Soumya AR
68a1218c18 libstdc++: Implement std::atomic::fetch_min/max
This patch extends libstdc++ to implement C++26's atomic fetch min/max
operations.

The __atomic_fetch_minmaxable concept checks if __atomic_fetch_min and
__atomic_fetch_max builtins are implemented by the compiler. If not, fall back
to a CAS loop.

This patch was bootstrapped and regtested on aarch64-linux-gnu and
x86_64-linux-gnu, no regression.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h:
	Add fetch_min and fetch_max memberfunctions.
	* include/bits/version.def:
	Add __cpp_lib_atomic_min_max feature test macro.
	* include/bits/version.h (defined): Regenerate.
	* include/std/atomic: Extend for fetch_min/max non-member functions.
	* src/c++23/std.cc.in: Export atomic_fetch_min, atomic_fetch_max,
	atomic_fetch_min_explicit, atomic_fetch_max_explicit.
	* testsuite/29_atomics/atomic_integral/nonmembers_fetch_minmax.cc:
	New test.
	* testsuite/29_atomics/atomic_ref/integral_fetch_minmax.cc: New test.
2026-01-28 10:57:37 +05:30
Alex Yesmanchyk
6e9cf03a76 c++: Error diagnostics for pointer-to-member type [PR38612]
Consider the following ptrtomem4.C file.

Now for test1 and test3 it produces the following errors:

ptrtomem4.C: In function 'int test1(int Base::*, X*)':
ptrtomem4.C:8:21: error: pointer to member type 'int Base::*' incompatible with incomplete object type 'X'
ptrtomem4.C: In function 'int test3(int Base::*, Y*)':
ptrtomem4.C:22:21: error: pointer to member type 'int Base::*' incompatible with object type 'Y' because 'Y' is not derived from 'Base'

	PR c++/38612

gcc/cp/ChangeLog:

	* typeck2.cc (build_m_component_ref): Improve class mismatch
	diagnostic.

gcc/testsuite/ChangeLog:

	* g++.dg/diagnostic/ptrtomem4.C: New test.

Signed-off-by: Alex Yesmanchyk <aliaksandr.yesmanchyk@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
2026-01-28 10:52:32 +08:00
vspefs
fd7635c7d8 c++/modules: Handle reflection SPLICE_SCOPE tree node
This patch adds support for serializing and deserializing SPLICE_SCOPE trees
in C++20 modules implementation. SPLICE_SCOPE is introduced by C++26
reflection, notably used for dependent splice types, thus needing to be
exported/imported as part of the module interface. Not handling SPLICE_SCOPE
leads to ICE.

This patch also includes 2 simple test cases: one for exporting splice scope
types and another for importing them.

gcc/cp/

	* module.cc (trees_out::type_node): Add case for SPLICE_SCOPE.
	(trees_in::tree_node): Add case for SPLICE_SCOPE.

gcc/testsuite/

	* g++.dg/modules/splice-scope-tree_a.C: New test.
	* g++.dg/modules/splice-scope-tree_b.C: New test.

Reviewed-by: Patrick Palka  <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-28 10:40:33 +08:00
Lucas Chollet
04ec3d4712 c++: Fix false positive with -Wunused [PR114450]
The patch fixes a bug in the detection of the usage of static variables
inside generic lambdas.  The comment in finish_id_expression_1 already
mentions this case, but the code didn't actually handle it.

	PR c++/114450

gcc/cp/ChangeLog:

	* lambda.cc (generic_lambda_fn_p): Handle null argument.
	* semantics.cc (finish_id_expression_1): Check for generic lambda.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wunused-var-42.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
2026-01-28 10:31:00 +08:00
Johannes Altmanninger
b0db0df2b2 c++: -Wunused-value on ternary indexed by non-constant
On this expression:

	(true ? "a" : "b")[index()]

"g++ -Wunused-value" incorrectly produces

	warning: left operand of comma operator has no effect [-Wunused-value]

From the -fdump-tree-original output:

	if ((void) SAVE_EXPR <index ()>, 1)
	  {
	    (void) "a"[SAVE_EXPR <index ()>];
	  }
	else
	  {
	    (void) "b"[SAVE_EXPR <index ()>];
	  }

Observe that we evaluate index() (and save it) before evaluating the
ternary expression.  Since "(void) SAVE_EXPR <index ()>" is ostensibly
side-effect free, we get this warning.  Since SAVE_EXPR is not useless,
this is a false positive. Also the comma operator compiler-generated,
so warning about it is wrong.

Suppress this warning for this implicit expression. Test that the
warning is gone for "$ternary[index()]" but we still warn on cases like
"$ternary[(1, 0)]".

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_array_ref): Suppress unused-value
	warning for implicit comma expression.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wunused-value-2.C: New test.

Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
2026-01-28 10:30:20 +08:00
Nina Ranns
9a8c08aaad c++, contracts: Add caller-side contract checks, and controls.
This a (currently GCC-only) extension that implements caller-side
checking of pre and post conditions.  It is completely in scope
with the C++26 CDIS wording, but is not mandated.

The implementation here allows applying caller or callee-side
checking independently.

gcc/c-family/ChangeLog:

	* c.opt (fcontracts-definition-check=,
	fcontracts-client-check=): New.
	* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

	* call.cc (build_cxx_call): Where enabled, wrap calls to
	functions with contract specifiers.
	* contracts.cc (enum contract_match_kind): Move to contracts
	header.
	(build_contract_condition_function): Copy caller-side wrapper
	state.
	(set_contract_wrapper_function, get_contract_wrapper_function,
	get_orig_func_for_wrapper, contracts_fixup_cdtorname,
	build_contract_wrapper_function,
	get_or_create_contract_wrapper_function): New.
	(start_function_contracts): Handle caller-side wrappers.
	(maybe_apply_function_contracts): Likewise.
	(copy_and_remap_contracts): Likewise.
	(should_contract_wrap_call, maybe_contract_wrap_call,
	define_contract_wrapper_func, emit_contract_wrapper_func): New.
	(finish_function_contracts): Handle caller-side wrappers.
	(get_src_loc_impl_ptr): Likewise.
	* contracts.h (DECL_IS_WRAPPER_FN_P): New.
	(enum contract_match_kind): Moved from contracts.cc.
	(copy_and_remap_contracts): Allow selection on the specific
	contract kind.
	(maybe_contract_wrap_call, emit_contract_wrapper_func): New.
	(set_decl_contracts): Delete dead code.
	* cp-tree.h (struct lang_decl_fn): Add wrapper function bit.
	(DECL_CONTRACT_WRAPPER): New.
	* decl2.cc (c_parse_final_cleanups): Emit wrappers.

gcc/ChangeLog:

	* doc/invoke.texi: Document -fcontracts-client-check= and
	-fcontracts-definition-check=.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-all.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-non-trivial.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-none.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-pre.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/ctor.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-post.C: New test.
	* g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-pre.C: New test.
	* g++.dg/contracts/cpp26/definition-checks/contract-assert-no-def-check.C: New test.
	* g++.dg/contracts/cpp26/non-trivial-ice.C: New test.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:26:26 +00:00
Nina Ranns
64674a295b c++, contracts: Allow contract checks as outlined functions.
In this variant of the contracts handling, we emit the contract
checks for pre and post conditions into small TU-local functions
that are then called in the relevant positions at the start of
the function and on each return edge (as a try-finally).

The rationale for adding this is that it is possible to treat
these outlined functions specially (for example, with different
(potentially fixed) optimisation settings from the code body.
Doing this can be a mechanism to work around cases where
optimisation of the contract conditions (or some function that
they might call) can lead to the elision of checks.

In order to pass parameters through to these small outlined
functions, we need similar functionality to that used for thunk
calls with respect copies of non-trivial values.  We are calling
this a "thunk-like" call, since none of the adjustments are
relevant here.

gcc/c-family/ChangeLog:

	* c.opt (fcontract-checks-outlined,
	fcontract-disable-optimized-checks): New.
	* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

	* contracts.cc (handle_contracts_p): Check that we are
	handling an original function, not an outlined check.
	(set_precondition_function, set_postcondition_function,
	get_orig_for_outlined, contracts_fixup_name,
	build_contract_condition_function,
	build_precondition_function, build_postcondition_function,
	build_contract_function_decls): New.
	(start_function_contracts): Update for the case that we
	outline the contract checks.
	(build_arg_list, build_thunk_like_call,
	add_pre_condition_fn_call,
	get_postcondition_result_parameter,
	add_post_condition_fn_call): New.
	(apply_preconditions): Allow outlined checks.
	(apply_postconditions): Likewise.
	(get_precondition_function, get_postcondition_function,
	set_contract_functions, remap_and_emit_conditions,
	finish_function_contracts): New.
	(get_src_loc_impl_ptr): Handle outlined checks.
	(build_contract_check): Likewise.
	* contracts.h (DECL_PRE_FN, DECL_POST_FN,
	DECL_IS_PRE_FN_P, DECL_IS_POST_FN_P,
	get_precondition_function, get_postcondition_function,
	get_orig_for_outlined, finish_function_contracts,
	set_contract_functions): New.
	* cp-tree.h (enum lang_contract_helper): New.
	(struct lang_decl_fn): Add contract helper enum.
	(CONTRACT_HELPER): New.
	(mangle_decl_string): New.
	* decl.cc (finish_function): Emit outlined checks when
	in use.
	* module.cc (trees_out::fn_parms_init): Stream pre and post
	outlined checks.
	(trees_in::fn_parms_init): Reload pre and post outlined checks.
	(check_mergeable_decl): Handle pre and post outlined functions.
	(module_state_config::get_dialect): Add contracts dialect.

gcc/ChangeLog:

	* doc/invoke.texi: Document -fcontract-checks-outlined and
	-fcontract-disable-optimized-checks.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/cpp26/outline-checks/freefunc-noexcept-post.C: New test.
	* g++.dg/contracts/cpp26/outline-checks/freefunc-noexcept-pre.C: New test.
	* g++.dg/contracts/cpp26/outline-checks/func-noexcept-assert.C: New test.
	* g++.dg/contracts/cpp26/outline-checks/memberfunc-noexcept-post.C: New test.
	* g++.dg/contracts/cpp26/outline-checks/memberfunc-noexcept-pre.C: New test.
	* g++.dg/contracts/cpp26/empty-nt-param.C: Test with outlined checks.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:26:10 +00:00
Iain Sandoe
7f914294fe c++, contracts: Add tests for C++26 contracts.
This adds in a set of tests for the C++26 contracts, and also ensures that
cases that previously failed with attribute syntax continue to work as
expected with the revised C++26 syntax.

	PR c++/113968
	PR c++/110871
	PR c++/110872

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/cpp26/BZ121936-workaround-noipa.C: New test.
	* g++.dg/contracts/cpp26/assertion-statement-errors.C: New test.
	* g++.dg/contracts/cpp26/assertion-statement.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p11-observe.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p14.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-2.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-3.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-4.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-5.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF-post.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF-pre.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF2.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF3.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF4.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p17.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p4-error.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p4.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p6.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p6.observe.C: New test.
	* g++.dg/contracts/cpp26/basic.scope.contract.p1.C: New test.
	* g++.dg/contracts/cpp26/basic.scope.contract.p2.1.C: New test.
	* g++.dg/contracts/cpp26/contract-assert-run.C: New test.
	* g++.dg/contracts/cpp26/contract-assert-warn-attributes.C: New test.
	* g++.dg/contracts/cpp26/contract-violation-noexcept.C: New test.
	* g++.dg/contracts/cpp26/contract-violation-noexcept2.C: New test.
	* g++.dg/contracts/cpp26/contract_genericize.C: New test.
	* g++.dg/contracts/cpp26/contracts-friend1.C: New test.
	* g++.dg/contracts/cpp26/contracts-nested-class1.C: New test.
	* g++.dg/contracts/cpp26/contracts-nested-class2.C: New test.
	* g++.dg/contracts/cpp26/contracts-tmpl-spec2.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.func.p4.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.func.p6.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.res.p1-NT.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.res.p1.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.res.p2.C: New test.
	* g++.dg/contracts/cpp26/debug-and-opt.C: New test.
	* g++.dg/contracts/cpp26/deferred1.C: New test.
	* g++.dg/contracts/cpp26/dependent_contract.C: New test.
	* g++.dg/contracts/cpp26/empty-nt-param.C: New test.
	* g++.dg/contracts/cpp26/function-contract-specifier-seq-error.C: New test.
	* g++.dg/contracts/cpp26/function-contract-specifier-seq.C: New test.
	* g++.dg/contracts/cpp26/lambda.C: New test.
	* g++.dg/contracts/cpp26/name_mangling.C: New test.
	* g++.dg/contracts/cpp26/over.call.func.p3.1.C: New test.
	* g++.dg/contracts/cpp26/pr113968.C: New test.
	* g++.dg/contracts/cpp26/src-loc-0.C: New test.
	* g++.dg/contracts/cpp26/src-loc-1.C: New test.
	* g++.dg/contracts/cpp26/src-loc-2.C: New test.
	* g++.dg/contracts/cpp26/throwing-violation-handler.cc: New test.
	* g++.dg/contracts/cpp26/unused_warning.C: New test.
	* g++.dg/contracts/cpp26/vaargs.C: New test.
	* g++.dg/contracts/cpp2a/check-err.C: New test.
	* g++.dg/coroutines/pr110871.C: New test.
	* g++.dg/coroutines/pr110872.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p8.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.func.p7.C: New test.
	* g++.dg/contracts/cpp26/dcl.contract.res.p1-2.C: New test.
	* g++.dg/contracts/cpp26/expr.prim.id.unqual.p7-2.C: New test.
	* g++.dg/contracts/cpp26/expr.prim.id.unqual.p7.C: New test.
	* g++.dg/contracts/cpp26/basic.contract.eval.p7.3.C: New test.
	* g++.dg/contracts/cpp26/intro.compliance.general.p2.3.4.C: New test.

Co-Authored-by: Nina Ranns <dinka.ranns@gmail.com>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:25:47 +00:00
Nina Ranns
fbde291af6 libstdc++, contracts: Add base P2900R14 contracts support.
What we need to do here (and, of course, in the code synthesis
that produces the objects) needs to be interoperable with other
platforms that share ABI.  For the present, this means Itanium
and to interoperate with clang and libc++.

The model we have followed in the development is essentially the
same as the model used for the C++2a edition.  However there is some
concern that the read-only data footprint of this is potentially
high and alternate schemes are in discussion with the clang folks.

Since the layout of the violation object is ABI let's leave this
in experimental until an agreed solution is fixed.

Remove the cxx2a support at the same time, GCC no longer supports
this mode.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add contract include.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def: Add ftm for contracts.
	* include/bits/version.h: Regenerate.
	* include/precompiled/stdc++.h: Add contracts header.
	* include/std/source_location: Befriend the contract_violation
	class so that we can initialise a source_location from an
	existing __impl *.
	* src/c++23/std.cc.in: Add contracts support.
	* src/experimental/Makefile.am: Add new contract violation
	implementation, remove the old one.
	* src/experimental/Makefile.in: Regenerate.
	* include/experimental/contract: Removed.
	* src/experimental/contract.cc: Removed.
	* include/std/contracts: New file.
	* src/experimental/contract26.cc: New file.
	* testsuite/18_support/contracts/invoke_default_cvh.cc: New test.
	* testsuite/18_support/contracts/invoke_default_cvh2.cc: New test.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Nina Ranns <dinka.ranns@gmail.com>
2026-01-28 01:25:12 +00:00
Nina Ranns
080b1cb5e4 c++, contracts: Apply P200R14 constification.
Split from the main patch as it was potentially contentious and might
have been altered by WG21 NB comment resolution. However, it most likely
makes sense to review in isolation (although we would expect to apply it
squashed into the base patch).

gcc/cp/ChangeLog:

	* contracts.cc (view_as_const, constify_contract_access,
	set_parm_used_in_post, check_param_in_postcondition,
	parm_used_in_post_p, check_postconditions_in_redecl): New.
	(check_redecl_contract): Handle constification.
	* contracts.h (constify_contract_access, view_as_const,
	contract_const_wrapper_p, strip_contract_const_wrapper): New.
	* cp-tree.h: Update tree flag usage comment.
	* lambda.cc (build_capture_proxy): Handle constification.
	* parser.cc (cp_parser_late_contract_condition, cp_parser_contract_assert,
	cp_parser_function_contract_specifier): Likewise.
	* pt.cc (tsubst_function_decl, tsubst_expr): Likewise.
	* semantics.cc (finish_id_expression_1, finish_decltype_type): Likewise.

gcc/ChangeLog:

	* tree.h (CONST_WRAPPER_P): New.

gcc/ChangeLog:

	* tree-core.h (struct tree_base): Update tree flag usage comment.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:24:51 +00:00
Nina Ranns
cac79586e1 c++, contracts: Work around GCC IPA bug, PR121936 by wrapping terminate.
This implements a no-ipa wrapper around the calls made from terminating
contract assertions so that callers can no longer make assuptions about
the no-return behaviour.  This is sufficient to work around the reported
bug while a suitable general fix is evaluated.

gcc/c-family/ChangeLog:

	* c.opt (fcontracts-conservative-ipa): New.

gcc/cp/ChangeLog:

	* contracts.cc (__tu_terminate_wrapper): New.
	(build_terminate_wrapper): New.
	(declare_terminate_wrapper): New.
	(maybe_emit_violation_handler_wrappers): Build a no-ipa wrapper
	for terminating contract violations if required.

gcc/ChangeLog:

	* doc/invoke.texi: Document -fcontracts-conservative-ipa.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:24:17 +00:00
Iain Sandoe
c928dc5196 c++, contracts: C++26 base implementation as per P2900R14.
This implementation performs the contracts application in three
phases:
    1. Parsing and semantic checks.
       Most of the code for this is in the parser, with helpers provided here.
    2. Emitting contract assertion AST nodes into function bodies.
       This is initiated from "finish_function ()"
    3. Lowering the contract assertion AST nodes to control flow, constant
       data and calls to the violation handler.
       This is initiated from "cp_genericize ()".

  Contract Assertion State
  ========================

  contract_assert () does not require any special handling and can be
  represented directly by AST inserted in the function body.

  'pre' and 'post' function contract specifiers require most of the special
  handling, since they must be tracked across re-declarations of functions and
  there are contraints on how such specifiers may change in these cases.

  The contracts specification identifies a "first declaration" of any given
  function - which is the first encountered when parsing a given TU.
  Subsequent re-declarations may not add or change the function contract
  specifiers from any introduced on this first declaration.  It is, however,
  permitted to omit specifiers on re-declarations.

  Since the implementation of GCC's (re-)declarations is a destructive merge
  we need to keep some state on the side to determine whether the re-declaration
  rules are met.  In this current design we have chosen not to add another tree
  to each function decl but, instead, keep a map from function decl to contract
  specifier state.  In this state we record the 'first declaration' specifiers
  which are used to validate re-declaration(s) and to report the initial state
  in diagnostics.

  We need (for example) to compare
    pre ( x > 2 ) equal to
    pre ( z > 2 ) when x and z refer to the same function parameter in a
    re-declaration.

  The mechanism used to determine if two contracts are the same is to compare
  the folded trees.  This makes use of current compiler machinery, rather than
  constructing some new AST comparison scheme.  However, it does introduce an
  additional complexity in that we need to defer such comparison until parsing
  is complete - and function contract specifiers in class declarations must be
  deferred parses, since it is also permitted for specifiers to refer to class
  members.

  When we encounter a definition, the parameter names in a function decl are
  re-written to match those of the definition (thus the expected names will
  appear in debug information etc).  At this point, we also need to re-map
  any function parameter names that appear in function contract specifiers
  to agree with those of the definition - although we intend to keep the
  'first declaration' record consistent for diagnostics.

  Since we shared some code from the C++2a contracts implementation, pre and
  post specifiers are represented by chains of attributes, where the payload
  of the attribute is an AST node.  However during the parse, these are not
  inserted into the function bodies, but kept in the decl-keyed state described
  above.  A future improvement planned here is to store the specifiers using a
  tree vec instead of the attribute list.

  Emitting contract AST
  =====================

  When we reach `finish_function ()` and therefore are committed to potentially
  emitting code for an instance, we build a new variant of the function body
  with the pre-condition AST inserted before the user's function body, and the
  post condition AST (if any) linked into the function return.

  Lowering the contract assertion AST
  ===================================

  In all cases (pre, post, contract_assert) the AST node is lowered to control
  flow and (potentially) calls to the violation handler and/or termination.
  This is done during `cp_genericize ()`.  In the current implementation, the
  decision on the control flow is made on the basis of the setting of a command-
  line flag that determines a TU-wide contract evaluation semantic, which has
  the following initial set of behaviours:

    'ignore'	    : contract assertion AST is lowered to 'nothing',
		      i.e. omitted.
    'enforce'	    : contract assertion AST is lowered to a check, if this
		      fails a violation handler is called, followed by
		      std::terminate().
    'quick_enforce' : contract assertion AST is lowered to a check, if this
		      fails, std::terminate () is called.
    'observe'	    : contract assertion AST is lowered to a check, if this
		      fails, a violation handler is called, the code then
		      continues.

  In each case, the "check" might be a simple 'if' (when it is determined that
  the assertion condition does not throw) or the condition evaluation will be
  wrapped in a try-catch block that treats any exception thrown when evaluating
  the check as equivalent to a failed check.  It is noted in the violation data
  object whether a check failed because of an exception raised in evaluation.

  At present, a simple (but potentially space-inefficient) scheme is used to
  store constant data objects that represent the read-only data for the
  violation.  The exact form of this is subject to revision as it represents
  ABI that must be agreed between implementations (as of this point, that
  discussion is not yet concluded).

gcc/c-family/ChangeLog:

	* c-common.cc: Add contract_assert keyword.
	* c-common.h (enum rid): Likewise.
	* c-cppbuiltin.cc (c_cpp_builtins): Add C++26 contracts feature test
	macro.
	* c.opt: Add a flag to control the TU-wide evaluation semantic. Add
	a flag to control whether P1494 observable_checkpoints are inserted
	to separate contract checks.
	* c.opt.urls: Regenerate.

gcc/ChangeLog:

	* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Add cases for contract
	constant data that need to be in independent link-time 'atoms'.
	* doc/invoke.texi: Document -fcontracts and
	-fcontract-evaluation-semantic=.

gcc/cp/ChangeLog:

	* class.cc (check_for_override): Diagnose attemtps to add contracts to
	virtual functions.
	* constexpr.cc (cxx_eval_builtin_function_call): Handle
	observable_checkpoints emitted for contracts.
	(cxx_eval_constant_expression): Check we do not see contract assertions
	here...
	(potential_constant_expression_1): ... but that we do here.
	* contracts.cc: Implement base C++26 P2600R14 contracts.
	* contracts.h: Likewise.
	* cp-gimplify.cc (cp_genericize_r): Lower contract assertions to control
	flow and calls (where required) to the violation handler.
	(fold_builtin_source_location): Use revised source_location impl.
	constructor.
	(build_source_location_impl): Split out the core of the constructor of
	source_location so that it can be re-used from the contracts code.
	* cp-tree.def (ASSERTION_STMT, PRECONDITION_STMT,
	POSTCONDITION_STMT): Revise to allow space for specifying a semantic,
	an assertion kind, and (where required) a source location.
	* cp-tree.h (enum cp_tree_index, builtin_contract_violation_type): Add
	the contract violation object type.
	(struct saved_scope): Add a contracts class pointer.
	(processing_postcondition, contract_class_ptr): New.
	(struct cp_declarator): Add contract_specifiers.
	(build_call_a_1): New.
	(build_source_location_impl): New.
	* decl.cc (duplicate_decls): Check function contract specifiers on
	redeclarations.  Handle contract specifiers on instantiations.
	(cxx_init_decl_processing): Initialise the terminate function since
	this can be called from contracts even when exception processing is
	disabled.  Build the contract violation object layout.
	(start_decl): Handle checking contract postcondition identifiers.
	(grokfndecl): Handle function contract specifiers.
	(grokdeclarator): Likewise.
	(start_preparsed_function): Start function contracts where needed.
	(finish_function): Emit contract specifier AST corresponding to the
	checked contracts.
	* decl2.cc (c_parse_final_cleanups): Emit helpers for contract
	violation handler calls.
	* lex.cc (cxx_init): Add keyword warning for contract_assert.
	* parser.cc (make_call_declarator): Add contract specifiers.
	(unparsed_contracts): New.
	(cp_parser_lambda_introducer): Allow contract specifier lambdas to have
	a capture default.
	(cp_parser_lambda_declarator_opt): Parse function contract specifiers.
	(make_dummy_lambda_op): Account for contract specifiers in declarator.
	(cp_parser_lambda_body): We have to ensure that deferred contracts are
	parsed before we finish the lambda.
	(cp_parser_statement): Handle contract_assert and diagnostics for
	misplaced pre and post conditions.
	(attr_chainon): Make this defensive against being passed a missing
	attribute list.
	(cp_parser_using_directive): Use attr_chainon instead of chainon.
	(contract_attribute_p): New.
	(cp_parser_init_declarator): Handle contract specifier names in
	attributes.
	(cp_parser_direct_declarator): Rename attrs to std_attrs for these.
	(cp_parser_type_specifier_seq): Allow for function contract specifiers.
	(cp_parser_class_specifier): Handle deferred parsing for function
	contract specifiers
	(cp_next_tokens_can_be_contract_attribute_p): True if this can be
	a function contract specifier (which appear in the same position
	as the attribute variant).
	(cp_next_tokens_can_be_std_attribute_p): Allow for contracts.
	(cp_nth_tokens_can_be_std_attribute_p): Likewise.
	(cp_next_tokens_can_be_attribute_p): Likewise.
	(cp_parser_late_contract_condition, cp_parser_late_contracts,
	cp_parser_contract_assert, cp_parser_function_contract_specifier,
	cp_parser_function_contract_specifier_seq): New.
	(cp_parser_skip_std_attribute_spec_seq): Handle contracts case.
	(cp_parser_skip_attributes_opt): Likewise.
	(cp_parser_save_default_args): Handle unparsed contract specs.
	* pt.cc (check_explicit_specialization): Handle removing contract
	specifiers from instances.
	(tsubst_contract, tsubst_contract_attribute,
	tsubst_contract_attributes): New.
	(tsubst_function_decl): Set contract specs. on substituted func.
	(tsubst_stmt): Handle contract_assert.
	(tsubst_expr): Allow for uses of postcondition uses of parm names.
	(regenerate_decl_from_template): Handle function contract specs.
	* semantics.cc (set_one_cleanup_loc): Add a location to
	postcondition specifiers.
	(finish_non_static_data_member): Diagnose bad uses of members
	in contract specifiers.
	(finish_this_expr): Diagnose invalid use of this in contract
	specifiers.
	(process_outer_var_ref): Allow use of params in contract specs.
	(finish_id_expression_1): Likewise.
	(apply_deduced_return_type): Maybe update postconditions when
	the return type is changed.
	* tree.cc (cp_tree_equal): Handle special cases when comparing
	contracts.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wkeyword-macro-1.C: Update for contract_assert.
	* g++.dg/warn/Wkeyword-macro-2.C: Likewise.
	* g++.dg/warn/Wkeyword-macro-4.C: Likewise.
	* g++.dg/warn/Wkeyword-macro-5.C: Likewise.
	* g++.dg/warn/Wkeyword-macro-7.C: Likewise.
	* g++.dg/warn/Wkeyword-macro-8.C: Likewise.

Co-Authored-by: Nina Ranns <dinka.ranns@gmail.com>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:23:34 +00:00
Iain Sandoe
918aa3fe87 c++, contracts: Add a contract scope per basic.scope.contract.
This adds a scope for contract assertions as per the standard section
referenced.  Split out here because it is the only part of the implementation
that touches the name lookup files.

gcc/cp/ChangeLog:

	* cp-tree.h (processing_contract_condition): New.
	* name-lookup.cc (cp_binding_level_descriptor): Add contract scope.
	(begin_scope): Likewise.
	* name-lookup.h (enum scope_kind): Add sk_contract.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:23:18 +00:00
Iain Sandoe
4e1f6865ac c++, contracts: Remove the abandoned C++2a implementation.
The C++26 contracts design bears little relationship with the abandoned C++2a one.
While we have, where possible, attempted to re-use code, the underlying syntax and
implementation are divergent.

We have thus decided to represent this as a new implementation, after first removing
the old one.  Trying to review the patches as changes between two different designs
would be quite confusing.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Remove C++2a-specific
	feature macros.
	* c.opt: Remove C++2a-specific flags.

gcc/cp/ChangeLog:

	* contracts.cc: Remove all C++2a contracts code.
	* contracts.h: Likewise.
	* coroutines.cc (coro_build_actor_or_destroy_function): Remove
	unused contracts references.
	* cp-gimplify.cc (cp_genericize_r): Remove C++2a contracts
	implementation.
	* cp-objcp-common.cc (cp_handle_option): Likewise.
	* cp-tree.h: Remove C++2a contracts code.
	* decl.cc: Likewise.
	* decl2.cc: Likewise.
	* mangle.cc: Likewise.
	* module.cc: Likewise.
	* parser.cc: Likewise.
	* pt.cc: Likewise.
	* search.cc: Likewise.
	* semantics.cc: Likewise.
	* tree.cc: Likewise.
	* constexpr.cc: Likewise.

gcc/ChangeLog:

	* doc/invoke.texi: Remove documentation of contracts options.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/contracts-access1.C: Removed.
	* g++.dg/contracts/contracts-assume1.C: Removed.
	* g++.dg/contracts/contracts-assume2.C: Removed.
	* g++.dg/contracts/contracts-assume3.C: Removed.
	* g++.dg/contracts/contracts-assume4.C: Removed.
	* g++.dg/contracts/contracts-assume5.C: Removed.
	* g++.dg/contracts/contracts-assume6.C: Removed.
	* g++.dg/contracts/contracts-comdat1.C: Removed.
	* g++.dg/contracts/contracts-config1.C: Removed.
	* g++.dg/contracts/contracts-constexpr1.C: Removed.
	* g++.dg/contracts/contracts-constexpr2.C: Removed.
	* g++.dg/contracts/contracts-constexpr3.C: Removed.
	* g++.dg/contracts/contracts-conversion1.C: Removed.
	* g++.dg/contracts/contracts-ctor-dtor1.C: Removed.
	* g++.dg/contracts/contracts-ctor-dtor2.C: Removed.
	* g++.dg/contracts/contracts-cv1.C: Removed.
	* g++.dg/contracts/contracts-deduced1.C: Removed.
	* g++.dg/contracts/contracts-deduced2.C: Removed.
	* g++.dg/contracts/contracts-err1.C: Removed.
	* g++.dg/contracts/contracts-externC.C: Removed.
	* g++.dg/contracts/contracts-friend1.C: Removed.
	* g++.dg/contracts/contracts-ft1.C: Removed.
	* g++.dg/contracts/contracts-ignore1.C: Removed.
	* g++.dg/contracts/contracts-ignore2.C: Removed.
	* g++.dg/contracts/contracts-large-return.C: Removed.
	* g++.dg/contracts/contracts-multiline1.C: Removed.
	* g++.dg/contracts/contracts-multiple-inheritance1.C: Removed.
	* g++.dg/contracts/contracts-multiple-inheritance2.C: Removed.
	* g++.dg/contracts/contracts-nested-class1.C: Removed.
	* g++.dg/contracts/contracts-nested-class2.C: Removed.
	* g++.dg/contracts/contracts-nocopy1.C: Removed.
	* g++.dg/contracts/contracts-override.C: Removed.
	* g++.dg/contracts/contracts-post1.C: Removed.
	* g++.dg/contracts/contracts-post2.C: Removed.
	* g++.dg/contracts/contracts-post3.C: Removed.
	* g++.dg/contracts/contracts-post4.C: Removed.
	* g++.dg/contracts/contracts-post5.C: Removed.
	* g++.dg/contracts/contracts-post6.C: Removed.
	* g++.dg/contracts/contracts-post7.C: Removed.
	* g++.dg/contracts/contracts-pre1.C: Removed.
	* g++.dg/contracts/contracts-pre10.C: Removed.
	* g++.dg/contracts/contracts-pre2.C: Removed.
	* g++.dg/contracts/contracts-pre2a1.C: Removed.
	* g++.dg/contracts/contracts-pre2a2.C: Removed.
	* g++.dg/contracts/contracts-pre3.C: Removed.
	* g++.dg/contracts/contracts-pre4.C: Removed.
	* g++.dg/contracts/contracts-pre5.C: Removed.
	* g++.dg/contracts/contracts-pre6.C: Removed.
	* g++.dg/contracts/contracts-pre7.C: Removed.
	* g++.dg/contracts/contracts-pre9.C: Removed.
	* g++.dg/contracts/contracts-redecl1.C: Removed.
	* g++.dg/contracts/contracts-redecl2.C: Removed.
	* g++.dg/contracts/contracts-redecl3.C: Removed.
	* g++.dg/contracts/contracts-redecl4.C: Removed.
	* g++.dg/contracts/contracts-redecl5.C: Removed.
	* g++.dg/contracts/contracts-redecl6.C: Removed.
	* g++.dg/contracts/contracts-redecl7.C: Removed.
	* g++.dg/contracts/contracts-redecl8.C: Removed.
	* g++.dg/contracts/contracts-tmpl-attr1.C: Removed.
	* g++.dg/contracts/contracts-tmpl-spec1.C: Removed.
	* g++.dg/contracts/contracts-tmpl-spec2.C: Removed.
	* g++.dg/contracts/contracts-tmpl-spec3.C: Removed.
	* g++.dg/contracts/contracts1.C: Removed.
	* g++.dg/contracts/contracts10.C: Removed.
	* g++.dg/contracts/contracts11.C: Removed.
	* g++.dg/contracts/contracts12.C: Removed.
	* g++.dg/contracts/contracts13.C: Removed.
	* g++.dg/contracts/contracts14.C: Removed.
	* g++.dg/contracts/contracts15.C: Removed.
	* g++.dg/contracts/contracts16.C: Removed.
	* g++.dg/contracts/contracts17.C: Removed.
	* g++.dg/contracts/contracts18.C: Removed.
	* g++.dg/contracts/contracts19.C: Removed.
	* g++.dg/contracts/contracts2.C: Removed.
	* g++.dg/contracts/contracts20.C: Removed.
	* g++.dg/contracts/contracts22.C: Removed.
	* g++.dg/contracts/contracts24.C: Removed.
	* g++.dg/contracts/contracts25.C: Removed.
	* g++.dg/contracts/contracts3.C: Removed.
	* g++.dg/contracts/contracts35.C: Removed.
	* g++.dg/contracts/contracts4.C: Removed.
	* g++.dg/contracts/contracts5.C: Removed.
	* g++.dg/contracts/contracts6.C: Removed.
	* g++.dg/contracts/contracts7.C: Removed.
	* g++.dg/contracts/pr110159.C: Removed.
	* g++.dg/contracts/pr113968.C: Removed.
	* g++.dg/contracts/pr115434.C: Removed.
	* g++.dg/contracts/pr116490.C: Removed.
	* g++.dg/contracts/pr116607.C: Removed.
	* g++.dg/contracts/pr117579.C: Removed.
	* g++.dg/contracts/noexcept_preload_handler/Makefile: Removed.
	* g++.dg/contracts/noexcept_preload_handler/README: Removed.
	* g++.dg/contracts/noexcept_preload_handler/assert_fail.cpp: Removed.
	* g++.dg/contracts/noexcept_preload_handler/handle_contract_violation.cpp: Removed.
	* g++.dg/contracts/preload_handler/Makefile: Removed.
	* g++.dg/contracts/preload_handler/README: Removed.
	* g++.dg/contracts/preload_handler/assert_fail.cpp: Removed.
	* g++.dg/contracts/preload_handler/handle_contract_violation.cpp: Removed.
	* g++.dg/contracts/preload_nocontinue_handler/Makefile: Removed.
	* g++.dg/contracts/preload_nocontinue_handler/README: Removed.
	* g++.dg/contracts/preload_nocontinue_handler/assert_fail.cpp: Removed.
	* g++.dg/contracts/preload_nocontinue_handler/handle_contract_violation.cpp: Removed.
	* g++.dg/contracts/preload_nocontinue_handler/nocontinue.cpp: Removed.
	* g++.dg/contracts/backtrace_handler/Makefile: Removed.
	* g++.dg/contracts/backtrace_handler/README: Removed.
	* g++.dg/contracts/backtrace_handler/assert_fail.cpp: Removed.
	* g++.dg/contracts/backtrace_handler/example_out.txt: Removed.
	* g++.dg/contracts/backtrace_handler/example_pretty.txt: Removed.
	* g++.dg/contracts/backtrace_handler/handle_contract_violation.cpp: Removed.
	* g++.dg/contracts/backtrace_handler/prettytrace.sh: Removed.
	* g++.dg/coroutines/pr110871.C: Removed.
	* g++.dg/coroutines/pr110872.C: Removed.
	* g++.dg/modules/contracts-1_a.C: Removed.
	* g++.dg/modules/contracts-1_b.C: Removed.
	* g++.dg/modules/contracts-2_a.C: Removed.
	* g++.dg/modules/contracts-2_b.C: Removed.
	* g++.dg/modules/contracts-2_c.C: Removed.
	* g++.dg/modules/contracts-3_a.C: Removed.
	* g++.dg/modules/contracts-3_b.C: Removed.
	* g++.dg/modules/contracts-4_a.C: Removed.
	* g++.dg/modules/contracts-4_b.C: Removed.
	* g++.dg/modules/contracts-4_c.C: Removed.
	* g++.dg/modules/contracts-4_d.C: Removed.
	* g++.dg/modules/contracts-5_a.C: Removed.
	* g++.dg/modules/contracts-5_b.C: Removed.
	* g++.dg/modules/contracts-tpl-friend-1_a.C: Removed.
	* g++.dg/modules/contracts-tpl-friend-1_b.C: Removed.
	* g++.dg/contracts/contracts8.C: Removed.
	* g++.dg/contracts/contracts9.C: Removed.
	* g++.dg/contracts/except_preload_handler/Makefile: Removed.
	* g++.dg/contracts/except_preload_handler/README: Removed.
	* g++.dg/contracts/except_preload_handler/assert_fail.cpp: Removed.
	* g++.dg/contracts/except_preload_handler/handle_contract_violation.cpp: Removed.

Co-Authored-by: Nina Ranns <dinka.ranns@gmail.com>

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2026-01-28 01:22:20 +00:00
GCC Administrator
a6201597c4 Daily bump. 2026-01-28 00:16:36 +00:00
Iain Buclaw
8e869a0d0e d: Side effects not evaluated for array literals on stack [PR120096]
PR d/120096

gcc/d/ChangeLog:

	* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Include saved side
	effects in expression result.

gcc/testsuite/ChangeLog:

	* gdc.dg/torture/pr120096.d: New test.
2026-01-27 23:35:24 +01:00
Rainer Orth
20bc4561ec build: Fix Linux/x86 bootstrap without --with-gnu-as/--with-as [PR123841]
My recent patch r16-7073 broke Linux/x86 bootstrap without
--with-gnu-as/with-as by only setting gcc_cv_as_flags in acinclude.m4
with gas_flag=yes.  Instead it should allow for any value.

Bootstrapped without regressions on x86_64-pc-linux-gnu,
i386-pc-solaris2.11 --with-gnu-as --with-as, and and
x86_64-apple-darwin21.6.0 (both in state 2 now with gcc/auto-host.h
unchanged).

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

	gcc:
	PR other/123841
	* acinclude.m4 (gcc_GAS_FLAGS) <i?86-*-* | x86_64-*-*>: Set
	gcc_cv_as_flags irrespective of $gas_flag.
	* configure: Regenerate.
2026-01-27 23:25:12 +01:00