Commit Graph

226840 Commits

Author SHA1 Message Date
GCC Administrator
56d85ab2a5 Daily bump. 2026-02-01 00:16:28 +00:00
Jose E. Marchesi
eabf7e0f72 a68: add TEST operator for bits to expanded prelude
This patch adds support for a TEST operator for L bits.  Documentation
and tests are included.

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

gcc/algol68/ChangeLog

	* a68.h: Prototypes for a68_bits_test and a68_lower_test3.
	* a68-low-bits.cc (a68_bits_test): New function.
	* a68-low-prelude.cc (a68_lower_test3): Likewise.
	* a68-parser-prelude.cc (gnu_prelude): Declare TEST operators and
	their priority.
	* ga68.texi (Extended bits operators): New section.

gcc/testsuite/ChangeLog

	* algol68/execute/bits-test-1.a68: New test.
2026-01-31 18:41:04 +01:00
Jose E. Marchesi
fecf1412b3 a68: add SET and CLEAR operators for L bits
This commit adds two more operators to the extended standard prelude
that work on L bits values.

Tests and documention included.

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

gcc/algol68/ChangeLog

	* ga68.texi (POSIX files): Document SET and CLEAR operators.
	* a68.h: Prototypes for a68_bits_set, a68_bits_clear,
	a68_lower_set3 and a68_lower_clear3.
	* a68-low-bits.cc (a68_bits_set): New function.
	(a68_bits_clear): Likewise.
	* a68-low-prelude.cc (a68_lower_set3): Likewise.
	(a68_lower_clear3): Likewise.
	* a68-parser-prelude.cc (gnu_prelude): Declare operators SET and
	CLEAR and their priorities.

gcc/testsuite/ChangeLog

	* algol68/execute/bits-clear-1.a68: New test.
	* algol68/execute/bits-set-1.a68: Likewise.
2026-01-31 18:41:04 +01:00
Keith Packard
9839ae8f24 [PATCH] picolibc: Use %:find-file for both test and access to picolibc.ld
If the gcc driver and linker don't agree on what the search path for
linker scripts is, then the driver may discover a file that
the linker won't end up using. This results in linking failures
when applications don't specific an explicit linker script.

Fix this by duplicating the call to %:find-file for both
test and in the parameter passed to the linker.

gcc/
	* config/picolibc-spec.h (LIBC_LINK_SPEC): Use find-file for test
	and access to picolibc.ld.
2026-01-31 07:00:26 -07:00
Richard Biener
cd6c3d19f6 middle-end/123887 - fix another missing side-effect check
The following fixes up another pattern lacking a check for
side-effects on operands made evaluated unconditional.

	PR middle-end/123887
	* match.pd ((a ? x : y) !=/== (b ? x : y)): Make sure
	x and y have no side-effects before evaluating them
	unconditionally.

	* gcc.dg/torture/pr123887-2.c: New testcase.
2026-01-31 13:05:22 +01:00
Paul Thomas
c40b573828 Fortran: Introduce macros IS_PDT and IS_CLASS_PDT
2026-01-31  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	* array.cc (resolve_array_list): Use macro IS_PDT.
	* gfortran.h : Supply macros IS_PDT and IS_CLASS_PDT.
	* match.cc (gfc_match_type_is): Use IS_PDT and IS_CLASS_PDT as
	appropriate.
	* resolve.cc (gfc_resolve_ref, build_init_assign,
	resolve_component): Likewise.
	* trans-array.cc (gfc_trans_array_constructor_value,
	trans_array_constructor, structure_alloc_comps,
	has_parameterized_comps): Likewise.
	* trans-decl.cc (gfc_get_symbol_decl, gfc_init_default_dt,
	gfc_trans_deferred_vars, gfc_generate_function_code): Likewise.
	* trans-expr.cc (conv_dummy_value, gfc_conv_structure,
	gfc_trans_assignment_1): Likewise.
	* trans-stmt.cc (trans_associate_var, gfc_trans_allocate,
	gfc_trans_deallocate): Likewise.
2026-01-31 10:34:26 +00:00
Nathaniel Shead
6bfec5d7b8 c++: Fix cp_fold_non_odr_use_1 [PR123557,PR123738]
This fixes two issues with cp_fold_non_odr_use_1:

- When called to fold away a reference, it considers the use to not be
  an lvalue and so 'maybe_constant_value' folds all the way through the
  nested INDIRECT_REF to a prvalue.  Fixed by folding the op0 of the
  INDIRECT_REF rather than the ref itself and avoiding a double
  cp_fold_non_odr_use_1.

- When used to fold away the initializing expression for an INIT_EXPR,
  it doesn't mark any new TARGET_EXPRs as eliding.  Fixed by reapplying
  'set_target_expr_eliding' for the initializer of an INIT_EXPR if it
  got modified during ff_only_non_odr walk.

	PR c++/123557
	PR c++/123738

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_fold_maybe_rvalue): Call
	cp_fold_non_odr_use_1 before recursing cp_fold.
	(cp_fold): Pass op0 to cp_fold_non_odr_use_1 when folding a
	reference.  Reapply set_target_expr_eliding on the initializing
	expression of an INIT_EXPR.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-ice22.C: New test.
	* g++.dg/cpp2a/constexpr-ref2.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-31 20:42:43 +11:00
