]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 weeks agolibstdc++: Revert making ref_view<R> statically sized.
Tomasz Kamiński [Tue, 26 May 2026 16:01:40 +0000 (18:01 +0200)] 
libstdc++: Revert making ref_view<R> statically sized.

This patch reverts all changes except introduction of
ranges::__static_size from r17-810-g7239744d25dadf.

In addition to expected errors from breaking inplace_vector
preconditions, this lead to change in the return type of
define_static_array, when applied on (adapted) ref_view:
  int x[10];
  auto x = define_static_array(x | views::transform(...));
Type of x changed from span<const ...> to span<const ..., 10>,
due size being statically know.

This was considered beyond the scope of implementation freedom,
and we should wait for acceptance of P3928R0 instead.

libstdc++-v3/ChangeLog:

* include/std/ranges (ref_view::size()): Only call ranges::size(*_M_r).
(ref_view::empty): Only call ranges::empty(*_M_r).
* testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc:
Except no errors from ref_view uses.
* testsuite/23_containers/inplace_vector/cons/from_range_neg.cc:
Likewise.

3 weeks agoFortran: Add debug functions for OpenMP data structures
Paul-Antoine Arras [Wed, 6 May 2026 18:07:44 +0000 (20:07 +0200)] 
Fortran: Add debug functions for OpenMP data structures

show_omp_namelist and show_omp_clauses cannot be called from GDB because
dumpfile is NULL at debug time. Add debug wrappers that temporarily set it to
stderr.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (debug): Add debug functions for gfc_omp_namelist
and gfc_omp_clauses.

3 weeks agoada: Fix System.Interrupt_Names generation on VxWorks (continued)
Eric Botcazou [Mon, 16 Feb 2026 21:26:56 +0000 (22:26 +0100)] 
ada: Fix System.Interrupt_Names generation on VxWorks (continued)

gcc/ada/ChangeLog:

* xsintnam.sed: Disable style checks.

3 weeks agoada: Fix System.Interrupt_Names generation on VxWorks
Ronan Desplanques [Mon, 16 Feb 2026 14:21:18 +0000 (15:21 +0100)] 
ada: Fix System.Interrupt_Names generation on VxWorks

The spec of Ada.Interrupts.Names for VxWorks (and RTEMS) contains a
subtype declaration. This is a deviation from the Ada reference manual
and the sed script used to generate System.Interrupt_Names failed to
handle it. This patch fixes this.

gcc/ada/ChangeLog:

* xsintnam.sed: Handle special case.

3 weeks agoada: Fix build failure on Windows machines
Eric Botcazou [Sat, 14 Feb 2026 23:00:55 +0000 (00:00 +0100)] 
ada: Fix build failure on Windows machines

The -E switch is not recognized by old versions of GNU sed, so remove it as
well as the pipe since it hides error messages.

gcc/ada/ChangeLog:

* gcc-interface/Makefile.in ($(RTSDIR)/s-intnam.ads): Change recipe
to use a basic invocation of 'sed'.

3 weeks agolibstdc++: Fix <optional> for freestanding [PR125450]
Jonathan Wakely [Tue, 26 May 2026 09:50:53 +0000 (10:50 +0100)] 
libstdc++: Fix <optional> for freestanding [PR125450]

libstdc++-v3/ChangeLog:

PR libstdc++/125450
* include/std/optional (range_format): Do not define for
freestanding.

3 weeks agolibstdc++: Make ref_view<R> statically sized if R has static size
Tomasz Kamiński [Fri, 24 Apr 2026 03:26:13 +0000 (05:26 +0200)] 
libstdc++: Make ref_view<R> statically sized if R has static size

This patch introduces ranges::__static_size<_Range> helper functions,
that returns ranges::size(__rg) for __statically_sized_range.
This function is then used for ref_view<R>::size if R has static size,
avoiding dereference of pointer value that is not known at compile time.
Similarly for ref_view<R>::empty() we compare the size with zero, if it
is known statically.

