Jonathan Wakely [Thu, 21 May 2026 17:58:14 +0000 (18:58 +0100)]
libstdc++: Add missing constraints to vector and deque deduction guides
The standard requires that these deduction guides are constrained to
only accept a type that qualifies as an allocator for the second
templates argument.
libstdc++-v3/ChangeLog:
* include/bits/stl_deque.h: Add missing constraint on allocator
type in deduction guide.
* include/bits/stl_vector.h: Likewise.
* include/debug/deque: Likewise.
* include/debug/vector: Likewise.
* testsuite/23_containers/deque/cons/deduction_c++23.cc: Check
that deduction fails for a type which does not qualify as an
allocator.
* testsuite/23_containers/vector/cons/deduction_c++23.cc:
Likewise.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Tue, 19 May 2026 15:51:14 +0000 (16:51 +0100)]
libstdc++: Split <iosfwd> and only include it in <ios> [PR125371]
The standard explicitly requires the <ios> header to include <iosfwd>,
which has declarations of all the standard stream buffers and stream
types. Because we include <ios> in <istream> and <ostream>, this means
that <iosfwd> is included everywhere, and so every iostream header has a
forward declaration of every iostream type. This means that for example,
<fstream> has a declaration (but not the definition) of std::stringbuf.
This leads to a poor user experience, because the compiler's fixit hints
for undeclared types do not trigger of the type _has_ been declared,
instead users get an error about using an incomplete type. See the
example in PR 125371, where using std::istringstream after including
<fstream> fails to suggest including <sstream>.
If we stop including <ios> in <istream> and <ostream>, and instead
include _most_ of the same things that <ios> provides, then we can avoid
the unhelpful declarations of the entire family of iostream types in
every header. Users who really do want a declaration of std::filebuf
or std::istringstream (but don't want the full definition) can still
explicitly include <iosfwd> to get those declarations. But they won't
get them as a side effect of <fstream> etc.
Various headers currently include <iosfwd> because they really do want
the declaration of e.g. std::ostream of std::streambuf_iterator. We can
split <iosfwd> into five smaller headers and then only include the relevant
one where required, e.g. <fstream> only needs to include iosfwd_file.h
and not iosfwd_string.h.
We need to add an explicit include of <ios> in <iostream>. The standard
requires it there, and after this change we no longer get it via
<istream> and <ostream>.
libstdc++-v3/ChangeLog:
PR libstdc++/125371
* config/io/basic_file_stdio.h: Include <bits/ios_base.h>
instead of <ios>.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/bits/fs_path.h: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/bits/locale_facets.h: Remove unused <iosfwd> and
<streambuf> includes.
* include/bits/localefwd.h: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/bits/ostream.h: Replace <ios> with its constituent
parts, except for <iosfwd>.
* include/bits/ostream_insert.h: Include <bits/iosfwd.h> instead
of <iosfwd>.
* include/bits/shared_ptr.h: Likewise.
* include/bits/std_thread.h: Likewise.
* include/bits/stream_iterator.h: Likewise.
* include/std/fstream: Include <bits/iosfwd_file.h>.
* include/std/iomanip: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/std/ios: Do not include <exception> or
<bits/char_traits.h>.
* include/std/iosfwd: Move declarations to new headers and
include those new headers. Tweak Doxygen comment.
* include/std/iostream: Include <ios>.
* include/std/istream: Replace <ios> with its constituent
parts, except for <iosfwd>.
* include/std/random: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/std/spanstream: Include <bits/iosfwd_span.h>.
* include/std/sstream: Include <bits/iosfwd_string.h>.
* include/std/streambuf: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/std/string_view: Likewise.
* include/std/syncstream: Include <bits/iosfwd_sync.h>.
* include/std/system_error: Include <bits/iosfwd.h> instead of
<iosfwd>.
* include/bits/iosfwd.h: New file.
* include/bits/iosfwd_file.h: New file.
* include/bits/iosfwd_span.h: New file.
* include/bits/iosfwd_string.h: New file.
* include/bits/iosfwd_sync.h: New file.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Fri, 24 Apr 2026 03:25:47 +0000 (05:25 +0200)]
libstdc++: Merged concept for ranges with static sized.
This patch replaces duplicated __detail::__statically_sized (from std/meta)
and simd::__static_sized_range (from include/bits/simd_details.h) concepts
with single range::__static_sized_range. The concept uses the implementation
based on __statically_sized concept, as it avoids triggering instantiations
of some class template for each possible size value.
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (ranges::__static_sized_range):
Define.
* include/bits/simd_details.h (simd::__static_sized_range):
Remove.
(simd::__static_range_size): Use ranges::__static_sized_range.
* include/bits/simd_loadstore.h (simd::unchecked_store)
(simd::unchecked_load): Use ranges::__static_sized_range.
* include/bits/simd_vec.h (basic_vec::basic_vec(_Rg&&, flags<_Flags>)):
Replace __static_sized_range<_Rg, _S_size> with
ranges::__static_sized_range<_Rg> and traing requires size
for size value.
* include/std/meta (__detail::__statically_sized): Remove.
(std::define_static_array): Use ranges::__static_sized_range.
* testsuite/std/simd/traits_impl.cc: Remove test for
simd::__static_sized_range.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Reviewed-by: Patrick Palka <ppalka@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Eric Botcazou [Fri, 13 Feb 2026 10:31:36 +0000 (11:31 +0100)]
ada: Fix missing accessibility check for anonymous access function result
This factors out from Apply_Access_Discrims_Accessibility_Check the logic
to generate an accessibility check for a single discriminant, moves two
other routines generating accessibility checks for returns from Exp_Ch6
to Accessibility, creates Apply_Accessibility_Check_For_Return to have
a single entry point, and adjusts Accessibility_Level to cope with the
additional patterns it is invoked on.
This also arranges for the computation of the minimum accessibility level
for access results to be entirely done in Analyze_Subprogram_Body_Helper
and in all cases (it was done only for function bodies without a spec).
gcc/ada/ChangeLog:
* accessibility.ads (Apply_Accessibility_Check): Rename into...
(Apply_Accessibility_Check_For_Parameter): ...this.
(Apply_Accessibility_Check_For_Return): New procedure.
(Effective_Extra_Accessibility): Minor tweak in description.
* accessibility.adb (Function_Call_Or_Allocator_Level): Apply the
specific treatment for returns to anonymous allocators as well.
(Accessibility_Level): Deal with literal null and Deref attribute.
(Apply_Accessibility_Check): Rename into...
(Apply_Accessibility_Check_For_Anonymous): New procedure extracted
from the old Apply_Access_Discrims_Accessibility_Check.
(Apply_Accessibility_Check_For_Class_Wide): New procedure taken
from Exp_Ch6.
(Apply_Accessibility_Check_For_Discriminant): Likewise.
(Apply_Accessibility_Check_For_Parameter): ...this.
(Apply_Accessibility_Check_For_Return): New procedure.
(Static_Accessibility_Level): Minor reformatting.
* exp_attr.adb (Expand_N_Attribute_Reference): Adjust to renaming.
* exp_ch3.adb (Expand_N_Object_Declaration): Generate accessibility
checks for returns by calling Apply_Accessibility_Check_For_Return.
* exp_ch4.adb (Expand_N_Type_Conversion): Adjust to renaming.
* exp_ch6.ads (Apply_Access_Discrims_Accessibility_Check): Delete.
(Apply_CW_Accessibility_Check): Likewise.
* exp_ch6.adb: Remove clauses for Exp_Atag.
(Apply_Access_Discrims_Accessibility_Check): Move to Accessibility.
(Apply_CW_Accessibility_Check): Likewise.
(Expand_Actuals): Adjust to renaming.
(Expand_Simple_Function_Return): Generate accessibility checks by
calling Apply_Accessibility_Check_For_Return.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Tidy up and make
the computation of minimum accessibility levels more uniform.
(Create_Extra_Formals): Minor reformatting.
Javier Miranda [Fri, 13 Feb 2026 12:09:34 +0000 (12:09 +0000)]
ada: Overriding of First_Controlling_Parameter tagged type primitive
Implement rule for overriding primitives of tagged types that
have the First_Controlling_Parameter aspect.
gcc/ada/ChangeLog:
* sem_ch3.adb (Derive_Subprogram): Do not replace the type when
Derived_Type inherits the first controlling parameter aspect and
it is not the first formal of this operation.
* sem_disp.adb (Check_Controlling_Formals): For overriding
primitives of types with the first controlling parameter aspect
inherit controlling formals of the overridden parent primitive.
Viljar Indus [Fri, 13 Feb 2026 10:24:15 +0000 (12:24 +0200)]
ada: Fix SPARK RM 6.9 Rule 32 check
Ensure that the ghost equality check is only applied to user defined
equality operations.
gcc/ada/ChangeLog:
* ghost.adb (Check_Ghost_Equality_Op): Supply the type of the
operation as an argument.
* ghost.ads (Check_Ghost_Equality_Op): Likewise.
* sem_ch6.adb (Valid_Operator_Definition): Remove call to
Check_Ghost_Equality_Op.
(Check_For_Primitive_Subprogram): Call Check_Ghost_Equality_Op.
ada: Make Interrupt_State not require Ada.Interrupts
This makes it so using the Interrupt_State configuration pragma does not
add an implicit dependency to Ada.Interrupts. The rationale is given in
a comment.
gcc/ada/ChangeLog:
* libgnarl/s-inttyp.ads: New file.
* libgnarl/a-interr.ads (Interrupt_ID): Derive from
Preelab_Interrupt_ID.
* libgnarl/s-interr.ads (Interrupt_ID): Derive from
Preelab_Interrupt_ID.
(Ada_Interrupt_ID): Remove.
* libgnarl/s-interr__vxworks.ads (Ada_Interrupt_ID): Remove.
* xsintnam.sed: New file.
* Makefile.rtl: Register new runtime files.
* libgnarl/a-interr.adb: Adjust with clauses.
* rtsfind.ads (RE_Interrupt_Names, RE_Preelab_Interrupt_ID): New
variants.
* sem_prag.adb: Use entities from new preelaborate packages.
* gcc-interface/Makefile.in: Generate System.Interrupt_Names.
The task state for interrupt server tasks was not quite right for
unhandled tasks. This fixes that and makes a few comment and formatting
improvements.
Javier Miranda [Thu, 12 Feb 2026 11:02:57 +0000 (11:02 +0000)]
ada: Missing initialization of aggregate components
When a tagged type conversion is applied to a qualified expression
of an aggregate, at runtime some components are left uninitialized.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Type_Conversion): When the operand is a
qualified expression of an aggregate, force its evaluation by
capturing its value in a constant (to ensure full initialization
of the tagged object).
Viljar Indus [Tue, 10 Feb 2026 10:04:31 +0000 (12:04 +0200)]
ada: Implement SPARK RM 6.9 (23)
Implement the rule 23 for ghost code:
A user-defined primitive equality operation on a non-ghost record type shall
not be ghost, unless the record type has only limited views.
In addition, a user-defined primitive equality operation on a ghost record type
shall have a matching assertion level.
gcc/ada/ChangeLog:
* ghost.adb (Check_Ghost_Equality_Op): New function for the
implementation of the rule.
* ghost.ads (Check_Ghost_Equality_Op): Likewise.
* sem_ch6.adb (Valid_Operator_Definition): Add check for rule 23.
Eric Botcazou [Tue, 10 Feb 2026 19:09:59 +0000 (20:09 +0100)]
ada: Fix long-standing issue with qualified expressions of class-wide types
Given the very specific name resolution rules for qualified expressions, the
Covers predicate cannot be used when the qualified expression is of a class-
wide type and, therefore, Analyze_Qualified_Expression needs to resort to a
stricter type compatibility analysis. But, unlike Covers, it fails to factor
out the limited views of the types, which may lead to spurious errors.
gcc/ada/ChangeLog:
* sem_ch4.adb (Analyze_Qualified_Expression): For a class-wide type,
check for an exact match modulo the Non_Limited_View attribute.
If a scalar type's Put_Image aspect is specified via an
attribute_definition_clause (as opposed to using aspect_specification
syntax), the aspect specification was incorrectly ignored.
gcc/ada/ChangeLog:
* aspects.adb (Has_Aspect): In the call to Find_Aspect, pass in
True for the Or_Rep_Item parameter instead of letting it default
to False.
Piotr Trojanek [Sat, 31 Jan 2026 11:22:34 +0000 (12:22 +0100)]
ada: Remove Tempdir package
Package Tempdir is no longer needed; its uses have been replaced by an
equivalent routine in System.OS_Lib that does not rely on Name_Id, which is an
internal compiler data type.
The Tempdir package is no longer used by gnatmake.
Eric Botcazou [Mon, 9 Feb 2026 08:09:36 +0000 (09:09 +0100)]
ada: Fix internal error on access to function as component via limited with
The code generator cannot translate the specification of a package because
it contains a circularity created by the presence of a limited_with clause
for it in a withed package, and of a function call made through an access-
to-function type declared in the latter package returning a type declared
in the former package.
gcc/ada/ChangeLog:
PR ada/89609
* sem_res.adb (Resolve_Call): Do not override the Etype of the Name
entity when it denotes a function that returns the limited view of a
type coming from a limited_with clause.
Eric Botcazou [Sat, 7 Feb 2026 13:17:55 +0000 (14:17 +0100)]
ada: Factor out common pattern in Exp_Ch6
This factors out the common prologue in the four procedures dealing with
build-in-place calls in the various contexts. No functional changes.
gcc/ada/ChangeLog:
* exp_ch6.adb (Get_Function_Entity): New function.
(Make_Build_In_Place_Call_In_Allocator): Call it, turn some local
variables into constants and rename Function_Id as Func_Id.
(Make_Build_In_Place_Call_In_Anonymous_Context): Likewise.
(Make_Build_In_Place_Call_In_Assignment): Likewise.
(Make_Build_In_Place_Call_In_Object_Declaration): Likewise.
Gary Dismukes [Thu, 5 Feb 2026 23:32:52 +0000 (23:32 +0000)]
ada: Error on legal No_Return subprogram with formals subject to Type_Invariant
The compiler reports a spurious error indicating that a subprogram with
aspect No_Return doesn't satisfy that aspect in cases where the subprogram
has formals whose type specifies a Type_Invariant aspect. The need for
invariant or postcondition checks leads to the creation of a nested
subprogram that wraps the enclosing subprogram's statements and exception
handler, defeating the checking that's done in Sem_Ch6.Check_Returns.
The fix is to suppress generation of the _wrapped_statements subprogram,
which is legitimate because the invariants and postconditions will not be
executed in any case for a No_Return subprogram since they can never be
reached.
gcc/ada/ChangeLog:
* contracts.adb (Expand_Subprogram_Contract): Don't call
Build_Subprogram_Contract_Wrapper for a No_Return subprogram,
but include any prologue declarations (such as for preconditions).
Viljar Indus [Wed, 7 Jan 2026 08:55:56 +0000 (10:55 +0200)]
ada: Print restrictions in the SARIF report
gcc/ada/ChangeLog:
* errid-diagnostic_repository.ads: Add new diagnostics to the
repository. Map diagnostics to restrictions.
* errid-restriction_repository.ads: New pacakges for mapping
restricitions to diagnostics.
* errid.adb (heck_Diagnostic_To_Restriction_Consistency): New
method for repository consistency.
(Check_Diagnostic_To_Restriction_Consistency): New method for
repository consistency.
(Add_All_Restriction_Rules): New method for adding all of the
restrictions.
* errid.ads: Add new Diagnostic_Id-s.
* errout.adb (Add_Unique_Diagnostics_And_Switches): Add
restrictions to the SARIF_Printer.
* erroutc.ads: Add restrictions to the Error_Msg_Object.
* erroutc-sarif_emitter.adb (Print_Rule): Add method for printing
rules for restrictions.
* erroutc-sarif_emitter.ads: add restrictions as part of the
printer.
* errutil.adb (Error_Msg): Update diagnostic element creation.
* restrict.adb (Restriction_Msg): Add diagnostic id based on the
restriction id.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Add
new files.
* gcc-interface/Makefile.in (GNATMAKE_OBJS): Likewise.
Javier Miranda [Thu, 5 Feb 2026 19:29:22 +0000 (19:29 +0000)]
ada: Fix recursion calls in Remove_Side_Effects
This patch fixes a latent problem in the recursion calls
performed by Remove_Side_Effects. The problem was introduced
when the formal Renaming_Req was added in 2014/June/30. This
fix does not introduce functional changes; it fixes the issue
thus improving the behavior of this routine.
gcc/ada/ChangeLog:
* exp_util.adb (Remove_Side_Effects): Propagate actuals in
recursion calls, unless this is a known side-effect free
attribute whose expressions are also side-effect free.
Bob Duff [Sun, 1 Feb 2026 17:47:23 +0000 (12:47 -0500)]
ada: Tech debt: Remove exception handling from aspects
Remove the Aspect_Exit exception and related code.
The big hammer of exceptions is not needed here,
and it gets in the way of future refactoring.
Some comments were slightly wrong; remove them instead of fixing
them.
gcc/ada/ChangeLog:
* sem_ch13.adb (Analyze_One_Aspect): Remove the exception
declaration, raises, and handler. Inline the code in
Check_Expr_Is_OK_Static_Expression, which was called only once.
Marc Poulhiès [Fri, 23 Jan 2026 11:12:47 +0000 (12:12 +0100)]
ada: fix: use correct scope when unnesting subprocedure
By the original comment before this Analyze call, initially, the
compiler was not creating any new entity, so scope information should be
already there and correct. But now (~15y later), the Analyze call may
indirectly create new entities (e.g. IType) that will use Current_Scope
as their scope: this is incorrect and leads to a failed assertion in
gcc-interface. This change correctly push/pop the current subp entity as
the scope.
gcc/ada/ChangeLog:
* exp_unst.adb (Unnest_Subprogram): Push/Pop scope around Analyze
call.
Marc Poulhiès [Fri, 5 Dec 2025 10:24:56 +0000 (11:24 +0100)]
ada: fix: drop renamings along with dropped subp
During unnesting, the compiler may drop some subp if reachability
analysis decides it's never used. This change adds tracking for subp
renamings, making sure renamings are also dropped with the subp.
When traversing the tree, when looking at a subp renaming declaration, it's
possible that the Subps entry (accessed through Subps_Index) for the renamed
subp has not yet been created. In this case, the renaming is recorded in a
"pending" list, and moved later when the Subps entry is created.
gcc/ada/ChangeLog:
* exp_unst.adb (Maybe_Subp_Index): New non throwing version of
Subp_Index.
(Nullify_Renamings, Move_Pending_Renamings): New.
(Register_Subprogram): Record subp renamings. Call
Nullify_Renamings when a subp is dropped.
(with Elist): Moved to...
* exp_unst.ads (with Elist): ... here.
(Subp_Entry): Add Renamings component.
(Pending_Renamings): New list.
This commit removes the Ada runtime's dependency on libutil when
targeting Linux, where the library is typically empty. Moreover, when
the runtime is built with Makefile.rtl the dependency isn't present (see
Make variable MISCLIB); this commit therefore synchronizes the GPR build
with the Makefile build.
gcc/ada/ChangeLog:
* s-oscons-tmplt.c (PTY_Library): Define empty for Linux targets.
Eric Botcazou [Mon, 26 Jan 2026 08:16:20 +0000 (09:16 +0100)]
ada: Small refactoring in Check_Anonymous_Access_Return_With_Tasks
The procedure uses a custom version of the Might_Have_Tasks predicate, so
this changes it to call the predicate instead.
gcc/ada/ChangeLog:
* sem_ch6.adb (Check_Anonymous_Access_Return_With_Tasks): Declare
Scop as a constant and call the Might_Have_Tasks predicate instead
of using a custom implementation of it.
Steve Baird [Wed, 21 Jan 2026 22:42:31 +0000 (14:42 -0800)]
ada: Deep delta aggregates incorrectly rejected with -gnatX.
To enable the use of deep delta aggregates, it should only be necessary to
enable core extensions (e.g., via -gnatX) as opposed to enabling all
extensions (e.g., via -gnatX0).
gcc/ada/ChangeLog:
* doc/gnat_rm/gnat_language_extensions.rst: Correct example
to avoid using a not-yet-implemented form of deep delta aggregate.
* exp_aggr.adb (Make_Delta_Choice_LHS): Call Core_Extensions_Allowed
instead of All_Extensions_Allowed.
* par-ch4.adb (P_Simple_Expression): Likewise.
* sem_aggr.adb (Resolve_Delta_Array_Aggregate): Likewise.
* gnat_rm.texi: Regenerate.
Gary Dismukes [Wed, 21 Jan 2026 23:35:56 +0000 (23:35 +0000)]
ada: Parsing error on declare expr in expression default for generic formal function
The compiler incorrectly issues syntax errors for a generic formal function
with default given by an expression (a GNAT extension) when the expression
is a declare_expression. This is fixed by calling P_Expression_If_OK rather
than P_Expression to parse the expression, which properly handles parsing
declare_expressions without parentheses (but still requires parentheses to
enclose the expression).
gcc/ada/ChangeLog:
* par.adb (P_Expression_If_OK): Add declare expression to spec comment.
* par-ch4.adb (P_Expression_If_OK): Add declare expression to comments.
* par-ch12.adb (P_Formal_Subprogram_Declaration): Call
P_Expression_If_OK rather than P_Expression.
Javier Miranda [Wed, 21 Jan 2026 19:36:30 +0000 (19:36 +0000)]
ada: Boolean flag for Unsigned_Base_Range aspect is ignored
Unsigned_Base_Range is erroneously enabled when set to False.
gcc/ada/ChangeLog:
* sem_ch13.adb (Analyze_One_Aspect): For Unsigned_Base_Range aspect,
skip generating its corresponding pragma when the aspect is set
to False.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Fix initialization
of local variable Is_Unsigned_Base_Range_Type_Decl to handle
Unsigned_Base_Range aspect set to False.
ada: Fix exception on attaching non-handler procedure
Before this patch, the program error raised when Attach_Handler was
called on a procedure without Interrupt_Handler specified was
accompanied by a message that related to a completely different error.
This patch fixes this.
Jin Ma [Tue, 19 May 2026 09:43:37 +0000 (17:43 +0800)]
RISC-V: Refactor riscv-fusion.cc to use table-driven dispatch
Refactor riscv_macro_fusion_pair_p to replace the large series of
if-blocks with a table-driven approach. Each fusion case is
extracted into its own static checker function with signature
(rtx_insn *prev, rtx_insn *curr), and a struct array
riscv_fusion_table drives the dispatch loop.
Each checker internally calls single_set and enforces its own
simple_sets_p and same-dest constraints, giving full flexibility
to inspect candidate insns and making it straightforward to add
future fusion rules (e.g. branch instructions) that do not
follow those patterns.
Extract the common same-dest register constraint into
riscv_fusion_same_dest_p to reduce code duplication across the
eleven checkers that require it.
Also rename the boolean helper functions (riscv_set_is_add, etc.)
to use the _p suffix per GNU/GCC naming convention for predicates.
No functional change intended.
gcc/ChangeLog:
* config/riscv/riscv-fusion.cc (riscv_fusion_same_dest_p):
New function.
(riscv_set_is_add_p): Rename from riscv_set_is_add.
(riscv_set_is_addi_p): Rename from riscv_set_is_addi.
(riscv_set_is_adduw_p): Rename from riscv_set_is_adduw.
(riscv_set_is_shNadd_p): Rename from riscv_set_is_shNadd.
(riscv_set_is_shNadduw_p): Rename from riscv_set_is_shNadduw.
(riscv_fuse_zextws): New function.
(riscv_fuse_zexth): Likewise.
(riscv_fuse_ldindexed): Likewise.
(riscv_fuse_expanded_ld): Likewise.
(riscv_fuse_ldpreincrement): Likewise.
(riscv_fuse_lui_addi): Likewise.
(riscv_fuse_auipc_addi): Likewise.
(riscv_fuse_lui_ld): Likewise.
(riscv_fuse_auipc_ld): Likewise.
(riscv_fuse_cache_aligned_std): Likewise.
(riscv_fuse_aligned_std): Likewise.
(riscv_fuse_bfext): Likewise.
(riscv_fuse_b_alui): Likewise.
(struct riscv_fusion_entry): New struct.
(riscv_fusion_table): New table.
(riscv_macro_fusion_pair_p): Refactor to use table-driven
dispatch loop with simplified checker interface.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/fusion-auipc-addi-2.c: New test.
* gcc.target/riscv/fusion-lui-addi-2.c: New test.
* gcc.target/riscv/fusion-zexth-2.c: New test.
* gcc.target/riscv/fusion-zextw-2.c: New test.
Jin Ma [Tue, 19 May 2026 09:31:27 +0000 (17:31 +0800)]
RISC-V: Fix multiple bugs in riscv_macro_fusion_pair_p
Fix several correctness and minor issues in the fusion pair
matching logic:
XINT (prev_set, 1) in RISCV_FUSE_AUIPC_LD incorrectly accesses
the SET node rather than its UNSPEC source operand. Use
XINT (SET_SRC (prev_set), 1) to match riscv_fuse_auipc_addi.
RISCV_FUSE_CACHE_ALIGNED_STD compared base registers with != instead
of ==, causing it to match stores with different bases rather than
the same base which is required for cache-line alignment analysis.
RISCV_FUSE_B_ALUI sub+smax pattern had a redundant CONST_INT_P
check on the same operand already validated by the CONST0_RTX
comparison.
RISCV_FUSE_LDINDEXED had a duplicate REG_P check on the same
operand.
Also fix a typo ("hte" -> "the") in a comment and correct the
dump output string from "RISCV_FUSE_ALIGNED_STD" to
"RISCV_FUSE_CACHE_ALIGNED_STD" for the cache-aligned case.
Tests are marked XFAIL as no upstream mtune currently enables
AUIPC_LD, CACHE_ALIGNED_STD, B_ALUI, or LDINDEXED. The
existing fusion-auipc-addi.c test indirectly validates the
XINT fix since AUIPC_ADDI shares the same UNSPEC_AUIPC check
code path.
gcc/ChangeLog:
* config/riscv/riscv-fusion.cc (riscv_macro_fusion_pair_p):
Fix XINT to access SET_SRC (prev_set) in AUIPC_LD case.
Fix base register comparison from != to == in
CACHE_ALIGNED_STD case. Remove redundant CONST_INT_P
check in B_ALUI sub+smax case. Remove duplicate REG_P
check in LDINDEXED case. Fix typo in comment. Fix dump
output name for CACHE_ALIGNED_STD.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/fusion-auipc-ld.c: New test.
* gcc.target/riscv/fusion-b-alui.c: New test.
* gcc.target/riscv/fusion-cache-aligned-std.c: New test.
* gcc.target/riscv/fusion-ldindexed.c: New test.
Andrew Pinski [Mon, 25 May 2026 19:44:48 +0000 (12:44 -0700)]
match: Fix up `(smaller)a ==/!= (smaller) b` pattern for pointers [PR125453]
While reviewing r17-632-g1c9808a71207eb, I missed that it was valid (in gimple)
to cast from a pointer to a smaller integral type. That meant with that
pattern we would get `ptr ^ ptr` which is invalid gimple.
This adds a check for integral type before applying this pattern.
Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
PR tree-optimization/125453
gcc/ChangeLog:
* match.pd (`(smaller)a ==/!= (smaller) b`): Reject
non integral types.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125453-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Georg-Johann Lay [Sun, 24 May 2026 20:16:46 +0000 (22:16 +0200)]
AVR: target/125409 - Add fixed-point conversions to / from [u]int24_t.
The test cases ran into
ld: undefined reference to `__fractunssapsi'
ld: undefined reference to `__fractunspsisa'
etc. because the backend didn't implement these conversions.
The worker function that outputs fixed-point conversions inline,
avr_out_fract, is generic enough to handle 24-bit integral modes, so
adding PSImode to the mode iterators in avr-fixed.md fixes the issue.
gcc/testsuite/
* gcc.target/avr/torture/pr125409.h: New file.
* gcc.target/avr/torture/pr125409-fx24-ssk.c: New test.
* gcc.target/avr/torture/pr125409-fx24-ssr.c: New test.
* gcc.target/avr/torture/pr125409-fx24-suk.c: New test.
* gcc.target/avr/torture/pr125409-fx24-sur.c: New test.
* gcc.target/avr/torture/pr125409-fx24-usk.c: New test.
* gcc.target/avr/torture/pr125409-fx24-usr.c: New test.
* gcc.target/avr/torture/pr125409-fx24-uuk.c: New test.
* gcc.target/avr/torture/pr125409-fx24-uur.c: New test.
Georg-Johann Lay [Sun, 24 May 2026 20:12:31 +0000 (22:12 +0200)]
AVR: ad target/121343 - Let __load_<size> insns use hard-reg constraints.
Insns that generate transparent __load_<size> calls can be simplified
using hard-reg constraints instead of explicit hard registers.
This handles __flash loads of 3-byte and 4-byte integral, floating point
and fixed-point values on devices without LPMx instruction.
PR target/121343
gcc/
* config/avr/avr.md (load_<mode>_libgcc): Rewrite to use
a hard-reg constraint for operand 0.
(gen_load<mode>_libgcc): Remove expander.
(mov<mode>): No more special handling needed for sources that
satisfy avr_load_libgcc_p.
Follow up to r16-5508-g77b8221af8fc82; seemingly, a testcase never got
added - and the internal representation changed afther the code was
written. At least the previous code ICE'd for the included testcase.
PR c/125377
gcc/ChangeLog:
* omp-general.cc (omp_check_for_duplicate_variant): Fix used
tree for 'inform' part of the error message.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/begin-declare-variant-1.c: New test.
Eric Botcazou [Wed, 21 Jan 2026 18:12:02 +0000 (19:12 +0100)]
ada: Fix crash on equality of unchecked union components of formal parameters
The bottom line is that we need to suspend the B.3.3(23/2) rule during the
expansion of the equality function of an unchecked union itself containing
a component of an unchecked union type subject to a per-object constraint,
but this was done too broadly instead of specifically for this case.
gcc/ada/ChangeLog:
* sem_util.adb (Prefix_Is_Formal_Parameter): Rename into...
(Prefix_Is_Formal_Parameter_Of_EQ): ...this. Return True only if
the formal parameter is that of an equality function built for an
unchecked union type.
(Has_Inferable_Discriminants): Adjust to above renaming.
Eric Botcazou [Wed, 21 Jan 2026 09:05:17 +0000 (10:05 +0100)]
ada: Fix different 'Img and 'Image on enumeration type with Put_Image
As documented in the GNAT RM, 'Img should behave like 'Image for objects.
The change fixes the problem and also implements more aggressive folding.
gcc/ada/ChangeLog:
* sem_attr.adb: Add with and use clauses for Exp_Put_Image.
(Eval_Attribute.Fold_Compile_Time_Known_Enumeration_Image): New
procedure factored out from....
(Eval_Attribute): ...here. Attempt to fold 'Img and 'Image for all
compile-time known values of enumeration, but not character, types,
provided that Put_Image need not be called, by invoking the nested
Fold_Compile_Time_Known_Enumeration_Image procedure on the value.
Denis Mazzucato [Tue, 20 Jan 2026 11:54:02 +0000 (12:54 +0100)]
ada: Update references to Parameter Associations RM 6.4.1
AI12-0095-1 added a paragraph after RM 6.4.1(6.3/3), all the subsequent RM
references within 6.x may be off by one; this patch updates those references.
Martin Clochard [Tue, 20 Jan 2026 16:44:13 +0000 (17:44 +0100)]
ada: Set Etype before analysis for conditions generated for 'Old
The absence of Etype decoration is problematic for GNATprove, which
cannot use analyze to fill the blanks in the output.
gcc/ada/ChangeLog:
* sem_util.adb (As_Boolean): utility to fill decoration in expressions
(Determining_Condition): set Etype for generated Boolean connectors
(Conditional_Evaluation_Condition): set Etype for generated connectors
Gary Dismukes [Tue, 20 Jan 2026 22:35:50 +0000 (22:35 +0000)]
ada: Formal function default given by expression rejected with -gnatX
The compiler should be allowing formal functions to be defaulted by
an expression when the core extensions are enabled, but it was
requiring all extensions to be enabled.
gcc/ada/ChangeLog:
* par-ch12.adb (P_Formal_Subprogram_Declaration): Pass True for
the Is_Core_Extension parameter on call to Error_Msg_GNAT_Extension.
Piotr Trojanek [Mon, 19 Jan 2026 22:04:10 +0000 (23:04 +0100)]
ada: Reject pragma CPU and Priority that duplicate corresponding aspects
When a main subprogram had its CPU or priority specified first by an aspect
specification and then by a corresponding pragma, then the pragma was silently
ignored. Now such a pragma is rejected.
gcc/ada/ChangeLog:
* sem_ch13.adb (Analyze_Aspect_Specifications): Record aspect CPU and
Priority applied to subprogram as a representation item.
Claire Dross [Fri, 16 Jan 2026 16:02:50 +0000 (17:02 +0100)]
ada: Reject exceptional contracts on No_Raise subprograms
Rejectd the SPARK-specific exceptional contract pragmas Exceptional_Cases and
Exit_Cases when they are not compatible with the No_Raise GNAT-specific aspect.
gcc/ada/ChangeLog:
* sem_prag.adb (Analyze_Exit_Contract): The Exception_Raised exit kind
is not compatible with No_Raise.
(Analyze_Pragma): The Exceptional_Cases pragma is not compatible with
No_Raise.
Eric Botcazou [Sun, 18 Jan 2026 21:12:25 +0000 (22:12 +0100)]
ada: Fix fallout of recent freezing change for expression functions
The change unnecessarily prevents the profile of all dispatching operations
from being frozen by their subprogram body, which exposes a weakness in the
implementation of freezing for generic units. This just reverts that part.
gcc/ada/ChangeLog:
PR ada/93702
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Revert latest
change.
* sem_ch12.adb (Analyze_One_Association): Remove redundant line.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Freeze the profile
again for bodies that are not generated from expression functions.
Javier Miranda [Fri, 16 Jan 2026 17:11:55 +0000 (17:11 +0000)]
ada: Spurious error on formals with First_Controlling_Parameter type
This patch fixes a spurious error reported by the frontend when
a dispatching primitive of a tagged type has additional formals
with types that have the First_Controlling_Parameter aspect.
gcc/ada/ChangeLog:
* sem_disp.adb (Check_Controlling_Formals): Formals of a type
specifying aspect First_Controlling_Parameter are not candidate
controlling parameters when they are not the first formal of
the dispatching primitive.
Eric Botcazou [Tue, 13 Jan 2026 19:00:28 +0000 (20:00 +0100)]
ada: Fix early freezing of tagged type by expression function in nested package
This addresses a long-standing issue in the implementation of expression
functions of Ada 2012, pertaining to their interaction with the freezing
of types that are referenced in their expression: when they are used as
the completion of a function declaration, their expression causes these
types to become frozen, but when they are stand-alone, it does not.
The last rule is problematic for GNAT, because it goes against its freezing
model devised for Ada 95, where types must always be frozen for code to be
generated. Therefore the current implementation needs to resort to several
kludges in order to implement it, but these are not bullet proof and do not
always work when tagged types are involved.
The new approach is to insert the generated body of stand-alone expression
functions at the next freezing point, instead of at the end of the current
package. This makes a difference for nested packages, which are precisely
the problematic case. This requires the analysis and resolution performed
on the body, potentially out of context now, to give identical results as
the preanalysis and resolution performed on the expression in its context,
which is achieved by treating the generated body as an inlined body.
This approach requires a more complete implementation of the special rules
for freezing expression functions, so the change overhauls it and plugs the
most blatant loopholes of the current implementation.
gcc/ada/ChangeLog:
PR ada/93702
* contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Call
Freeze_Expr_Types_Before instead of Freeze_Expr_Types.
(Process_Preconditions_For): Likewise.
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Do not set
Was_Expression_Function flag on the generated bodies.
* exp_ch6.adb (Expand_Call_Helper): Call Original_Node on the
result of the call to Expression_Of_Expression_Function.
* freeze.ads (Freeze_Expr_Types): Delete.
(Freeze_Expr_Types_Before): New procedure declaration.
* freeze.adb (Check_Expression_Function): Delete.
(Freeze_And_Append): Add Do_Freeze_Profile formal parameter and
pass it to Freeze_Entity. Remove call to Check_Expression_Function.
(Freeze_Entity): Set Test_E consistently and freeze the expression
of expression functions that are primitives of a tagged type.
(Freeze_Profile): Adjust calls to Should_Freeze_Type.
(In_Expanded_Body): Also return true for DIC procedures.
(Freeze_Expression): Remove call to Check_Expression_Function.
Freeze the expression of expression functions.
(Freeze_Expr_Types): Add Result and Before formal parameters.
Make a copy and preanalyze/resolve it only if Typ is present.
(Freeze_Expr_Types.Explain_Error): New procedure.
(Freeze_Expr_Types.Find_Incomplete_Constant): Likewise.
(Freeze_Expr_Types.Check_And_Freeze_Type): Return immediately if
the type is already frozen. Report errors on N instead of Node.
If Before is False, append the freeze nodes to Result.
(Freeze_Expr_Types.Freeze_Type_Refs): Call Find_Incomplete_Constant.
(Freeze_Expr_Types_Before): New procedure.
(Should_Freeze_Type): Remove formal parameter E and
specific kludge for stand-alone expression functions.
* ghost.ads (Mark_And_Set_Ghost_Body_Of_Expression_Function): New
procedure declaration.
* ghost.adb (Mark_And_Set_Ghost_Body_Of_Expression_Function): New
procedure body.
* rtsfind.adb (RTE): Preserve and reset the In_Inlined_Body flag.
(RTE_Record_Component): Likewise.
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Just call
Freeze_Expression to freeze the expression of prefixes that are
expression functions and remove obsolete implementation.
* sem_ch3.adb (Analyze_Declarations): Adjust commentary.
(Check_Completion): Also skip stand-alone expressions functions.
* sem_ch4.adb (Analyze_Case_Expression): Always analyze the choices.
* sem_ch6.adb: Add with and use clauses for Sem_Ch7.
(Analyze_Expression_Function): Call Freeze_Expr_Types_Before instead
of Freeze_Expr_Types for expression functions that are completions.
For stand-alone expression functions, set In_Private_Part on the
entity if it is in the private part, propagate the results of the
resolution of the specification of the the declaration to that of
the body and insert the body at the next freezing point.
(Analyze_Subprogram_Body_Helper): Remove the machinery for masking
and unmasking unfrozen types. For a stand-alone expression function,
call Mark_And_Set_Ghost_Body_Of_Expression_Function, remove obsolete
code dealing with the freezing of the spec, set In_Inlined_Body to
True, make the full view of the private types of its scope visible
if this is not the current scope and it is in the private part, and
avoid making the spec immediately visible.
(Analyze_Subprogram_Specification): Fix typo.
(New_Overloaded_Entity): Set Has_Completion on a [generic] package
that conflicts with the entity to prevent a cascaded error.
* sem_ch7.ads (Is_Private_Base_Type): New function declaration moved
here from...
* sem_ch7.adb (Is_Private_Base_Type): ...here. Remove.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Call Freeze_Expression
to freeze the expression of expression functions, but only if the
renaming comes from source.
* sem_ch12.adb (Analyze_One_Association): Likewise, and remove the
manual freezing for calls to them.
* sem_res.adb (Resolve): Remove obsolete commentary.
(Resolve_Call): Always freeze the expression of names that are
expression functions.
* sem_util.adb (Check_Fully_Declared): Add commentary and do not
check types with private component declared outside of the current
scope when it is a generic unit.
(Expression_Of_Expression_Function): Return Expression directly.
(Is_Inlinable_Expression_Function): Call Original_Node on the
result of the call to Expression_Of_Expression_Function.
Eric Botcazou [Fri, 16 Jan 2026 18:55:07 +0000 (19:55 +0100)]
ada: Fix fallout of latest change to Analyze_Subprogram_Renaming
Replacing the original expression by Expression_Of_Expression_Function is
not fully equivalent because Expression_Of_Expression_Function returns the
Original_Node of the expression.
gcc/ada/ChangeLog:
* sem_ch8.adb (Analyze_Subprogram_Renaming): Retrieve again the
expression of the expression function manually.
Eric Botcazou [Thu, 15 Jan 2026 23:31:16 +0000 (00:31 +0100)]
ada: Small tweak to error message for premature freezing of deferred constant
The tweak is to add the name of the constant to the error message. That's
a minor improvement in this simple case, but it will help for the same error
in a more complex case.
gcc/ada/ChangeLog:
* sem_res.adb (Resolve_Entity_Name): Add the name of the constant
to the error message for premature freezing of deferred constants.
Gary Dismukes [Thu, 15 Jan 2026 20:40:28 +0000 (20:40 +0000)]
ada: Missing contract checks for calls to formal subprograms within instances
While working on a visibility bug, it was noticed that preconditions
on formal subprograms are not being checked on calls to the subprograms
within package instantiations. The wrapper subprogram that is created to
perform the check (and invoke the actual subprogram) was not being used
as the target of calls, and the actual subprogram is being called instead
(bypassing the check). This was due to the subprogram renaming created
(for the actual-to-formal association) and the wrapper being homographs,
and the loop over interpretations in Collect_Interps happening to resolve
calls to the actual instead of the wrapper. This wrong resolution is
avoided by removing the homographic subprogram renaming, so that the
resolution can only resolve to the wrapper (which will only include
the precondition check in the case where assertions are enabled).
gcc/ada/ChangeLog:
* sem_ch12.adb (Build_Subprogram_Wrapper): Remove the subprogram
renaming created for the formal-to-actual association from the
list of renamings (only when such a subprogram renaming is present).
Also, change the name from plural to singular, since the procedure
only creates one wrapper, update the spec comment to reflect that,
and clarify the state and use of the Renamings parameter.
Denis Mazzucato [Fri, 9 Jan 2026 15:04:57 +0000 (16:04 +0100)]
ada: Fix Initialize aspect for constructors
This patch improve the analysis for the Initialize aspect in constructor bodies.
Specifically:
- Assignments based on the Initialize aspect are always placed at the end of the
constructor prologue, otherwise they could be overwritten depending on the
original order of components.
- Introduce the "others" default choice for the Initialize aggregate.
- Improve diagnostics when the Initialize aspect is clearly misspelled.
- Flag components that are required to be initialized but are missing from the
Initialize aspect.
- Check whether aggregate choices refer to ancestors, which is not allowed.
gcc/ada/ChangeLog:
* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Add Initialize
aspect with default others to trigger Initialize aspect analysis.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): Fix
initialization order.
(Init_From_Initialize_Expression): Retrieve initialization expression or
the default one base on the Initialize aspect.
(Init_From_Default_Or_Constructor):. Retrieve initialization expression
based on the default one in the record initialization list or the init
procedure.
* sem_ch13.adb (Analyze_Aspect_Specifications): Add check for
missing components that require initialization, and add an
expression_with_action node to place ABE during resolution of
aggregates with function calls.
(Check_Constructor_Choices): Helper to check that the aggregate choices
do not refer to ancestors.
(Diagnose_Misplaced_Aspects): Improve diagnostics when it is a clear
misspelling of Initialize aspect.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): If missing, add a
compiler generated Initialize aspect with default others to trigger
Initialize analysis.
Eric Botcazou [Mon, 12 Jan 2026 20:45:44 +0000 (21:45 +0100)]
ada: Fix incorrect finalization of renamed function call at library level
This is a regression present in recent releases for the peculiar case of the
renaming of a controlled function call done at library level, which causes
the compiler to create a dangling reference to a temporary created on the
stack of the elaboration routine to hold the result of the function call.
gcc/ada/ChangeLog:
* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out for the name
of an object renaming declaration at library level, if the call
does not return on the secondary stack.
* exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Rewrite the
renaming as a regular object declaration if it is declared at
library level and the name is a controlled function call whose
result is not returned on the secondary stack.
* exp_util.adb (Rewrite_Object_Declaration_As_Renaming): Minor fix.
Gary Dismukes [Wed, 7 Jan 2026 20:23:55 +0000 (20:23 +0000)]
ada: Visibility bug in instance of generic with precondition on formal subprogram
The compiler may issue an error saying that a global entity referenced in
the precondition of a formal subprogram is not visible when the containing
generic is instantiated at a place where the entity is not directly visible.
This was due to the formal subprogram's contract not having been analyzed
in the generic template. As a result, the nodes with global references were
not properly captured (by Save_Global_References).
An additional problem was exposed, which was that references within
contract aspect specifications of generic formals to other formals of the
same generic were not being properly analyzed/resolved, due to copying
the aspect specifications of the already-analyzed copy of the generic
formal when building subprogram wrappers for the contracts. This could
lead to blowups in the back end due to references to the original formals
occurring in the expansion of the instantiation. This is addressed by
copying the aspect specifications of the unanalyzed formals rather than
those that were analyzed in the copy of the generic template.
gcc/ada/ChangeLog:
* contracts.adb (Analyze_Contracts): Add cases for formal subprogram
Nkinds so that Analyze_Entry_Or_Subprogram_Contract will be called
for them.
* sem_attr.adb (Analyze_Attribute_Old_Result): Account for the cases
of formal subprogram Nkinds, allowing Old attributes for those.
* sem_ch12.adb (Build_Subprogram_Wrappers): Add a formal for passing
the unanalyzed generic formal, and use it for copying any aspect
specifications of the generic formal rather than copying the analyzed
generic formal's aspects.
(Analyze_One_Association): Pass Assoc.Un_Formal as an additional
actual in the call to Build_Subprogram_Wrappers.
Steve Baird [Thu, 8 Jan 2026 22:31:16 +0000 (14:31 -0800)]
ada: Missing dynamic accessibility check assigning conditional expr to saooaaat.
When a conditional expression is assigned to a saooaaat (that is, to a
stand-alone object of an anonymous access type), in some cases the
required dynamic accessibility check was not being performed.
gcc/ada/ChangeLog:
* accessibility.adb (Needs_Accessibility_Level_Temp_Or_Check): Conform
to spec changes. Return True for the RHS of an assignment statement.
* accessibility.ads: Change name of Is_Anonymous_Access_Actual
to Needs_Accessibility_Level_Temp_Or_Check; the function now returns
True in cases other than those described by the old name.
Also change name of the formal parameter from N to Conditional_Expr.
* exp_ch4.adb (Expand_N_If_Expression): Update call to a function
whose name changed.
Javier Miranda [Wed, 24 Dec 2025 10:46:40 +0000 (10:46 +0000)]
ada: Improve machinery for generating predicate check
gcc/ada/ChangeLog:
* sem_util.adb (Is_Fully_Initialized_Variant): Moved inside
subprogram Is_Fully_Initialized_Type.
(Is_Fully_Initialized_Constrained_Array): New subprogram that
factorizes code of Is_[Fully|Partially]_Initialized_Type.
(Is_Fully_Initialized_Record_Type): New subprogram; add missing
support for incomplete types.
(Is_Partially_Initialized_Record_Type): New subprogram; add missing
support for incomplete types.
(Is_Partially_Initialized_Type): Add new formal for predicate checks.
* sem_util.ads (Is_Partially_Initialized_Type): Add new formal for
predicate checks.
* sem_warn.adb (Type_OK_For_No_Value_Assigned): Use named parameters
in call to Is_Partially_Initialized_Type.
* sem_ch3.adb (Analyze_Object_Declaration): Add new actual for
predicate checks.
Eric Botcazou [Sun, 11 Jan 2026 12:00:32 +0000 (13:00 +0100)]
ada: Small tweaks to semantic analysis of expression functions
They are mostly about streamlining the implementation, but also eliminate
unexpected or duplicate error messages in some specific cases.
gcc/ada/ChangeLog:
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Introduce new local
boolean constant From_Expression_Function, use it throughout, and
replace an equivalent test by it. Do not deal with name conflicts
here when it is true. Do not verify the consistency of overriding
indicators for stand-alone expression functions.
* sem_util.ads (Is_Expression_Function_Or_Completion): Fix improper
wording in description.
* sem_util.adb (Is_Expression_Function_Or_Completion): Streamline
the implementation.
Eric Botcazou [Thu, 8 Jan 2026 20:58:05 +0000 (21:58 +0100)]
ada: Fix endless loop on Address aspect for object with dynamic address
The freezing machinery ends up inserting a freeze node into its own Actions
list, which causes Expand_N_Freeze_Entity to enter an endless loop, because
Remove_Init_Call incorrectly returns the initialization call of a different
variable than the one for which it was invoked.
gcc/ada/ChangeLog:
* exp_util.adb (Remove_Init_Call.Find_Init_Call_In_List): Check that
the first actual denotes the expected variable modulo qualification
and conversion.
Javier Miranda [Sun, 4 Jan 2026 10:32:56 +0000 (10:32 +0000)]
ada: Handle call to C++ constructor placed in return statement
Add missing support for C++ constructor call placed in the return
statement.
gcc/ada/ChangeLog:
* sem_ch3.adb (Analyze_Object_Declaration): Report an error if the
return statement of a function with foreign convention has a call
to a C++ constructor.
* exp_ch3.adb (Expand_N_Object_Declaration): Handle initialization
expression calling a C++ constructor in an extended return statement
of a subprogram with Ada convention.
Denis Mazzucato [Tue, 23 Dec 2025 14:25:46 +0000 (15:25 +0100)]
ada: Enable checks during analysis of expanded dispatching calls
This patch enables the generation of run-time checks during the analysis and
resolution of expanded dispatching calls. They were previously disabled to avoid
reporting spurious warnings under the ZFP run-time, but this is no longer
required.
gcc/ada/ChangeLog:
* exp_disp.adb (Expand_Dispatching_Call): Remove suppression of checks
during analysis of expanded dispatching calls.
This makes it possible to use the word "finally" as an identifier when
GNAT extensions are enabled. This does not make the syntax ambiguous
and the "finally" syntax extension is not affected.
gcc/ada/ChangeLog:
* doc/gnat_rm/gnat_language_extensions.rst: Add that finally is a
non-reserved keyword.
* par-ch5.adb (P_Sequence_Of_Statements): handle "finally" syntax
extension.
* snames.ads-tmpl: Remove the concept of GNAT extension reserved
word.
* snames.adb-tmpl (Is_Keyword_Name): Likewise.
* scans.adb (Initialize_Ada_Keywords): Likewise.
* par-util.adb (Check_Future_Keyword): Likewise.
* gnat_rm.texi: Regenerate.
Bob Duff [Wed, 7 Jan 2026 18:57:52 +0000 (13:57 -0500)]
ada: Crash with pragma Ignore_Pragma in SPARK mode
This patch fixes a bug in the expansion of protected bodies.
Consolidate the various cases that simply copy the Op_Body,
which is usually a protected subprogram declaration or body.
Remove the "raise Program_Error", because it's not really the
job of this code to enforce the rules about what can appear
in a protected body. Better to remove all the cases that
have accreted over the years, and just assume that anything
not allowed syntactically must be an artifact of expansion.
The specific goal here is to avoid raising Program_Error
when Op_Body is a null statement, which happens when there
is a "SPARK_Mode => Off" aspect (turned into a pragma)
and also a "pragma Ignore_Pragma (SPARK_Mode)" (which turns
the pragma into a null statement). The fix here is more
general and more "DRY".
gcc/ada/ChangeLog:
* exp_ch9.adb (Expand_N_Protected_Body):
Remove "raise Program_Error" and consolidate other
cases.
The GPR files can be used to build the Ada runtime, usually via
libada.gpr as the entry point. This commits extends the GPR project
definitions to make them suitable for shared and static PIC runtime
builds.
When LIBRARY_KIND is "static-pic", the libraries gain a "_pic" suffix,
as expected by the build tools. When it's "dynamic", we configure the
Library_Version attribute in order to set the right SONAME on Unix, as
well as the expected symlinks.
Finally, libgnarl.gpr now depends on libgnat.gpr; the missing dependency
hasn't caused problems so far because static libraries don't resolve
missing symbols at build time, but it's necessary to build shared
libraries.
gcc/ada/ChangeLog:
* libgnarl/libgnarl.gpr: Add dependency on libgnat.gpr.
Set Library_Name and Library_Version depending on Library_Kind.
* libgnat/libgnat.gpr: Likewise.
Denis Mazzucato [Tue, 6 Jan 2026 12:38:49 +0000 (13:38 +0100)]
ada: Support for implicit parameterless constructor
An implicit parameterless constructor is available when no other constructor is
declared for a tagged type that has an ancestor with constructors. The implicit
parameterless constructor calls the parent parameterless constructor through the
Super aspect without arguments.
gcc/ada/ChangeLog:
* aspects.ads (Aspects): Make Super aspect optional to allow for
explicit call to parent parameterless constructor.
* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Build implicit
parameterless constructor when no other constructors are defined but the
type has an ancestor with constructors.
* exp_ch6.adb
(Init_Expression_If_Any): Pe4rmit implicit calls to parameterless
constructors in initialization expressions if available.
(Make_Parent_Constructor_Call): Super without parameters calls the
parent parameterless constructor.
* sem_ch13.adb (Analyze_Aspect_Specification): Allow Super aspect
without expression.
* sem_ch3.adb (Analyze_Object_Declaration): Delay check for missing
parameterless constructor until the the implicit constructor is built.
Steve Baird [Mon, 15 Dec 2025 21:47:35 +0000 (13:47 -0800)]
ada: New aspects for use in CodePeer's taint analysis.
Add minimal compiler support for three new aspects: Taint_Sanitizer,
Taint_Sink, and Taint_Source. This support consists of accepting (with no
accompanying semantic analysis) aspect specifications for these aspects, using
either aspect_specification syntax or pragmas. Such aspect specifications are
subsequently ignored by the compiler front end. These aspects are intended for
use with CodePeer and are (or will be) documented in CodePeer documentation;
they are not documented in the GNAT RM.
gcc/ada/ChangeLog:
* aspects.ads: Add three new Taint_Xxx aspects to the Aspect_Id
enumeration type and define a corresponding subtype,
Ignored_Aspects.
* exp_prag.adb (Expand_N_Pragma): Don't rewrite a taint-related
pragma as a null statement. We want to leave the (unanalyzed)
pragma in the tree.
* sem_ch13.adb (Analyze_One_Aspect): Leave taint-related aspect
specifications
(and their arguments, if any) unanalyzed.
(Check_Aspect_At_Freeze_Point): Update a case statement to treat
the new aspects as an error case.
* sem_util.adb (Should_Ignore_Pragma_Sem): Return True for an
ignored pragma.
* snames.ads-tmpl: Define names for the three new aspects.
Denis Mazzucato [Mon, 22 Dec 2025 12:44:41 +0000 (13:44 +0100)]
ada: Fix spurious range check for out mode scalars in class-wide preconditions
This patch fixes a spurious range check that was generated for out mode scalars
after a class-wide precondition call. This issue was not present in static
preconditions, but only in dynamic ones. This patch refactors the two helper
call builders into the same to ensure the same processing of actuals.
gcc/ada/ChangeLog:
* exp_ch6.adb (Build_Helper_Call): Refactor code to handle both static and
dynamic precondition calls in the same way.
Denis Mazzucato [Tue, 16 Dec 2025 10:16:32 +0000 (11:16 +0100)]
ada: Refactor assignments in constructor prologue
Constructor prologues now call the same routine as initialization procedures to
build component assignments.
gcc/ada/ChangeLog:
* exp_ch3.adb (Build_Record_Init_Proc): Move Build_Assignment to
Build_Component_Assignment in Exp_Util for a more general use.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): refactor using
Build_Component_Assignment.
* exp_util.adb (Build_Component_Assignment): Logic to build component
assignments for initialization procedures and constructor prologues.
* exp_util.ads (Build_Component_Assignment): Likewise.
* sem_ch5.adb (Analyze_Assignment): Revert back changes from previous
attempt to fix assignments of limited types in constructor prologues,
the use of Build_Component_Assignment makes those changes unnecessary.
Eric Botcazou [Sat, 3 Jan 2026 08:58:32 +0000 (09:58 +0100)]
ada: Fix typo in head comment of Sinput specification
As explained later in the commentary of the file, wide characters specified
to be line terminators are considered to be logical instead of physical line
terminators. The change also aligns the description of the physical line
terminators with the one present later in the commentary.
Tomasz Kamiński [Mon, 18 May 2026 11:14:25 +0000 (13:14 +0200)]
libstdc++: Add data/member for initializer_list, and remove std overloads
This implements changes section 4.6 of P3016R6, and initializer_list related
parts of 4.7 and 4.8. The change makes immediately dangling invocations of
std::begin, std::end, and std::data on braced-init list ill-formed (see
range_access_neg.cc and range_access17_neg.cc):
auto it = std::begin({1, 2, 3}); // ILL-FORMED, it was dangling
(it == std::end({1, 2, 3})); // ILL-FORMED, was unspecified
auto* ptr = std::data({1, 2, 3}); // ILL-FORMED, ptr was dangling
However, similary problemetic calls for std::rbegin, std::rend remain
well-formed (see range_access14_neg.cc), as initializer_list overloads
are preserved for these functions:
auto rit = ranges::rbegin({1, 2, 3}); // COMPILES, dangling
auto rend = ranges::rend({1, 2, 3}); // COMPILES, danging
Note, that non-problematic std::size({1, 2, 3}) and std::empty({1, 2, 3})
use c-array overloads, and remain well-formed.
Per paper, to keep std::data(il) and std::empty(il) well-formed, the data
and empty member are added to initializer_list.
libstdc++-v3/ChangeLog:
* include/bits/version.def (initializer_list): Define with value
202511 for C++26.
* include/bits/version.h: Regenerate.
* libsupc++/initializer_list (initializer_list::data)
(initializer_list::empty) [__glibcxx_initializer_list >= 202511L]:
Define.
(std::begin(initializer_list<_Tp>), std::end(initializer_list<_Tp>)):
Define only if __glibcxx_initializer_list < 202511L (i.e. not defined).
* include/bits/range_access.h (std::empty(initializer_list<_Tp>))
(std::data(initializer_list<_Tp>)): Define only if
__glibcxx_initializer_list < 202511L (i.e. not defined).
* testsuite/18_support/initializer_list/range_access.cc: Move test for
brace-init list to range_access_neg.c. Included <iterator> in C++26 or
later mode.
* testsuite/18_support/initializer_list/data_empty_mem.cc: New test.
* testsuite/18_support/initializer_list/range_access14.cc: New test.
* testsuite/18_support/initializer_list/range_access14_neg.cc: New test.
* testsuite/18_support/initializer_list/range_access17.cc: New test.
* testsuite/18_support/initializer_list/range_access17_neg.cc: New test.
* testsuite/18_support/initializer_list/range_access_neg.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Eric Botcazou [Mon, 25 May 2026 07:42:04 +0000 (09:42 +0200)]
Restore original format of -fstack-usage and add new second field
This should minimize the backward compatibility breakage.
gcc/
* doc/invoke.texi (fstack-usage): Document new second field.
* toplev.cc (output_stack_usage_1): Revert latest changes and add
the mangled name as the second field.
If the last bit in a bitmap was in elt->bits[0], bitmap_last_set_bit
would not read it and would instead fall through with "word" still set
to elt->bits[1], which is known to be 0.
This patch fixes it to use the same structure as
bitmap_first_set_bit_worker.
As you might expect from this, only the sbitmap version of this
function appears to be used.
gcc/
* bitmap.cc (bitmap_last_set_bit): Fix handling of index 0.
Jerry DeLisle [Sun, 24 May 2026 18:51:49 +0000 (11:51 -0700)]
Fortran: [PR93727] Fix EX format kind=8 output on ILP32 targets
On 32-bit targets such as ARM where unsigned long is 32 bits, the
kind=8 case in get_float_hex_string used unsigned long for frac_part.
The kind=8 mantissa requires 52 bits (13 hex digits), so the cast
silently truncated the upper bits, producing wrong hex output. In
addition, converting a ~4.5e15 double value to a 32-bit unsigned long
is out of range, which raised IEEE_INVALID_FLAG on ARM hardware.
Fix kind=8 by using GFC_UINTEGER_8, which is guaranteed 64 bits on all
targets. Update kind=10 and kind=16 to use GFC_UINTEGER_8 throughout
for consistency with libgfortran conventions.
PR fortran/93727
libgfortran/ChangeLog:
* io/write_float.def (get_float_hex_string): Fix kind=8 frac_part
from unsigned long to GFC_UINTEGER_8 to correct truncated hex
output and IEEE_INVALID_FLAG on ILP32 targets. Update kind=10
and kind=16 to use GFC_UINTEGER_8 for consistency.