Jakub Jelinek
d6386e0984 c++: Handle argument merging push_local_extern_decl_alias [PR123825]
The first testcase comes directly from
https://eel.is/c++draft/meta.reflection#names-1.8.2
and shows that we don't handle for -freflection the function
argument name difference handling isn't performed for local externs,
which doesn't go the duplicate_decls route but directly remembers
the alias.
The following patch handles outlines the DECL_ARGUMENTS handling
from duplicate_decls and uses it in push_local_extern_decl_alias
(with some minor differences and for now not propagating attributes
back for the push_local_extern_decl_alias case unless -freflection).

ALso, I found that the addition of a new alias created completely broken
DECL_ARGUMENTS (copied at most the first PARM_DECL, never more than that).
That is because copy_decl clears DECL_CHAIN, so the loop always stopped
after the first iteration.

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

	PR c++/123825
	* cp-tree.h (merge_decl_arguments): Declare.
	* decl.cc (duplicate_decls): Outline DECL_ARGUMENTS handling
	into ...
	(merge_decl_arguments): ... new function.
	* name-lookup.cc (push_local_extern_decl_alias): Call
	merge_decl_arguments.  Don't copy just the first PARM_DECL when
	creating a new alias FUNCTION_DECL.

	* g++.dg/reflect/has_identifier3.C: New test.
	* g++.dg/reflect/identifier_of3.C: New test.
	* g++.dg/cpp26/attr-indeterminate5.C: New test.