This implements relevant part of P3928R0: static_sized_range by
Hewill Kang. As standard does not specify when constexpr functions
are usable at compile time, such implementation are allowed (but not
mandated) by current draft.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::__static_size): Define.
* include/std/ranges (ref_view::size()): For ranges with static
size return ranges::__static_size<_Range>.
(ref_view::empty): For ranges with static size, compare size
against zero.
* testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc:
Expect errors from ref_view uses.
* testsuite/23_containers/inplace_vector/cons/from_range_neg.cc:
Expect errors from ref_view uses.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 weeks agolibstdc++: static_assert that static sized range size is less than inplace_vector...
Tomasz Kamiński [Fri, 24 Apr 2026 03:26:06 +0000 (05:26 +0200)] 
libstdc++: static_assert that static sized range size is less than inplace_vector capacity

Resolves LWG 4396. Improve inplace_vector(from_range_t, R&& rg)

The test case illustrates that views applied to span<T, N> are still
statically sized, but once applied to array<T, N> are not. This is
caused by the fact that ref_view stores a pointer to array, and
dereference of unknown pointers does not produce reference to unknown,
and simply yield non-constant expressions (unknown pointer is not
equivalent to pointer to unknown, as it may be null).

libstdc++-v3/ChangeLog:

* include/std/inplace_vector (inplace_vector(std::from_range, __Rg&&)):
Add static_asserts checking range size.
* testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc:
New test.
* testsuite/23_containers/inplace_vector/cons/from_range_neg.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 weeks agolibstdc++: Deprecate std::memory_order::consume
Jonathan Wakely [Thu, 21 May 2026 16:09:47 +0000 (17:09 +0100)] 
libstdc++: Deprecate std::memory_order::consume

This implements P3475R2, "Defang and deprecate memory_order::consume",
approved in Hagenberg, 2025.

It looks like the using-declaration for memory_order_consume in
<stdatomic.h> was not deprecated by the paper, but I don't think we can
implement that if we warn for the name in <atomic>. It doesn't make
sense to me for it to be deprecated in C++ but still usable in the C/C++
compatibility header. It's still just as useless in common C/C++
headers, so we should warn.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (memory_order::consume): Add
deprecate attribute.
(memory_order_consume): Likewise.
(kill_dependency): Likewise.
(atomic_flag::clear): Disable warning with pragmas.
(__atomic_base::store, __atomic_base<T*>::store): Likewise.
* include/c_compatibility/stdatomic.h (memory_order_consume):
Likewise.
* testsuite/29_atomics/atomic/requirements/compare_exchange_lowering.cc:
Ignore deprecation warnings.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc:
Likewise.
* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Add
dg-warning directives.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Winvalid-memory-model-2.C: Disable deprecated
warnings for C++26 and up.
* g++.dg/warn/Winvalid-memory-model.C: Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 weeks agolibstdc++: Add missing constraints to vector and deque deduction guides
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>
3 weeks agolibstdc++: Split <iosfwd> and only include it in <ios> [PR125371]
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>
3 weeks agolibstdc++: Merged concept for ranges with static sized.
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>
3 weeks agoada: Fix build failure on Windows machines
Eric Botcazou [Sat, 14 Feb 2026 22:58:51 +0000 (23:58 +0100)] 
ada: Fix build failure on Windows machines

gcc/ada/ChangeLog:

* xsintnam.sed: Do not filter out comments.

3 weeks agoada: Fix build failure for Windows platforms
Eric Botcazou [Fri, 13 Feb 2026 20:21:41 +0000 (21:21 +0100)] 
ada: Fix build failure for Windows platforms

gcc/ada/ChangeLog:

* libgnarl/s-interr__sigaction.adb: Add with clause for
System.OS_Interface.

3 weeks agoada: Add suffix to name of newly added procedures
Eric Botcazou [Fri, 13 Feb 2026 22:42:24 +0000 (23:42 +0100)] 
ada: Add suffix to name of newly added procedures

These procedures are specifically meant for accessibility checks of returns.

gcc/ada/ChangeLog:

* accessibility.adb (Apply_Accessibility_Check_For_Anonymous):
Rename into...
(Apply_Accessibility_Check_For_Anonymous_Return): ...this.
(Apply_Accessibility_Check_For_Class_Wide): Rename into...
(Apply_Accessibility_Check_For_Class_Wide_Return): ...this.
(Apply_Accessibility_Check_For_Discriminant): Rename into...
(Apply_Accessibility_Check_For_Discriminated_Return): ...this.
(Apply_Accessibility_Check_For_Return): Adjust to above renamings.