2026-01-31 10:19:26 +01:00
Iain Buclaw
8b0ccc95f1 d: Merge upstream dmd, druntime e1f6680f50, phobos f87979028
D front-end changes:

	- Import latest fixes from v2.112.0-beta.1.
	- Associative array operations are now lowered to templates
	  defined in `core.internal.newaa'.

D runtime changes:

	- Import latest fixes from v2.112.0-beta.1.

Phobos changes:

	- Import latest fixes from v2.112.0-beta.1.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd e1f6680f50.
	* Make-lang.in (D_FRONTEND_OBJS): Remove d/gluelayer.o, d/iasm.o,
	d/iasmgcc.o.  Add d/iasm-package.o, d/iasm-gcc.o.
	(d/iasm-%.o): New recipe.
	* d-convert.cc (convert_expr): Remove library call to dynamic_cast.
	* d-lang.cc (d_init_options): Set errorSupplementLimit parameter.
	* decl.cc (DeclVisitor::visit): Update for new front-end interface.
	* expr.cc (ExprVisitor::visit (EqualExp *)): Update for front-end
	lowering expression using templates.
	(ExprVisitor::visit (InExp *)): Likewise.
	(ExprVisitor::visit (IndexExp *)): Likewise.
	(ExprVisitor::visit (CastExp *)): Likewise.
	(ExprVisitor::visit (RemoveExp *)): Likewise.
	(ExprVisitor::visit (AddrExp *)): Likewise.
	(ExprVisitor::visit (NewExp *)): Likewise.
	(ExprVisitor::visit (ArrayLiteralExp *)): Likewise.
	(ExprVisitor::visit (AssocArrayLiteralExp *)): Likewise.
	* imports.cc (ImportVisitor::visit (AliasDeclaration *)): Update for
	new front-end interface.
	* runtime.def (DYNAMIC_CAST): Remove.
	(INTERFACE_CAST): Remove.
	(ARRAYLITERALTX): Remove.
	(ADEQ2): Remove.
	(ASSOCARRAYLITERALTX): Remove.
	(AANEW): Remove.
	(AAEQUAL): Remove.
	(AAINX): Remove.
	(AAGETY): Remove.
	(AAGETRVALUEX): Remove.
	(AADELX): Remove.
	* typeinfo.cc (TypeInfoVisitor::visit): Layout xopEquals and xtoHash
	in TypeInfo_AssociativeArray.
	(create_typeinfo): Add new fields to internal typeinfo.
	(check_typeinfo_type): Print instantiation trace of error.
	* types.cc (TypeVisitor::visit (TypeStruct *)): Update for new
	front-end interface.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime e1f6680f50.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
	core/internal/cast_.d.  Remove rt/aaA.d, rt/adi.d, rt/cast_.d.
	(DRUNTIME_DSOURCES_POSIX): Add core/sys/posix/endian.d.
	* libdruntime/Makefile.in: Regenerate.
	* src/MERGE: Merge upstream phobos f87979028.
	* src/Makefile.am (PHOBOS_DSOURCES): Add std/internal/entropy.d.
	* src/Makefile.in: Regenerate.
	* testsuite/libphobos.aa/test_aa.d: Adjust test.
	* testsuite/libphobos.init_fini/custom_gc.d: Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/asm1.d: Adjust test.
	* gdc.dg/asm5.d: Likewise.
	* gdc.dg/pr100967.d: Likewise.
	* gdc.dg/rtti1.d: Likewise.
	* gdc.dg/rtti2.d: New test.
2026-01-31 09:37:45 +01:00
Gerald Pfeifer
f96138ed6a doc: Switch delorie.com to https
gcc:
	* doc/install.texi (Binaries): Switch delorie.com to https.
2026-01-31 08:40:28 +01:00
Alexandre Oliva
c035985fd6 testsuite: arm: crypto-vsha1*_u32 tests got late-combine improvements
The late-combine pass enabled some of the vdup.32 instructions
expected in crypto-vsha1*_u32 tests to use d registers, so accept them
as well.

While at that, drop the excess + after ] in d register matches in
vmov.32 instructions.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/crypto-vsha1cq_u32.c: Accept d regs in
	vdup.32.  Drop extraneous + after ] in vmov.32 pattern.
	* gcc.target/arm/crypto-vsha1h_u32.c: Likewise.
	* gcc.target/arm/crypto-vsha1mq_u32.c: Likewise.
	* gcc.target/arm/crypto-vsha1pq_u32.c: Likewise.
2026-01-31 01:54:45 -03:00
Alexandre Oliva
45fb81866b testsuite: arm: add -mcpu=unset before -march
Reset the cpu selection to the default on tests that set -march
explicitly instead of using dg-add-options.  The latter would reset
the cpu selection to avoid interference from TOOL_OPTIONS.

Also add +fp to -march in tests that don't override float-abi and fpu,
so that -mfloat-abi=hard -mfpu=auto in TOOL_OPTIONS won't cause a
failure.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/bfloat16_simd_1_2.c: Add -mcpu=unset.
	* gcc.target/arm/bfloat16_simd_2_2.c: Likewise.
	* gcc.target/arm/bfloat16_simd_3_2.c: Likewise.
	* gcc.dg/torture/pr120347.c: Likewise.  Add +fp to -march.
2026-01-31 01:54:42 -03:00
Alexandre Oliva
9dceb52664 testsuite: arm: update fast-math-complex-mls-half-float.c
Since the addition of DCE after complex lowering, reassoc1 has no
longer been impeded by COMPLEX_EXPRs, so it changes (a - (b + c)),
where (b + c) is the imaginary part of an intermediate complex value,
to ((a - b) - c), and this prevents the vectorizer from recognizing
the expected COMPLEX_ADD_ROT270 pattern in fms_elemconjsnd.

Stop expecting that pattern to be found on that test.


for  gcc/testsuite/ChangeLog

	* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c:
	Don't expect COMPLEX_ADD_ROT270.
2026-01-31 01:51:53 -03:00
David Malcolm
b5d5cab8e4 analyzer: fix ICE on rethrow without throw [PR123880]
gcc/analyzer/ChangeLog:
	PR analyzer/123880
	* engine.cc (throw_custom_edge::update_model): Gracefully handle
	not knowing the current exception in a rethrow.
	(exploded_node::on_throw): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/123880
	* g++.dg/analyzer/exception-rethrow-3.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2026-01-30 23:27:40 -05:00
Pietro Monteiro
fc7081e1dc compare_tests: Don't hardcode grep -E
The non-unique test names report is broken on systems where 'grep -E' is
not supported.  Use egrep if a simple test for 'grep -E' fails.

contrib/ChangeLog:

	* compare_tests: Use egrep if 'grep -E' is not supported.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2026-01-30 22:27:14 -05:00
Jason Merrill
35b17c7713 c++: defer DECL_ONE_ONLY vs consteval-only [PR122785]
The failure in the given PR occurs because when setting up an
imported vague-linkage variable, we currently call 'maybe_commonize_var'
which for -freflection checks 'consteval_only_p'.  Unfortunately this
latter function needs to call 'complete_type_p' which can perform
recursive loading of the (possibly yet-to-be-streamed) class type,
breaking modules assumptions.

If we just remove the consteval_only_p early exit from maybe_commonize_var,
we end up crashing at EOF while trying to mangle its comdat group, so we
need to undo maybe_commonize_var along with setting DECL_EXTERN.

	PR c++/122785

gcc/cp/ChangeLog:

	* decl.cc (maybe_commonize_var): Don't check consteval_only_p.
	(make_rtl_for_nonlocal_decl): Undo make_decl_one_only for
	consteval-only variables.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/reflect-1_a.H: New test.
	* g++.dg/modules/reflect-1_b.C: New test.

Co-authored-by: Nathaniel Shead <nathanieloshead@gmail.com>
2026-01-31 10:16:08 +08:00
Patrick Palka
bdd45f4eee libstdc++/regex: Suppress -Wpedantic warning about anonymous structs
Fixes some modules testsuite compilation errors.

libstdc++-v3/ChangeLog:

	* include/bits/regex_executor.tcc (_ExecutorFrameBase): Add
	#pragma GCC diagnostic to suppress -Wpedantic warning about
	anonymous structs.
2026-01-30 21:01:08 -05:00
Pietro Monteiro
b129ff0880 libitm: testsuite: don't include libstdc++ paths in test names [PR69018]
Libitm C++ tests pass -B/full/path/to/build/libstc++/src/.libs on the
options argument to dg-runtest and the libstdc++ include paths as
the default-extra-options.  This causes 2 problems:

1) If a test uses `dg-options' then the libstdc++ include paths are
not passed to the compiler.

2) The `-B/full/path/to/build/libstc++/src/.libs' gets added to the
test name.  This makes comparing build done in different directories
harder because the hardcoded full path.

Stop passing options and default-extra-options to dg-runtest and move
dealing with the path-releated flags to libitm_target_compile in
libitm.exp, where they are added to additional_flags.

Also change the FSF address to the website in the license text.

libitm/ChangeLog:
	PR libitm/69018
	* testsuite/lib/libitm.exp (libitm_target_compile): Add
	lang_include_flags and `-B${blddir}/${lang_library_paths}' to
	additional_flags.
	* testsuite/libitm.c++/c++.exp: Set lang_library_paths and lang_include_flags.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2026-01-30 20:22:49 -05:00
GCC Administrator
7875ee88c3 Daily bump. 2026-01-31 00:16:35 +00:00
Jerry DeLisle
ca448bc5e4 Fortran: Fix PR123868
When copying derived types with allocatable array components where the
array element type also has allocatable components, the condition at
line 11071 was incorrectly triggering a call to gfc_duplicate_allocatable.
However, for allocatable arrays with nested allocatables (where
cmp_has_alloc_comps && c->as is true), the add_when_allocated code
already includes a gfc_duplicate_allocatable call (generated by the
recursive structure_alloc_comps call at lines 10290-10293).

This caused the outer array to be allocated twice: first by the explicit
gfc_duplicate_allocatable call at line 11099, and then again by the
gfc_duplicate_allocatable embedded in add_when_allocated.  The first
allocation was leaked when the second allocation overwrote the data
pointer.

PR121628 added "add_when_allocated != NULL_TREE ||" to the condition,
which was redundant for scalars (already handled by !c->as) and wrong
for arrays (caused double allocation).  Simply removing this clause
restores the correct pre-PR121628 behavior.

	PR fortran/123868

gcc/fortran/ChangeLog:

	* trans-array.cc (structure_alloc_comps): For COPY_ALLOC_COMP,
	remove the add_when_allocated != NULL_TREE clause that PR121628
	added.  This clause was redundant for scalars and caused double
	allocation for arrays with nested allocatable components.

gcc/testsuite/ChangeLog:

	* gfortran.dg/array_memcpy_2.f90: Update expected memcpy count
	from 4 to 3, as the double allocation bug is now fixed.
	* gfortran.dg/pr123868.f90: New test.

	Signed-off-by: Christopher Albert <albert@alumni.tugraz.at>
2026-01-30 13:38:43 -08:00
Patrick Palka
e4c57e146a c++: non-empty constexpr constructor bodies in C++11 [PR123845]
This patch makes us support C++14 non-empty constexpr constructor bodies
in C++11, as an extension.  This will make it trivial to safely fix the
C++11 library regression PR114865 that requires us to do
__builtin_clear_padding after initializing _M_i in std::atomic's
single-parameter constructor, and that's not really possible with the
C++11 constexpr restrictions.

Since we lower member initializers to constructor body statements
internally, and so constructor bodies are already effectively non-empty
internally even in C++11, supporting non-empty bodies in user code is
mostly a matter of relaxing the parse-time error.

But constexpr-ex3.C revealed that by accepting the non-empty body of A's
constructor, build_data_member_initialization goes on to mistake the
'i = _i' assignment as a member initializer, and we incorrectly accept
the constructor in C++11 mode (even though omitting mem-inits is only
valid since C++20).  Turns out this is caused by that function
recognizing MODIFY_EXPR only in C++11 mode, logic that was last changed
by r5-5013 (presumably to limit impact of the patch at the time) but I
reckon could just be removed outright.  This should be safe because the
result of build_data_member_initialization is only used by
cx_check_missing_mem_inits for validation; evaluation is in terms of
the entire lowered constructor body.

	PR c++/123845
	PR libstdc++/114865

gcc/cp/ChangeLog:

	* constexpr.cc (build_data_member_initialization): Remove
	C++11-specific recognition of MODIFY_EXPR.
	(check_constexpr_ctor_body): Relax error diagnostic to a
	pedwarn and don't clear DECL_DECLARED_CONSTEXPR_P upon
	error.  Return true if complaining.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-ex3.C: Adjust C++11 non-empty
	constexpr constructor dg-error to a dg-warning.  Expect
	a follow-up missing member initializer diagnostic in C++11 mode.
	* g++.dg/cpp2a/constexpr-try1.C: Expect a follow-up
	compound-statement in constexpr function diagnostic in C++11
	mode.
	* g++.dg/cpp2a/constexpr-try2.C: Likewise.  Adjust C++11
	non-empty constexpr constructor dg-error to a dg-warning.
	* g++.dg/cpp2a/constexpr-try3.C:  Adjust C++11 non-empty
	constexpr constructor dg-error to a dg-warning.
	* g++.dg/cpp0x/constexpr-ctor23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-30 15:25:43 -05:00