3 weeks agoada: Fix missing accessibility check for anonymous access function result
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.

3 weeks agoada: Overriding of First_Controlling_Parameter tagged type primitive
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.

3 weeks agoada: Fix SPARK RM 6.9 Rule 32 check
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.

3 weeks agoada: Make Interrupt_State not require Ada.Interrupts
Ronan Desplanques [Thu, 12 Feb 2026 10:59:07 +0000 (11:59 +0100)] 
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.

3 weeks agoada: Fix minor issues
Ronan Desplanques [Thu, 12 Feb 2026 10:59:07 +0000 (11:59 +0100)] 
ada: Fix minor issues

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.

gcc/ada/ChangeLog:

* libgnarl/s-interr.adb (Unprotected_Exchange_Handler): Improve
comment and formatting.
(Server_Task): Fix task state.
* rtsfind.adb (RTE): Remove incorrect comment.

3 weeks agoada: Missing initialization of aggregate components
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).

3 weeks agoada: Copy documentation of gnatdll -m switch from its help message
Piotr Trojanek [Thu, 12 Feb 2026 12:07:30 +0000 (13:07 +0100)] 
ada: Copy documentation of gnatdll -m switch from its help message

Switch -m was only documented in gnatdll help message. Now this documentation,
while brief, is copied into GNAT User's Guide.

gcc/ada/ChangeLog:

* doc/gnat_ugn/platform_specific_information.rst
(Using gnatdll): Document switch -m.
* gnat_ugn.texi: Regenerate.

3 weeks agoada: Relocate Check_Valid_Ghost_Declaration
Viljar Indus [Thu, 12 Feb 2026 10:26:48 +0000 (12:26 +0200)] 
ada: Relocate Check_Valid_Ghost_Declaration

Relocate it to an alphabetically correct location.

gcc/ada/ChangeLog:

* ghost.adb (Check_Valid_Ghost_Declaration): Relocate the procedure.

3 weeks agoada: Implement SPARK RM 6.9 (23)
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.

3 weeks agoada: Fix long-standing issue with qualified expressions of class-wide types
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.

3 weeks agoada: Put_Image attribute_definition_clause incorrectly ignored.
Steve Baird [Mon, 9 Feb 2026 22:05:51 +0000 (14:05 -0800)] 
ada: Put_Image attribute_definition_clause incorrectly ignored.

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.

3 weeks agoada: Remove Tempdir package
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.

gcc/ada/ChangeLog:

* tempdir.ads, tempdir.adb: Remove.
* gcc-interface/Makefile.in (GNATMAKE_OBJS): Remove dependency on Tempdir.

3 weeks agoada: Remove Tempdir from gnatname
Piotr Trojanek [Sat, 31 Jan 2026 11:22:52 +0000 (12:22 +0100)] 
ada: Remove Tempdir from gnatname

Package Tempdir duplicates routine Create_Temp_File that is also provided by
System.OS_Lib; we don't need it.

gcc/ada/ChangeLog:

* gnatname.adb: Use System.OS_Lib routine.

3 weeks agoada: Remove Tempdir from gnatmake
Piotr Trojanek [Sat, 31 Jan 2026 11:23:10 +0000 (12:23 +0100)] 
ada: Remove Tempdir from gnatmake

Package Tempdir duplicates routine Create_Temp_File that is also provided by
System.OS_Lib; we don't need it.

gcc/ada/ChangeLog:

* make.adb: Use System.OS_Lib routine.

3 weeks agoada: Fix internal error on access to function as component via limited with
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.

3 weeks agoada: Factor out common pattern in Exp_Ch6
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.

3 weeks agoada: Error on legal No_Return subprogram with formals subject to Type_Invariant
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).

3 weeks agoada: Print restrictions in the SARIF report
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.

3 weeks agoada: Fix recursion calls in Remove_Side_Effects
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.

3 weeks agoada: Fix Assertion_Level dependency for Runtime level
Viljar Indus [Wed, 4 Feb 2026 12:35:48 +0000 (14:35 +0200)] 
ada: Fix Assertion_Level dependency for Runtime level

gcc/ada/ChangeLog:

* sem_util.adb (Depends_On_Level): Fix condition for Runtime
level.