Richard Biener
c1fa15791a middle-end/123887 - trapping conditional operand turned unconditional
The following properly checks expr_no_side_effects_p on two patterns
that turns a conditionally evaluated operand into unconditonal.

	PR middle-end/123887
	* match.pd ((zero_one ==/!= 0) ? .. z <op> y .. -> zero_one * z ..):
	Check evaluating z unconditionally has no side-effects, like
	trapping.

	* gcc.dg/torture/pr123887.c: New testcase.
2026-01-30 19:21:58 +01:00
Richard Biener
2b44a1ab15 debug/123886 - remove GTY((skip)) from external_die_map entry
The following avoids GCing IDENTIFIER_POINTERs referenced from
external_die_map after we clear ggc_protect_identifiers.  I never
expected those to be GCed.

	PR debug/123886
	* dwarf2out.cc (sym_off_pair::sym): Remove GTY((skip)).
2026-01-30 19:19:58 +01:00
Patrick Palka
a8a1183d58 libstdc++/regex: add [[gnu::always_inline]] to _Executor::_M_node
The compiler understandably doesn't know that _M_node only ever has a
single call site, _M_dfs, (and is not directly called from other library
headers or user code) and so decides not to inline it.  So use the
always_inline attribute to force the inlining.  This seems sufficient to
make all _M_dfs subroutines get inlined away, and speeds up the executor
by 30% on some microbenchmarks.

libstdc++-v3/ChangeLog:

	* include/bits/regex_executor.tcc (__detail::_Executor::_M_node)
	[__OPTIMIZE__]: Add [[gnu::always_inline]] attribute.  Declare
	inline.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2026-01-30 13:16:20 -05:00
Gary Dismukes
f58b792238 Ada: Fix regression in visibility for nested use_type_clauses
An earlier fix for wrong handling of visibility when a use_type_clause
with "all" occurs within a nested scope when there's a use_type_clause
in an enclosing scope without "all" was incorrect and led to primitives
being visible in a later nested scope that has a use_type_clause with
"all" for the same type.  We now properly restore Current_Use_Clause
to refer to the outer use_type_clause when ending the scope of nested
use_type_clauses.

gcc/ada/
	* sem_ch8.adb (End_Use_Type): Remove test of Prev_Use_Clause as
	as a condition for resetting In_Use and Current_Use_Clause, and
	change setting of that flag and field based on Prev_Use_Clause
	rather than setting them to Empty. Revise preceding comment.
2026-01-30 18:47:56 +01:00
Patrick Palka
ead66d5f22 libstdc++/regex: Defer _M_current restoration to backtracking nodes [PR86164]
The incrementing of the current input string position (_M_current) is
done by _M_handle_match, which also makes sure to restore it afterwards,
via a restore_current frame.  But restoring _M_current is naturally only
necessary when backtracking is involved, not after every single match.

So this patch moves the responsibility of saving/restoring _M_current
from _M_handle_match to the branching nodes _M_handle_alternative and
_M_handle_repeat.  This is done by storing _M_current within the
fallback_next, fallback_rep_once_more and posix_alternative frames.
In turn we can get rid of the now unused restore_current frame kind.

This reduces the maximum size of the _M_frames stack by 15% for

  regex_match(string(200000, 'a'), "(a|b|c)*")

	PR libstdc++/86164

libstdc++-v3/ChangeLog:

	* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
	Remove _S_fopcode_restore_current.
	(__detail::_Executor::_M_handle_repeat): Pass _M_current when
	pushing a fallback_next or fallback_rep_once_more frame.
	(__detail::_Executor::_M_handle_match): Don't push a
	restore_current frame.
	(__detail::_Executor::_M_handle_backref): Likewise and simplify
	accordingly.
	(__detail::_Executor::_M_handle_alternative): Pass _M_current when
	pushing a fallback_next or posix_alternative frame.
	(__detail::_Executor::_M_dfs) <case _S_fopcode_fallback_next>:
	Restore _M_current.
	<case _S_fopcode_fallback_rep_once_more>: Likewise.
	<case _S_fopcode_posix_alternative>: Likewise.
	<case _S_fopcode_restore_current>: Remove.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2026-01-30 12:29:17 -05:00
Patrick Palka
158ad5f969 libstdc++/regex: Make DFS executor non-recursive [PR86164]
This patch replaces the recursive implementation of the DFS executor
with an iterative one using an explicit heap-based stack.  System
stack usage of the executor is now constant with respect to input size
rather than linear, avoding stack overflow errors when processing
long inputs.

	PR libstdc++/86164

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (__detail::_Executor): Use inline
	namespace _V2.
	* include/bits/regex_executor.h (__detail::_ExecutorFrame):
	Declare.
	(__detail::_Executor): Use inline namespace _V2.
	(__detail::_Executor::_M_node): Declare.
	(__detail::_Executor::_M_frames): New data member.
	* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
	New.
	(__detail::_ExecutorFrameBase): New.
	(__detail::_ExecutorFrame): New.
	(__detail::_Executor): Use inline namespace _V2.
	(__detail::_Executor::_M_rep_once_more): Replace recursive
	_M_dfs calls with an _S_opcode_next frame push, and any work
	after such calls with an appropriate frame push.
	(__detail::_M_handle_repeat): Likewise.
	(__detail::_M_handle_subexpr_begin): Likewise.
	(__detail::_M_handle_subexpr_end): Likewise.
	(__detail::_M_handle_line_begin_assertion): Likewise.
	(__detail::_M_handle_line_end_assertion): Likewise.
	(__detail::_M_handle_word_boundary): Likewise.
	(__detail::_M_handle_subexpr_lookahead): Likewise.
	(__detail::_M_handle_match): Likewise.
	(__detail::_M_handle_backref): Likewise.
	(__detail::_M_handle_accept): Likewise.
	(__detail::_M_handle_alternative): Likewise.
	(__detail::_M_node): Factored out from _M_dfs.
	(__detail::_M_dfs): Push an initial frame to _M_frames that
	visits the starting node and pass this stack each subroutine.
	Pop the latest _ExecutorFrame from _M_frames and handle
	appropriately according to its _ExecutorFrameOpcode.  Loop until
	_M_frames is empty.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2026-01-30 12:23:40 -05:00