3 weeks agoada: Normalize the handling of assertion policies
Viljar Indus [Wed, 4 Feb 2026 12:42:22 +0000 (14:42 +0200)] 
ada: Normalize the handling of assertion policies

Normalize On and Off to Check and Ignore policies in order to avoid
internal logic errors.

gcc/ada/ChangeLog:

* sem_util.adb (Policy_In_Effect): Normalize the policy names.

3 weeks agoada: Tech debt: Remove Is_Boolean_Aspect
Bob Duff [Mon, 2 Feb 2026 18:08:37 +0000 (13:08 -0500)] 
ada: Tech debt: Remove Is_Boolean_Aspect

Remove the Is_Boolean_Aspect flag. It was unnecessary,
and anyway, the comment on it was wrong.

Misc comment improvement.

gcc/ada/ChangeLog:

* gen_il-fields.ads (Is_Boolean_Aspect): Remove.
* gen_il-gen-gen_nodes.adb: Likewise.
* sinfo.ads: Likewise.
* sem_ch13.adb: Likewise. Minor comment fix.
* aspects.ads: Clean up comments, including removing
some redundancy.
* freeze.adb: Fix comment typo.
* sem_eval.ads: Fix comment typo.
* tbuild.ads: Fix comment; there's no reason to mention the
number, especially when it's wrong.

3 weeks agoada: Add missing assertion level check
Viljar Indus [Fri, 23 Jan 2026 13:56:34 +0000 (15:56 +0200)] 
ada: Add missing assertion level check

Add a missing check for assertion levels inside aspect specifications
described in rule 14 in SPARK RM 6.9.

gcc/ada/ChangeLog:

* ghost.adb (Check_Ghost_Policy): Add check for assertion levels
inside aspect specifications.

3 weeks agoada: Tech debt: Remove Aspect_Unimplemented
Bob Duff [Sun, 1 Feb 2026 21:20:49 +0000 (16:20 -0500)] 
ada: Tech debt: Remove Aspect_Unimplemented

It's time to remove this temporary code;
the comment "-- ??? temp for now" was inserted in 2015.

gcc/ada/ChangeLog:

* aspects.ads (Aspect_Unimplemented): Remove.
* sem_ch13.adb (Aspect_Unimplemented): Remove.

3 weeks agoada: Tech debt: Remove exception handling from aspects
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.

3 weeks agoada: fix: use correct scope when unnesting subprocedure
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.

3 weeks agoada: fix: drop renamings along with dropped subp
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.

3 weeks agoada: Align VxWorks version of System.Interrupts
Ronan Desplanques [Tue, 27 Jan 2026 11:56:42 +0000 (12:56 +0100)] 
ada: Align VxWorks version of System.Interrupts

A recent minor fix to the main System.Interrupts was omitted for the
VxWorks-specific version. This patch fixes this.

gcc/ada/ChangeLog:

* libgnarl/s-interr__vxworks.adb (Unprotected_Exchange_Handler): Fix
exception message.

3 weeks agoada: Remove the libutil dependency on Linux
Sebastian Poeplau [Mon, 26 Jan 2026 15:03:59 +0000 (16:03 +0100)] 
ada: Remove the libutil dependency on Linux

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.

3 weeks agoada: Fix wrong comments
Ronan Desplanques [Mon, 26 Jan 2026 14:55:55 +0000 (15:55 +0100)] 
ada: Fix wrong comments

Unlike what the comments said, most reserved interrupts are not masked
since they also belong to Keep_Unmasked.

gcc/ada/ChangeLog:

* libgnarl/s-interr.adb (Interrupt_Manager, Server_Task): Fix
comments.

3 weeks agoada: Minor comment and formatting fixes
Ronan Desplanques [Mon, 26 Jan 2026 14:55:55 +0000 (15:55 +0100)] 
ada: Minor comment and formatting fixes

gcc/ada/ChangeLog:

* libgnarl/s-interr.adb (User_Handler): Improve comment.
(Unprotected_Exchange_Handler): Fix message string.

3 weeks agoada: Small refactoring in Check_Anonymous_Access_Return_With_Tasks
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.

3 weeks agoada: Deep delta aggregates incorrectly rejected with -gnatX.
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.

3 weeks agoada: Parsing error on declare expr in expression default for generic formal function
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.

3 weeks agoada: Boolean flag for Unsigned_Base_Range aspect is ignored
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.

3 weeks agoada: Fix exception on attaching non-handler procedure
Ronan Desplanques [Wed, 21 Jan 2026 16:16:03 +0000 (17:16 +0100)] 
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.

gcc/ada/ChangeLog:

* libgnarl/s-interr.adb (Unprotected_Exchange_Handler): Fix
exception message.

3 weeks agoada: Unsigned_Base_Range aspect (part 8)
Javier Miranda [Tue, 20 Jan 2026 19:54:46 +0000 (19:54 +0000)] 
ada: Unsigned_Base_Range aspect (part 8)

Enable this language extension (switch -gnatd.u is no longer required).

gcc/ada/ChangeLog:

* aspects.adb (Get_Aspect_Id): Enable aspect Unsigned_Base_Range
* debug.adb (Debug_Flag_Dot_U): Leave free this switch
* par-ch4.adb (Scan_Apostrophe): Enable attribute Unsigned_Base_Range
* sem_prag.adb (Analyze_Pragma): Enable pragma Unsigned_Base_Range
* doc/gnat_rm/gnat_language_extensions.rst: Document unsigned base range.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

3 weeks agoRISC-V: Refactor riscv-fusion.cc to use table-driven dispatch
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.

3 weeks agoRISC-V: Fix multiple bugs in riscv_macro_fusion_pair_p
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.