Michal Jires
bf9abf065e doc: Explain flto-toplevel-asm-heuristics
This patch adds documentation for flto-toplevel-asm-heuristics
and mentions it in Remarks in Basic Asm.

gcc/ChangeLog:

	* doc/extend.texi: Mention flto-toplevel-asm-heuristics.
	* doc/invoke.texi: Add flto-toplevel-asm-heuristics.
2026-01-30 16:13:32 +01:00
Marek Polacek
f28f4ddcfd c++/reflection: check TYPE_BEING_DEFINED in define_aggregate
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we should check TYPE_BEING_DEFINED along with COMPLETE_TYPE_P in
eval_define_aggregate.  It seems that with this check added, we don't
need this code anymore:

      if (c == type)
        {
          auto_diagnostic_group d;
          error_at (loc, "%<define_aggregate%> evaluated from "
                         "%<consteval%> block enclosed by %qT being "
                         "defined", type);
	  //...
	}

so I'm removing that in this patch.

gcc/cp/ChangeLog:

	* reflect.cc (eval_define_aggregate): Also give an error when
	TYPE_BEING_DEFINED is true for the first argument.  Remove code
	that did the same.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/define_aggregate3.C: Adjust expected diagnostic.
	* g++.dg/reflect/p2996-21.C: Likewise.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2026-01-30 08:31:43 -05:00
Marek Polacek
35d45295f5 c++/reflection: tweak eval_can_substitute
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we should check for undeduced_auto_decl after performing
resolve_nondeduced_context_or_error.  Also add a test to exercise
the new check.

gcc/cp/ChangeLog:

	* reflect.cc (eval_can_substitute): Check undeduced_auto_decl after
	resolve_nondeduced_context_or_error.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/substitute3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
2026-01-30 08:26:04 -05:00
Pietro Monteiro
a2a7c49948 libga68: Use the internal malloc for UTF-32 to UTF-8 conversion
_libga68_u32_to_u8 called free on the result buffer on error, but the
buffer is allocated by the GC, so calling free on it is incorrect.

Instead of using the GC, use the internal malloc because this is an
internal function.

Remove the resultbuf parameter from the _libga68_u32_to_u8 since all
callers used NULL for it.

Last but not least, return a null-terminated char* from
_libga68_u32_to_u8.

libga68/ChangeLog:

	* ga68-alloc.c (_libga68_realloc_internal): New function.
	* ga68-posix.c (_libga68_posixperror): Adjust calls to _libga68_u32_to_u8.
	(_libga68_posixfopen): Likewise.
	(_libga68_posixcreat): Likewise.
	(_libga68_posixgetenv): Likewise.
	(_libga68_posixfputs): Likewise.
	(_libga68_posixfconnect): Likewise.
	* ga68-unistr.c (_libga68_u32_to_u8): Use internal allocator.
	* ga68.h (_libga68_realloc_internal): New prototype.
	(_libga68_u32_to_u8): Update prototype.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2026-01-30 07:57:02 -05:00
Marc Poulhiès
69ee6ac4bc a68: Minor typo fix in doc
gcc/algol68/ChangeLog:
	* ga68-coding-guidelines.texi: Typo fix.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2026-01-30 12:52:16 +01:00
Eric Botcazou
9a946fb8a8 Add missing PR reference 2026-01-30 12:43:53 +01:00
Eric Botcazou
a28bb06b3e Ada: Fix spurious visibility error from limited_with clause in hierarchy
The problem is that the compiler installs the limited view of a package that
is already installed by the virtue of being an ancestor of the main unit.

gcc/ada/
	PR ada/123867
	* sem_ch10.adb (Analyze_Compilation_Unit): Output info message
	when -gnatdi is specified.
	(Install_Parents): Likewise.  Set the Is_Visible_Lib_Unit flag
	on the unit.
	(Install_Private_With_Clauses): Do not output info message here.
	(Remove_Parents): Output info message when -gnatdi is specified
	and clear the Is_Visible_Lib_Unit flag on the unit.