3 weeks agoDaily bump.
GCC Administrator [Tue, 26 May 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

3 weeks agomatch: Fix up `(smaller)a ==/!= (smaller) b` pattern for pointers [PR125453]
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>
3 weeks agoAdjust stack-usage-realign.c for commit dbb7b2af233
H.J. Lu [Mon, 25 May 2026 22:04:33 +0000 (06:04 +0800)] 
Adjust stack-usage-realign.c for commit dbb7b2af233

Adjust stack-usage-realign.c for

commit dbb7b2af2333b69707ffbea6a2a98830c37a0485
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon May 25 09:42:04 2026 +0200

    Restore original format of -fstack-usage and add new second field

* gcc.target/i386/stack-usage-realign.c: Adjusted.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoAVR: target/125409 - Add fixed-point conversions to / from [u]int24_t.
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.

PR target/125409
gcc/
* config/avr/avr-fixed.md (FIXED_A, FIXED_B): Add PSI to iterators.

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.

3 weeks agoAVR: ad target/121343 - Let __load_<size> insns use hard-reg constraints.
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.

3 weeks agolibstdc++: Fix some test failures due trivial unions (P3074R7) change.
Tomasz Kamiński [Mon, 25 May 2026 14:30:46 +0000 (16:30 +0200)] 
libstdc++: Fix some test failures due trivial unions (P3074R7) change.

The corresponding types are now trivially destructible, per changes
from P3074R7, see PR119059.

libstdc++-v3/ChangeLog:

* testsuite/20_util/is_constructible/value-2.cc:
Adjust expected value for C++26 (__cpp_trivial_union >= 202502L).
* testsuite/20_util/is_destructible/value.cc: Likewise.
* testsuite/20_util/is_nothrow_destructible/value.cc: Likewise.

3 weeks agoOpenMP: Fix omp_check_for_duplicate_variant [PR125377]
Tobias Burnus [Mon, 25 May 2026 11:13:46 +0000 (13:13 +0200)] 
OpenMP: Fix omp_check_for_duplicate_variant [PR125377]

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.

3 weeks agolibstdc++: Add begin, end, (const_)iterator members to valarray.
Tomasz Kamiński [Fri, 15 May 2026 11:41:16 +0000 (13:41 +0200)] 
libstdc++: Add begin, end, (const_)iterator members to valarray.

This implements additions from sections 4.3, 4.4, 4.5 of P3016R6.

libstdc++-v3/ChangeLog:

* include/bits/version.def (valarray): Define.
* include/bits/version.h: Regenerate.
* include/std/valarray: (__cpp_lib_valarray): Define.
(valarray::begin, valarray::end, valarray::iterator)
(valarray::const_iterator) [__glibcxx_valarray >= 202511L]: Define.
(std::begin(valarray<_Tp>&), std::begin(const valarray<_Tp>&))
(std::end(valarray<_Tp>&), std::end(const valarray<_Tp>&)): Define
only if __glibcxx_valarray < 202511L (i.e. not defined).
* include/bits/range_access.h (std::valarray)
(std::begin(valarray<_Tp>&), std::begin(const valarray<_Tp>&))
(std::end(valarray<_Tp>&), std::end(const valarray<_Tp>&)): Forward
declare only if __glibcxx_valarray < 202511L (i.e. not defined).
* testsuite/26_numerics/valarray/range_access3.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Nathan Myers <ncm@cantrip.org>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 weeks agoada: Fix crash on equality of unchecked union components of formal parameters
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.

3 weeks agoada: Rename Image_Should_Call_Put_Image into Image_Must_Call_Put_Image
Eric Botcazou [Wed, 21 Jan 2026 10:13:45 +0000 (11:13 +0100)] 
ada: Rename Image_Should_Call_Put_Image into Image_Must_Call_Put_Image

The former is a bit of a misnomer, since there is absolutely no leeway.

gcc/ada/ChangeLog:

* exp_put_image.ads (Image_Should_Call_Put_Image): Rename into...
(Image_Must_Call_Put_Image): ...this.
* exp_put_image.adb (Image_Should_Call_Put_Image): Rename into...
(Image_Must_Call_Put_Image): ...this.
* exp_imgv.adb (Expand_Image_Attribute): Adjust to above renaming.
(Expand_Wide_Image_Attribute): Likewise.
(Expand_Wide_Wide_Image_Attribute): Likewise.
* sem_attr.adb (Eval_Attribute): Likewise.

3 weeks agoada: Fix different 'Img and 'Image on enumeration type with Put_Image
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.

3 weeks agoada: Update references to Parameter Associations RM 6.4.1
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.

gcc/ada/ChangeLog:

* sem_util.adb: Fix RM references.
* sem_util.ads: Likewise.
* sem_warn.adb: Likewise.

3 weeks agoada: Set Etype before analysis for conditions generated for 'Old
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

3 weeks agoada: Formal function default given by expression rejected with -gnatX
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.

3 weeks agoada: Reject pragma CPU and Priority that duplicate corresponding aspects
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.

3 weeks agoada: Reject exceptional contracts on No_Raise subprograms
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.

3 weeks agoada: Fix crash on declare expression in contract on access to subprogram type
Eric Botcazou [Tue, 20 Jan 2026 09:09:23 +0000 (10:09 +0100)] 
ada: Fix crash on declare expression in contract on access to subprogram type

As documented at the end of gen_il-gen-gen_entities.adb, E_Subprogram_Type
is part of Scope_Kind but, unlike what is said, it lacks Scope_Depth_Value.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (E_Subprogram_Type): Add the missing
Scope_Depth_Value field.

3 weeks agoada: Fix fallout of recent freezing change for expression functions
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.

3 weeks agoada: Spurious error on formals with First_Controlling_Parameter type
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.

3 weeks agoada: Unsupported C++ constructor call in array aggregate
Javier Miranda [Thu, 15 Jan 2026 20:49:28 +0000 (20:49 +0000)] 
ada: Unsupported C++ constructor call in array aggregate

This patch adds support for C++ constructor calls in array aggregates.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_N_Assignment_Statement): Handle internally
generated initialization invoking a C++ constructor.

3 weeks agoada: Fix early freezing of tagged type by expression function in nested package
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.

3 weeks agoada: Fix fallout of latest change to Analyze_Subprogram_Renaming
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.

3 weeks agoada: Small tweak to error message for premature freezing of deferred constant
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.

3 weeks agoada: Missing contract checks for calls to formal subprograms within instances
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.

3 weeks agoada: Fix Ghost => True/False for Abstract_State
Viljar Indus [Thu, 15 Jan 2026 08:41:59 +0000 (10:41 +0200)] 
ada: Fix Ghost => True/False for Abstract_State

Ensure that an Assertion_Level is assigned when Ghost => True is
used for Abstract_State.

Add an error if Ghost => False is used on an Abstract_State within
a ghost pacakage.

Add an error if the expression used for Ghost is not static.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Abstract_State): Improve handling of
True/False for Abstract_State with Ghost.

3 weeks agoada: Fix Initialize aspect for constructors
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.

3 weeks agoada: More tweaks to semantic analysis of expression functions
Eric Botcazou [Wed, 14 Jan 2026 17:01:54 +0000 (18:01 +0100)] 
ada: More tweaks to semantic analysis of expression functions

They are exclusively about streamlining the implementation, so there should
be no functional changes.

gcc/ada/ChangeLog:

* contracts.adb (Has_Public_Visibility_Of_Subprogram): Use Subp_Id
throughout and Is_Expression_Function to spot expression functions.
* ghost.adb (Is_OK_Declaration): Likewise.
* sem_ch12.adb (Analyze_One_Association): Likewise.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Likewise.
(Analyze_Subprogram_Specification): Fix typo.
(Find_Corresponding_Spec): Call Is_Expression_Function.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Retrieve the expression
by means of Expression_Of_Expression_Function.
* sem_res.adb (Resolve_Allocator): Call Is_Expression_Function.
(Rewrite_Renamed_Operator): Likewise.
* sem_util.adb (Expression_Of_Expression_Function): Streamline the
the implementation.
(Is_Expression_Function): Likewise.

3 weeks agoada: Fix incorrect finalization of renamed function call at library level
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.

3 weeks agoada: Handle call to C++ constructor in generic instantiation
Javier Miranda [Mon, 12 Jan 2026 13:48:04 +0000 (13:48 +0000)] 
ada: Handle call to C++ constructor in generic instantiation

Add missing support for C++ constructor call passed as a generic
formal subprogram parameter.

gcc/ada/ChangeLog:

* sem_ch3.adb (Analyze_Subtype_Declaration): Record subtypes
inherit the CPP_Class attribute; required for instantiations.

3 weeks agoada: Visibility bug in instance of generic with precondition on formal subprogram
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.

3 weeks agoada: Missing dynamic accessibility check assigning conditional expr to saooaaat.
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.

3 weeks agoada: Improve machinery for generating predicate check
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.

3 weeks agoada: Small tweaks to semantic analysis of expression functions
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.

3 weeks agoada: Fix endless loop on Address aspect for object with dynamic address
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.

3 weeks agoada: Handle call to C++ constructor placed in return statement
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.

3 weeks agoada: Small tweak to Analyze_Subprogram_Body_Helper
Eric Botcazou [Thu, 8 Jan 2026 10:40:38 +0000 (11:40 +0100)] 
ada: Small tweak to Analyze_Subprogram_Body_Helper

No functional changes.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Pull out the generic
case from the if-statement and put it first.

3 weeks agoada: Enable checks during analysis of expanded dispatching calls
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.

3 weeks agoada: Make "finally" a non-reserved keyword
Ronan Desplanques [Wed, 7 Jan 2026 11:43:36 +0000 (12:43 +0100)] 
ada: Make "finally" a non-reserved keyword

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.

3 weeks agoada: Crash with pragma Ignore_Pragma in SPARK mode
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.

3 weeks agoada: Extend the runtime GPR files for shared libs
Sebastian Poeplau [Fri, 14 Nov 2025 15:46:21 +0000 (16:46 +0100)] 
ada: Extend the runtime GPR files for shared libs

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.

3 weeks agoada: Support for implicit parameterless constructor
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.

3 weeks agoada: New aspects for use in CodePeer's taint analysis.
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.

3 weeks agoada: Tech debt: VAST-related cleanup of Save_Scan_State
Bob Duff [Tue, 6 Jan 2026 14:42:09 +0000 (09:42 -0500)] 
ada: Tech debt: VAST-related cleanup of Save_Scan_State

Minor cleanup; follow-on to previous change titled
"clean up miscellaneous VAST issues".

Use an aggregate in Save_Scan_State. This has the usual
advantage of an aggregate over a series of individual
assignments -- full coverage checking.

gcc/ada/ChangeLog:

* scans.adb (Save_Scan_State): Use an aggregate.

3 weeks agoada: Fix spurious range check for out mode scalars in class-wide preconditions
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.

3 weeks agoada: Refactor assignments in constructor prologue
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.

3 weeks agoada: Minor comment fixes
Eric Botcazou [Mon, 5 Jan 2026 06:56:07 +0000 (07:56 +0100)] 
ada: Minor comment fixes

This comprises a couple of typos and a small rewriting.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Minor comment fixes.