gcc/testsuite/
	* gnat.dg/specs/limited_with3.ads: New test.
	* gnat.dg/specs/limited_with3-child.ads: New helper.
	* gnat.dg/specs/limited_with3-child-grandchild.ads: Likewise.
	* gnat.dg/specs/limited_with3-child-grandchild-grandgrandchild.ads:
	Likewise.
2026-01-30 12:01:36 +01:00
Richard Biener
b61b3e19f9 debug/110885 - fix split-dwarf / debug-types interaction
The following fixes a link failure due to missing skeleton
ancestors.

	PR debug/110885
	* dwarf2out.cc (generate_skeleton_bottom_up): Generate the
	skeleton ancestor tree when moving a new child to the parent
	even for template instantiations.

	* g++.dg/debug/dwarf2/pr110885.C: New testcase.
2026-01-30 11:57:31 +01:00
Jakub Jelinek
12c95fc1ad libatomic: Don't install libatomic_asneeded.{so,a} if corresponding libatomic.{so,a} wasn't installed
Filip complained on IRC that libatomic_asneeded.a is installed as
stale symlink in --disable-static build.

The following patch makes sure to install the libatomic_asneeded.{so,a}
script and/or symlink only if the corresponding libatomic.{so,a} has been
installed.

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

	* Makefile.am (all-local, install-asneeded): Only create
	libatomic_asneeded.so script if libatomic.so exist, only
	create libatomic_asneeded.a symlink if libatomic.a exist.
	* Makefile.in: Regenerate.
2026-01-30 11:43:49 +01:00
Jakub Jelinek
238d2fc116 match.pd: Fix up __imag__ .MUL_OVERFLOW simplification [PR123864]
The integer_minus_onep case is really meant for multiplication by
-1, not by (unsigned char)0xff or (unsigned short)0xffff or 0xffffffffU etc.
We've already tested that the first operand is signed (otherwise the
earlier case is used) and also that int_fits_type_p (@1, TREE_TYPE (@0)),
but if @0 is signed and @1 is unsigned all ones with smaller precision
than that, it fits into @0's type, integer_minus_onep will be true
and it still should be handled through the ranges, not as @0 == min.

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

	PR tree-optimization/123864
	* match.pd (__builtin_mul_overflow_p (x, cst, (stype) 0) ->
	x > stype_max / cst || x < stype_min / cst): Only check
	integer_minus_onep for signed types.

	* gcc.c-torture/execute/pr123864.c: New test.
	* gcc.dg/torture/pr123864.c: New test.
2026-01-30 11:42:41 +01:00
Jakub Jelinek
cffe5fd7c9 fold-const: Fix implicit cast to nullptr_t typedef [PR123790]
The following testcase is incorrectly rejected, because since r15-6744
it adds build_nop to preserve the exact typedef type and
cxx_eval_constant_expression can't fold NOP_EXPR from integer_zerop of one
NULLPTR_TYPE to another NULLPTR_TYPE, while cxx_eval_constant_expression
relies on fold to do such folding.

I see 3 options to fix that, one is deal with this in the r15-6744 spot
and special case NULLPTR_TYPE there and build_zero_cst instead of build_nop
(with similar condition like in the patch below), another possibility is
special case this in cxx_eval_constant_expression, and
another one (done in this patch) is to handle this in fold-const.cc -
fold_convert_loc and also in fold_convert_const.

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

	PR c++/123790
	* fold-const.cc (fold_convert_const): Handle conversion of
	integer_zerop to NULLPTR_TYPE.
	(fold_convert_loc): Likewise.

	* g++.dg/cpp0x/nullptr47.C: New test.
2026-01-30 11:40:17 +01:00
Iain Buclaw
919b6fa6ad d: Merge upstream dmd, druntime 1017635a96, phobos 5a142da0a
D front-end changes:

	- Import dmd v2.112.0-beta.1.

D runtime changes:

	- Import druntime v2.112.0-beta.1.
	- Added 64-bit `mul' and `udivmod' overloads to `core.int128'.

Phobos changes:

	- Added `lazyCache' to `std.algorithm.iteration'.
	- Added `writeText', `writeWText', and `writeDText' to
	  `std.conv'.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 1017635a96.
	* dmd/VERSION: Bump version to v2.112.0-beta.1.
	* decl.cc (DeclVisitor::finish_vtable): Update for new front-end
	interface.
	(DeclVisitor::visit): Likewise.
	* typeinfo.cc (TypeInfoVisitor::visit): Likewise.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 1017635a96.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Add
	core/sys/linux/sys/syscall.d, core/sys/linux/syscall.d.
	* libdruntime/Makefile.in: Regenerate.
	* src/MERGE: Merge upstream phobos 5a142da0a.
	* src/Makefile.am (PHOBOS_DSOURCES): Remove
	std/internal/windows/bcrypt.d.
	* src/Makefile.in: Regenerate.

gcc/testsuite/ChangeLog:

	* gdc.dg/asm1.d: Adjust test.
2026-01-30 11:24:27 +01:00
Jørgen Kvalsvik
340c45dc16 Permit const counters in flush_on_edges [PR123855]
Relax the (accidental) requirement and permit that function-local
counters don't have SSA names.  We really only look up the def
statement to check if it is a phi node, in which case we need to
resolve the counter from there.  This obviously doesn't apply when it
is a constant.

	PR gcov-profile/123855

gcc/ChangeLog:

	* path-coverage.cc (flush_on_edges): Only look up SSA name def
	stmt when counter is non-const.

gcc/testsuite/ChangeLog:

	* gcc.misc-tests/gcov-pr123855.c: New test.
2026-01-30 11:20:58 +01:00
Jørgen Kvalsvik
5380be9175 gcov-dump: Print PATHS tag
Print the record associated with the PATHS tag.  While it just prints
the number of prime paths for the function, this is more useful than
the UNKNOWN it would otherwise print.

Before:
...
demo.gcno:    01450000:  31:LINES
demo.gcno:                  block 6:`demo.c':13
demo.gcno:    01490000:   4:UNKNOWN

After:
...
demo.gcno:    01450000:  31:LINES
demo.gcno:                  block 6:`demo.c':13
demo.gcno:    01490000:   4:PATHS 5 paths

gcc/ChangeLog:

	* gcov-dump.cc (tag_paths): New function.
2026-01-30 11:20:58 +01:00
Jørgen Kvalsvik
94fa0d52a2 gcc: -f*-coverage implies -ftest-coverage
The --coverage flag is a useful alias for -fprofile-arcs
-ftest-coverage where the latter makes gcc output the .gcno file.
While it makes sense to use -fprofile-arcs without a .gcno file (pgo,
maybe more), it never really makes sense to request -fpath-coverage or
-fcondition-coverage without also wanting the .gcno to interpret the
results.

gcc/ChangeLog:

	* common.opt: ftest-coverage enabled by fpath-coverage or
	fcondition-coverage

gcc/testsuite/ChangeLog:

	* g++.dg/gcov/gcov-18.C: Remove --coverage.
	* g++.dg/gcov/gcov-22.C: Likewise.
	* gcc.misc-tests/gcov-19.c: Remove -ftest-coverage.
	* gcc.misc-tests/gcov-29.c: Likewise.
2026-01-30 11:20:57 +01:00
Jørgen Kvalsvik
1681b203a0 gcov-dump: Print start-position for conditions
The printed position should be the start of the record, as is the case
with lines.

Before:
ex.gcno:  795:    01470000:  16:CONDITIONS 2 conditions
ex.gcno:  811:                  block 2: 1
ex.gcno:  819:                  block 5: 1
ex.gcno:  819:    01000000:  50:FUNCTION ... `main' ...

After:
ex.gcno:  795:    01470000:  16:CONDITIONS 2 conditions
ex.gcno:  803:                  block 2: 1
ex.gcno:  811:                  block 5: 1
ex.gcno:  819:    01000000:  50:FUNCTION ... `main' ...

gcc/ChangeLog:

	* gcov-dump.cc (tag_conditions):  Read position before blocks,
	terms.
2026-01-30 11:20:57 +01:00
Jørgen Kvalsvik
ba68de6708 Update expected number of prime paths in test case
This test has been failing since this commit which introduces an extra
block in the loop, increasing the number of prime paths:

FAIL: gcc.misc-tests/gcov-29.c line 826: expected 0/5 covered paths, was 0/6

commit 385d9937f0
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Jul 11 13:01:13 2025 +0200
    Rewrite assign_discriminators

I have looked at the CFGs of this function before and after Jan's
patch and both cases are fine, this test breaking is not a real
regression.

gcc/testsuite/ChangeLog:

	* gcc.misc-tests/gcov-29.c: Expect 6 prime paths in test.
	* gcc.misc-tests/gcov-30.c: Likewise.
2026-01-30 11:20:57 +01:00
Jørgen Kvalsvik
2df6b3b9e8 gcov: Only consider pure locations in line mapping
Fixes a regression introduced I bisected to this commit:

commit 385d9937f0
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Jul 11 13:01:13 2025 +0200
    Rewrite assign_discriminators

That patch adds discriminators to edge->goto_locus which will map to
the right source location, but breaks the equality comparison used in
the hash set.

Fixes these tests:

gcc/testsuite/gcc.misc-tests/gcov-pr83813.c
gcc/testsuite/gcc.misc-tests/gcov-pr84758.c
gcc/testsuite/gcc.misc-tests/gcov-pr85332.c
gcc/testsuite/gcc.misc-tests/gcov-pr85372.c

	PR gcov-profile/121084
	PR gcov-profile/121123
	PR gcov-profile/121409

gcc/ChangeLog:

	* profile.cc (branch_prob): Record seen_locations without
	discriminators.
2026-01-30 11:20:57 +01:00
Jakub Jelinek
de23c4ad41 openmp: Handle asm goto in diagnose_sb_2 [PR123876]
We weren't handling asm goto in diagnose_sb_2, so could ICE
on invalid code instead of diagnosing it as invalid.

Note, for C++ the FE already diagnoses that instead of deferring
it will omp-low.cc.

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

	PR middle-end/123876
	* omp-low.cc (diagnose_sb_2): Handle GIMPLE_ASM.

	* gcc.dg/gomp/pr123876.c: New test.
2026-01-30 11:00:41 +01:00
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