ada: Disable signals when calling pthread_create on QNX
The QNX Certified Products Defect Notification from February 2025
mentions a potential memory leak when pthread_create is interrupted by a
signal. It recommends to disable signals for this function call.
gcc/ada/ChangeLog:
* adaint.c: Add functions to disable and enable signals on QNX.
* libgnarl/s-taprop__qnx.adb (Create_Task): Disable
signals when calling pthread_create.
Gary Dismukes [Thu, 14 Aug 2025 20:29:20 +0000 (20:29 +0000)]
ada: Refine condition for reporting warnings on components with abstract equality
The initial implementation of the warning resulted in unwanted false
positives for types that have a user-defined equality function (in
which case abstract equality on components will typically not ever
be invoked). The conditions for reporting the warning are refined
by this change to exclude checking for presence of abstract component
equality functions in the case where the containing type has a user-defined
equality.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Op_Eq): Test for absence of user-defined
equality on type being compared (for both array and record types)
as a condition for checking for abstract equality on component
types. Add a "???" comment about current limitations on issuing
the new warning.
(Warn_On_Abstract_Equality_For_Component): Remove temporary disabling
of the warning. Improve comment on declaration.
This patch fixes a reference to an Ada RM clause, fixes an occurrence of
"unconstrained" that should have been "indefinite", and removes an
incorrect claim that completing a partial view without discriminants
with a full view with defaulted discriminants is an error situation.
Denis Mazzucato [Wed, 13 Aug 2025 15:14:35 +0000 (17:14 +0200)]
ada: Fix compile time evaluation needed for static unfoldings
Unfolding of static expressions is needed when evaluating static bounds, even in
the presence of strict analysis. Otherwise, we may wrongly identify static
predicates as dynamic ones, and thus require unnecessary "others" default case.
Denis Mazzucato [Tue, 12 Aug 2025 08:57:03 +0000 (10:57 +0200)]
ada: Better warning when single letter package conflicts with predefined unit naming
This patch improves the warning message when the actual file name of a child
package with a single letter parent isn't the expected one because it may
collide with a predefined unit name. The warning explain why in this specific
case the expected name is not the standard one using the minus to separate
parents with children.
Tucker Taft [Mon, 11 Aug 2025 21:33:52 +0000 (21:33 +0000)]
ada: Set Related_Expression on compiler-generated Valid_Scalars functions
When creating the local functions to implement the Valid_Scalars
attribute for array and record types, set a Related_Expression that
points to the original attribute reference (blah'Valid_Scalars).
This allows the Inspector to give a more user-friendly name
when these functions are called and they are known, for example,
to always return True.
gcc/ada/ChangeLog:
* exp_attr.adb
(Build_Array_VS_Func and Build_Record_VS_Func): Pass in the
Attr as the Related_Node parametr when calling
Make_Temporary for the Func_Id for the array and record
Valid_Scalars local functions.
ada: Improve documentation comment of Find_Type_Name
The meaning of the return value of Find_Type_Name depends greatly on
whether the declaration it's passed is a completion. This patch adds a
description of this to the documentation comment of Find_Type_Name.
Gary Dismukes [Tue, 12 Aug 2025 22:45:43 +0000 (22:45 +0000)]
ada: Disable new warning for composite equality ops that can raise Program_Error
The new warning is spuriously flagged on membership tests in
vss-xml-implementation-html_writer_data.adb, leading to the GNAT CB
failing, so we disable it until that issue can be resolved.
Robin Dapp [Tue, 9 Sep 2025 14:15:48 +0000 (16:15 +0200)]
ifcvt: Clarify if_info.original_cost.
Before noce_find_if_block processes a block it sets up an if_info
structure that holds the original costs. At that point the costs of
the then/else blocks have not been added so we only care about the
"if" cost.
The code originally used BRANCH_COST for that but was then changed
to COST_N_INSNS (2) - a compare and a jump.
This patch computes the jump costs via
insn_cost (if_info.jump, ...)
under the assumption that the target takes BRANCH_COST into account
when costing a jump instruction.
In noce_convert_multiple_sets we keep track of the need for the initial
CC comparison. If needed for the generated sequence we add its
cost in default_noce_conversion_profitable_p.
gcc/ChangeLog:
* ifcvt.cc (noce_convert_multiple_sets_1): Add use_cond_earliest
param.
(noce_convert_multiple_sets): Set use_cond_earliest.
(noce_process_if_block): Just use original cost.
(noce_find_if_block): Use insn_cost (jump_insn).
testsuite: Fix asm-hard-reg-error-{4,5}.c for non-LRA targets
Hard register constraints are only supported for LRA and not old reload.
Targets hppa, m68k, pdp11, rx, sh, vax do not default to LRA which is
why these tests fail there. Limit the tests to LRA targets, although,
this means that currently on these targets the tests are skipped by
default. Since the tests are about general logic, the extra coverage we
loose by skipping these targets is negligible.
For hppa, register 0 cannot be used as a general register. Therefore,
use temporary registers r20 and r21 instead. Likewise, for AVR use r20
and r24 instead.
gcc/testsuite/ChangeLog:
* gcc.dg/asm-hard-reg-error-4.c: Limit the test to LRA targets.
Use registers r20 and r21 for hppa. Likewise, for AVR use r20
and r24 instead.
* gcc.dg/asm-hard-reg-error-5.c: Ditto.
Kito Cheng [Thu, 14 Aug 2025 13:29:38 +0000 (21:29 +0800)]
RISC-V: Fix can_find_related_mode_p for VLS types
can_find_related_mode_p incorrectly handled VLS (Vector Length Specific)
types by using TARGET_MIN_VLEN directly, which is in bits, instead of
converting it to bytes as required.
This patch fixes the issue by dividing TARGET_MIN_VLEN by 8 to convert
from bits to bytes when calculating the number of units for VLS modes.
The fix enables proper vectorization for several test cases:
- zve32f-1.c: Now correctly finds vector mode for SF mode in foo3,
enabling vectorization of an additional loop.
- zve32f_zvl256b-1.c and zve32x_zvl256b-1.c: Added -mrvv-max-lmul=m2
option to handle V8SI[2] (vector array mode) requirements during
vectorizer analysis, which needs V16SI to pass, and V16SI was enabled
incorrectly before.
Changes since V4:
- Fix testsuite, also triaged why changed.
gcc/ChangeLog:
* config/riscv/riscv-selftests.cc (riscv_run_selftests): Call
run_vectorize_related_mode_selftests.
(test_vectorize_related_mode): New function to test
vectorize_related_mode behavior.
(run_vectorize_related_mode_selftests): New function to run all
vectorize_related_mode tests.
(run_vectorize_related_mode_vla_selftests): New function to test
VLA modes.
(run_vectorize_related_mode_vls_rv64gcv_selftests): New function to
test VLS modes on rv64gcv.
(run_vectorize_related_mode_vls_rv32gc_zve32x_zvl256b_selftests):
New function to test VLS modes on rv32gc_zve32x_zvl256b.
(run_vectorize_related_mode_vls_selftests): New function to run all
VLS mode tests.
* config/riscv/riscv-v.cc (can_find_related_mode_p): Fix VLS type
handling by converting TARGET_MIN_VLEN from bits to bytes.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/zve32f-1.c: Update expected
vectorization count from 2 to 3.
* gcc.target/riscv/rvv/autovec/zve32f_zvl256b-1.c: Add
-mrvv-max-lmul=m2 option.
* gcc.target/riscv/rvv/autovec/zve32x_zvl256b-1.c: Add
-mrvv-max-lmul=m2 option.
Jonathan Wakely [Fri, 5 Sep 2025 10:44:57 +0000 (11:44 +0100)]
libstdc++: Enforce Mandates: for Boyer-Moore searchers
C++17 has a 'Requires:' precondition that the two random access iterator
types have the same value type. In C++20 that is a 'Mandates:'
requirement which we must diagnose.
Although we could diagnose it in C++17, that might be a breaking change
for any users relying on it today. Also I am lazy and wanted to use
C++20's std::iter_value_t for the checks. So this only enforces the
requirement for C++20 and later.
Joseph Myers [Wed, 10 Sep 2025 20:48:05 +0000 (20:48 +0000)]
c: Add tests for some C2Y removals of undefined behavior
C2Y removes various instances of undefined behavior, typically making
them either constraint violations or implementation-defined.
In many but not all such cases, GCC's existing behavior is compatible
with the C2Y changes. For an initial batch of such cases, add
explicit tests for how GCC behaves in C2Y mode; more such cases will
need tests added in future patches, and there are also some such
changes that will need changes to how GCC behaves, not just new tests.
(Some of the individual examples in these tests may have been
constraint violations even before C2Y.)
Tested for x86_64-pc-linux-gnu.
* gcc.dg/c2y-function-qual-1.c, gcc.dg/c2y-incomplete-1.c,
gcc.dg/c2y-inline-1.c, gcc.dg/c2y-pointer-1.c,
gcc.dg/c2y-register-array-1.c, gcc.dg/c2y-storage-class-1.c,
gcc.dg/c2y-struct-empty-1.c: New tests.
There are at least two cases where tree-switch-conversion leads
to unpleasant resource allocation:
PR49857
The lookup table lives in RAM. This is the case for all
devices that locate .rodata in RAM, which is for almost
all AVR devices.
PR81540
Code is bloated for 64-bit inputs.
As far as PR49857 is concerned, a target hook that may add an
address-space qualifier to the lookup table is the obvious
solution, though a respective patch has always been rejected by
global maintainers for non-technical reasons.
Peter Bergner [Tue, 9 Sep 2025 19:43:28 +0000 (14:43 -0500)]
RISC-V: Fix typo in tt-ascalon-d8's pipeline description [PR121878]
PR121878 shows a typo in the tt-ascalon-d8's pipeline description that
leads to an ICE. The problem is that the vector define_insn_reservation
patterns test for scalar modes rather than vector modes, meaning the
insns don't get handled correctly. We could correct the modes, but given
we could have multiple VLEN values, the number of modes we'd have to check
can be large and mode iterators are not allowed in the mode attribute check.
Instead, I've removed the mode check and replaced it with a test of the
Selected Elenent Width (SEW).
2025-09-09 Peter Bergner <bergner@tenstorrent.com>
gcc/
PR target/121878
* config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_vec_idiv_half): Test the
Selected Element Width (SEW) rather than the mode.
(tt_ascalon_d8_vec_idiv_single): Likewise.
(tt_ascalon_d8_vec_idiv_double): Likewise.
(tt_ascalon_d8_vec_float_divsqrt_half): Likewise.
(tt_ascalon_d8_vec_float_divsqrt_single): Likewise.
(tt_ascalon_d8_vec_float_divsqrt_double): Likewise.
gcc/testsuite/
PR target/121878
* gcc.target/riscv/pr121878.c: New test.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
Eric Botcazou [Wed, 10 Sep 2025 13:00:59 +0000 (15:00 +0200)]
Fix -Wlto-type-mismatch warning during GNAT LTO build
The recent addition of Pragma_Unsigned_Base_Range to the enumeration type
Pragma_Id has made it exceed 256 enumeration values and thus overflow the
unsigned 8-bit type used for it on the C side. This should have stopped
the build, except that a glitch in the Snames machinery causes one value
to be dropped on the C side, leaving it at just 256 enumeration values.
This fixes both issues, i.e. ensures that the number of enumeration values
is the same on both sides and bumps the size of the C type to 16 bits.
gcc/ada/
PR ada/121885
* snames.ads-tmpl (Pragma_Id): Rename Unknown_Pragma to
Pragma_Unknown for the sake of XSnamesT.
* snames.adb-tmpl (Get_Pragma_Id): Adjust to above renaming.
* snames.h-tmpl (Attribute_Id): Change underlying type to Byte.
(Get_Attribute_Id): Use Byte as return value.
(Pragma_Id): Change underlying type to Word.
(Get_Pragma_Id): Use Word as return value.
* types.h (Word): New typedef.
* exp_prag.adb (Expand_N_Pragma): Remove useless comment.
* par-prag.adb (Prag): Adjust to above renaming.
* sem_prag.adb (Analyze_Pragma): Likewise.
(Sig_Flags): Likewise.
Martin Uecker [Mon, 28 Jul 2025 23:05:00 +0000 (01:05 +0200)]
c: Warn when returning nested functions that require a non-local context.
This patch adds a mechanism to keep track whether nested functions require
non-local context because they reference a variable of an enclosing
scope. This is used for extending the existing -Wreturn-address warning
to also warn for such nested functions. Certain exceptions are implemented
for functions that do not requite a non-local context, because they reference
only static variables, named constants, non-local variables in unevaluated
sizeof, typeof or countof operators, or typedef. The logic is based on the
existing infrastructure for determining use of undeclared static functions.
Finally, To make sure that no trampolines are generated even when not using
optimization, we mark the exempt functions with TREE_NO_TRAMPOLINE.
gcc/c/ChangeLog:
* c-tree.h: Add new macro C_DECL_NONLOCAL_CONTEXT and prototype
for mark_decl_used.
* c-typeck.cc (mark_decl_used): New function.
(function_to_pointer_conversion): Mark exempt functions.
(record_maybe_used_decl): Add `address' parameter.
(build_external_ref): Change to mark_decl_used.
(pop_maybe_used): Call mark_decl_used.
(c_mark_addressable): Ditto.
(c_finish_goto_label): Ditto.
(c_finish_return): Add warning.
* c-decl.cc (declspecs_add_type): Ditto.
(grokdeclarator): Don't set C_DECL_REGISTER on function
declarators.
gcc/testsuite/ChangeLog:
* gcc.dg/Wreturn-nested-1.c: New test.
* gcc.dg/Wreturn-nested-2.c: New test.
* gcc.dg/Wtrampolines-2.c: New test.
* gcc.dg/Wtrampolines-3.c: New test.
RISC-V: Add pattern for vector-scalar single widening floating-point sub
This pattern enables the combine pass (or late-combine, depending on the case)
to merge a float_extend'ed vec_duplicate into a minus RTL instruction. The other
minus operand is already wide.
Before this patch, we have four instructions, e.g.:
fcvt.d.s fa0,fa0
vsetvli a5,zero,e64,m1,ta,ma
vfmv.v.f v2,fa0
vfsub.vv v1,v1,v2
After, we get only one:
vfwsub.wf v1,v1,fa0
gcc/ChangeLog:
* config/riscv/autovec-opt.md (*vfwsub_wf_<mode>): New pattern to
combine float_extend + vec_duplicate + vfsub.vv into vfwsub.wf.
If the results include several configurations (schedule of
variations), do not report summary lines as duplicates. Indeed with
several configurations, it's likely that the results contain the same
# of expected passes XXXXX
The patch just keeps lines starting with test state prefix to avoid
this problem.
contrib/ChangeLog:
* compare_tests: Improve non-unique tests report when testing
several configurations.
c++: Fix null deref in maybe_diagnose_standard_trait [PR121859]
A static member template doesn't always have a DECL_INITIAL, as in the
below testcase, and so checking its TREE_CODE performs a null-pointer
dereference. I don't think we need to specially detect this case as
traits we care about are unlikely to be members, so this just adds the
missing null check.
PR c++/121859
gcc/cp/ChangeLog:
* constraint.cc (maybe_diagnose_standard_trait): Check if expr
is non-null.
libstdc++: Rename _S-prefixed identifiers in <mdspan>.
In libstdc++ the prefix _S is used for static members only. In <mdspan>
there's several type aliases that also used the prefix _S. They now use
a single leading underscore follow by a capital letter instead.
libstdc++-v3/ChangeLog:
* include/std/mdspan (_ExtentsStorage::_Base): New name for
_S_base.
(_ExtentsStorage::_Storage): New name for _S_storage.
(extents::_Storage): New name for _S_storage.
(layout_stride::mapping::_Strides): New name for
_S_stries_t.
* testsuite/23_containers/mdspan/class_mandate_neg.cc: Update
test to the new error message.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
The concept __integral_constant_like doesn't consider traits with a
boolean member `value` as an integer constant. This is done to reject
various completely unrelated traits like is_const, is_abstract, etc.
LWG4351 adjusts the check to strip references and cv qualifiers before
checking if `value` is bool. The immediate context is constant_wrapper
which defines:
Without LWG4351, std::cw<true> and std::cw<false> would both be
considered integer constants (by __integral_constant_like); but both
std::{true,false}_type are not considered integer constants. Hence,
LWG4351 removes inconsistent behaviour between std::integral_constant
and std::constant_wrapper.
libstdc++-v3/ChangeLog:
* include/std/span (__integral_constant_like): Use
remove_cvref_t before checking if _Tp::value is boolean.
* testsuite/23_containers/mdspan/extents/misc.cc: Update test.
* testsuite/23_containers/mdspan/mdspan.cc: Ditto.
* testsuite/23_containers/span/deduction.cc: Ditto.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Jakub Jelinek [Wed, 10 Sep 2025 10:39:11 +0000 (12:39 +0200)]
testsuite: Only scan for known file extensions in lto.exp
This is something that has bothered me for a few years but I've only found
time for it now.
The glob used for finding *_1.* etc. counterparts to the *_0.* tests is too
broad, so if one has say next to *_1.c file also *_1.c~ or *_1.c.~1~
or *_1.c.orig or *_1.c.bak etc. files, lto.exp will report a warning and the
test will fail.
So, e.g. in rpm build if some backported commit in patch form adds some
gcc/testsuite/*.dg/lto/ test and one uses -b option to patch, if one doesn't
remove the backup files, the test will fail.
Looking through all the *.dg/lto/ directories, I only see c, C, ii, f, f90
and d extensions used right now for the *_1.* files (and higher), while for
the *_0.* files also m, mm and f03 extensions are used.
So, the following patch only searches for those (plus for Fortran uses the
extensions searched by the gfortran.dg/lto/ driver, i.e. \[fF\]{,90,95,03,08}
, not just f, f90 and f03).
Tested on x86_64-linux and verified I got exactly the same number of
grep '^Executing.on.host.*_[1-9]\.' testsuite/*/*.log
before/after this patch when doing make check RUNTESTFLAGS=lto.exp
except for 2 new ones which were previously failed because I had backup
files for 2 tests.
2025-09-10 Jakub Jelinek <jakub@redhat.com>
* lib/lto.exp (lto-execute-1): Search for _1.* etc. files
only with a list of known extensions.
Jakub Jelinek [Wed, 10 Sep 2025 10:34:50 +0000 (12:34 +0200)]
bitint: Fix up lowering optimization of .*_OVERFLOW ifns [PR121828]
THe lowering of .{ADD,SUB,MUL}_OVERFLOW ifns is optimized, so that we don't
in the common cases uselessly don't create a large _Complex _BitInt
temporary with the first (real) part being the result and second (imag) part
just being a huge 0 or 1, although we still do that if it can't be done.
The optimizable_arith_overflow function checks when that is possible, like
whether the ifn result is used at most twice, once in REALPART_EXPR and once
in IMAGPART_EXPR in the same bb, etc. For IMAGPART_EXPR it then checks
if it has a single use which is a cast to some integral non-bitint type
(usually bool or int etc.). The final check is whether that cast stmt
appears after the REALPART_EXPR (the usual case), in that case it is
optimizable, otherwise it is not (because the lowering for optimizable
ifns of this kind is done at the location of the REALPART_EXPR and it
tweaks the IMAGPART_EXPR cast location at that point, so otherwise it
would be set after use.
Now, we also have an optimization for the REALPART_EXPR lhs being used
in a single stmt - store in the same bb, in that case we don't have to
store the real part result in a temporary but it can go directly into
memory.
Except that nothing checks for the IMAGPART_EXPR cast being before or after
the store in this case, so the following testcase ICEs because we have
a use before a def stmt.
In bar (the function handled right already before this patch) we have
_6 = .SUB_OVERFLOW (y_4(D), x_5(D));
_1 = REALPART_EXPR <_6>;
_2 = IMAGPART_EXPR <_6>;
a = _1;
_3 = (int) _2;
baz (_3);
before the lowering, so we can just store the limbs of the .SUB_OVERFLOW
into the limbs of a variable and while doing that compute the value we
eventually store into _3 instead of the former a = _1; stmt.
In foo we have
_5 = .SUB_OVERFLOW (y_3(D), x_4(D));
_1 = REALPART_EXPR <_5>;
_2 = IMAGPART_EXPR <_5>;
t_6 = (int) _2;
baz (t_6);
a = _1;
and we can't do that because the lowering would be at the a = _1; stmt
and would try to set t_6 to the overflow flag at that point. We don't
need to punt completely and mark _5 as _Complex _BitInt VAR_DECL though
in this case, all we need is not merge the a = _1; store with the
.SUB_OVERFLOW and REALPART_EXPR/IMAGPART_EXPR lowering. So, add _1
to m_names and lower the first 3 stmts at the _1 = REALPART_EXPR <_5>;
location, optimizable_arith_overflow returned non-zero and so the
cast after IMAGPART_EXPR was after it and then a = _1; will copy from
the temporary VAR_DECL to memory.
2025-09-10 Jakub Jelinek <jakub@redhat.com>
PR middle-end/121828
* gimple-lower-bitint.cc (gimple_lower_bitint): For REALPART_EXPR
consumed by store in the same bb and with REALPART_EXPR from
optimizable_arith_overflow, don't add REALPART_EXPR lhs to
the m_names bitmap only if the cast from IMAGPART_EXPR doesn't
appear in between the REALPART_EXPR and the store.
Jakub Jelinek [Wed, 10 Sep 2025 10:33:14 +0000 (12:33 +0200)]
expr: Handle RAW_DATA_CST in store_constructor [PR121831]
I thought this wouldn't be necessary because RAW_DATA_CST can only appear
inside of (array) CONSTRUCTORs within DECL_INITIAL of TREE_STATIC vars,
so there shouldn't be a need to expand it. Except that we have an
optimization when reading ARRAY_REF from such a CONSTRUCTOR which will
try to expand the constructor if it either can be stored by pieces
(I think that is just fine) or if it is mostly zeros (which is at least
75% of the initializer zeros). Now the second case is I think in some
cases desirable (say 256MB initializer and just 20 elements out of that
non-zero, so clear everything and store 20 elements must be fastest and
short), but could be really bad as well (say 40GB initializer with
10GB non-zero in it, especially if it doesn't result in the original
variable being optimized away). Maybe it would help if expand_constructor
and store_constructor* etc. had some optional argument with addresses into
the original VAR_DECL so that it could be copying larger amounts of data
like larger RAW_DATA_CSTs from there instead of pushing those into new
.rodata again. And another problem is that we apparently expand the
initializes twice, expand_constructor in store_constructor can expand
the stores one and if expand_constructor returns non-NULL, we then
expand_expr the CONSTRUCTOR again. to the same location.
This patch doesn't address either of those issues, just adds RAW_DATA_CST
support to store_constructor for now. For the can_store_by_pieces
cases it stores those by pieces using a new callback very similar to
string_cst_read_str, for the rest (unfortunately) forces it into a memory
and copies from there.
Tomasz Kamiński [Thu, 4 Sep 2025 11:58:23 +0000 (13:58 +0200)]
libstdc++: Use _Drop_iter<_CharT> for formattable concept checking [PR121765]
When producing output, the libstdc++ format implementation only uses _Sink_iter
specializations. Since users cannot construct basic_format_context, this is the
only iterator type actually used. The __format_padded helper relies on this
property to efficiently pad sequences from tuples and ranges.
However, the standard's formattable concept requires a generic format function
in formatters that works with any iterator type. This is intended to
future-proof the implementation by allowing new format_context types. Previously,
libstdc++ used back_insert_iterator<basic_string<_CharT>> for this purpose.
Normally, concept checks only instantiate function signatures, but with
user-defined formatters and deduced return types, the function body and all
called functions are instantiated. This could trigger a static assertion error
in the range/tuple formatter that assumed the iterator was a _Sink_iter
(see included test).
This patch resolves the issue by replacing the _Iter_for_t alias with the
internal _Drop_iter. This iterator's sematnics is to drop elements, so
__format_padded can handle it by simply returning the input iterator, which
still produces the required behavior [1].
An alternative of using _Sink_iter was considered but rejected because it would
allow formatters to pass formattable requirements while only supporting
format_context and wformat_context, which seems counter to the design intent
(the std/format/formatter/concept.cc fails).
[1] The standard's wording defines format functions as producing an output
representation, but does not explicitly require a formatter to be invoked
for each element. This allows the use of _Drop_iter to pass the concept check
without generating any output.
PR libstdc++/121765
libstdc++-v3/ChangeLog:
* include/std/format (__format::_Drop_iter): Define.
(_Iter_for_t::type): Change alias to _Drop_iter.
(__format::__format_padded): Return __fc.out() for
_Drop_iter.
* testsuite/std/format/pr121765.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Juergen Christ [Thu, 28 Aug 2025 13:48:31 +0000 (15:48 +0200)]
s390: Implement clz and ctz for SI mode
To properly implement __builtin_ffs for SI mode, implement clz and
(for >= z17) ctz for SI mode. Otherwise, gcc falls back to a libcall
which causes problems for Linux kernel code.
Also adjust the C?Z_DEFINED_VALUE_AT_ZERO macros to return 2. Since
the optabs now return exactly the value set by these macros, return
value 2 is more appropriate and leads to better code.
Jakub Jelinek [Wed, 10 Sep 2025 08:48:31 +0000 (10:48 +0200)]
c++: Change mangling of Intel/Motorola extended long double literals
On Fri, Sep 05, 2025 at 09:57:06PM +0200, Matthias Kretz wrote:
> > Hmm, would this fail for x86 long double, which is 80 bits? OK, just
> > checked. It's mangled as 12/16 bytes on i686/x86_64.
>
> It seems that Clang and GCC disagree on mangling 80-Bit long double:
>
> I like Clang's interpretation of https://itanium-cxx-abi.github.io/cxx-abi/
> abi.html#mangle.float better.
This patch changes the mangling of 80-bit long double literals from
24 or 32 digits (on m68k with padding bits in the middle, on x86
at the start) to just 20 hex digits.
2025-09-10 Jakub Jelinek <jakub@redhat.com>
* mangle.cc (write_real_cst): Mangle Intel/Motorola extended
80-bit formats using 20 hex digits instead of 24 or 32.
* g++.target/i386/mangle-ldbl-1.C: New test.
* g++.target/i386/mangle-ldbl-2.C: New test.
* g++.target/m68k/mangle-ldbl-1.C: New test.
* g++.target/m68k/mangle-ldbl-2.C: New test.
Because of a wrong define_insn for vec_extract_plus a vector access wasn't
combined with a preceeding plus operation which set the offset at which
to perform the vector access even though the instruction offers that capability.
I have double checked that implementation-defined behavior in the [compliance]
(whether the implementation is freestanding) and [stringbuf.const] (initialization
of sequence pointers) are indeed null, and there are no corresponding entires in
earlier standards.
libstdc++-v3/ChangeLog:
* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx2020.xml: Add more entires.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This patch fixes some issues with import handling.
The main functional change is to allow importing a module's interface
file into its implementation file indirectly. [module.import] p9
forbids an explicit 'import M;' declaration, but there's no provision
against having 'import X;' where module X itself imports M, so this
patch splits up the detection of circular imports to handle this better.
I also updated the errors to be closer to the standard wording.
A second issue I found while testing this is that we don't properly
handle name visibility when a partition implementation unit imports its
primary module interface (g++.dg/modules/part-10). This is resolved by
setting 'module_p' on the primary interface when it gets imported.
Solving this I incidentally removed the assertion that PR121808 was
failing on, which was never valid: we can enter import_module for a
module previously seen as a module-declaration if parsing bails before
declare_module is called. I experimented with guaranteeing that
declare_module always gets called for a module_state generated during
preprocessing if at all possible, but the resulting errors didn't seem a
lot better so I've left it as-is for now.
I did make a small adjustment so that a direct import of a module
doesn't overwrite the location of a module-declaration from earlier in
the file; this is important because preprocessing (and thus the
assigning of these locations) seems to happen for the whole file before
parsing begins, which can otherwise cause confusing locations referring
to later in the file than parsing would otherwise indicate.
PR c++/99682
PR c++/121808
gcc/cp/ChangeLog:
* module.cc (class module_state): Add comment to 'parent'.
(module_state::check_not_purview): Rename to...
(module_state::check_circular_import): ...this. Only handle
interface dependencies, adjust diagnostic message.
(module_state::read_imports): Use new function. Pass location
of import as from_loc instead of the module location.
(module_state::do_import): Set module_p when importing the
primary interface for the current module.
(import_module): Split out check for imports in own unit.
Remove incorrect assertion.
(preprocess_module): Don't overwrite module-decl location with
later import.
gcc/testsuite/ChangeLog:
* g++.dg/modules/circ-1_c.C: Adjust diagnostic.
* g++.dg/modules/mod-decl-1.C: Likewise.
* g++.dg/modules/mod-decl-2_b.C: Likewise.
* g++.dg/modules/pr99174.H: Likewise.
* g++.dg/modules/import-3_a.C: New test.
* g++.dg/modules/import-3_b.C: New test.
* g++.dg/modules/import-3_c.C: New test.
* g++.dg/modules/mod-decl-9.C: New test.
* g++.dg/modules/part-10_a.C: New test.
* g++.dg/modules/part-10_b.C: New test.
* g++.dg/modules/part-10_c.C: New test.
* g++.dg/modules/part-10_d.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
c++/modules: Create helper to get current TU's module_state
A lot of places use (*modules)[0] to refer to the module state for the
current TU. This is a bit awkward to type and not particularly clear
what it represents; make a helper function to clarify it.
Patrick Palka [Tue, 9 Sep 2025 18:39:57 +0000 (14:39 -0400)]
c++: non-dep cmp op rewritten from <=> returning int [PR121779]
Apparently an explicitly defined operator<=> isn't required to return
std::foo_ordering, so build_min_non_dep_op_overload needs to be able
to rebuild forms of (x <=> y) @ 0 where the @ resolved to a built-in and
in turn isn't expressed as a function call.
PR c++/121779
gcc/cp/ChangeLog:
* tree.cc (build_min_non_dep_op_overload): Handle comparison
operator expressions rewritten from a <=> that returns a
non-class type.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/operator-8.C: Remove outdated comment about
this test failing.
* g++.dg/lookup/operator-8a.C: New test.
Andrew Stubbs [Tue, 9 Sep 2025 13:48:16 +0000 (13:48 +0000)]
amdgcn: fix GFX10/GFX11 VGPR counts
The previous definition had all the GFX11 register counts doubled to fix a bug
that was encountered in early testing. This seems to have been a
misunderstanding of the problem (which is no longer reproducible).
gcc/ChangeLog:
* config/gcn/gcn-devices.def: Correct the Max ISA VGPRs counts for
GFX10 and GFX11 devices.
* config/gcn/gcn.cc (gcn_hsa_declare_function_name): Remove the wave64
VGPR count fudge.
Harald Anlauf [Mon, 8 Sep 2025 19:21:15 +0000 (21:21 +0200)]
Fortran: make STAT/LSTAT/FSTAT intrinsics generic [PR82480]
PR fortran/82480
gcc/fortran/ChangeLog:
* check.cc (error_unsupported_kind): Helper function to report an
unsupported kind of an argument.
(check_minrange4): Helper function to report if an integer variable
does not have a decimal range of at least four.
(gfc_check_fstat): Adjust checks for generalization of instrinsic
function FSTAT.
(gfc_check_fstat_sub): Likewise for subroutine FSTAT.
(gfc_check_stat): Likewise for functio STAT.
(gfc_check_stat_sub): Likewise for subroutine STAT.
* intrinsic.texi: Document generalized versions of intrinsics
STAT/LSTAT/FSTAT.
* iresolve.cc (gfc_resolve_stat): STAT function result shall have
the same kind as the VALUES argument.
(gfc_resolve_lstat): Likewise for LSTAT.
(gfc_resolve_fstat): Likewise for FSTAT.
(gfc_resolve_stat_sub): Resolve proper library subroutine for STAT.
(gfc_resolve_lstat_sub): Likewise for LSTAT.
* trans-decl.cc (gfc_build_intrinsic_function_decls): Declare
fndecls for required subroutines in runtine library.
* trans-intrinsic.cc (conv_intrinsic_fstat_lstat_stat_sub): Emit
runtime wrapper code for the library functions, taking care of
possible kind conversion of the optional STATUS argument of the
subroutine versions of the intrinsics.
(gfc_conv_intrinsic_subroutine): Use it.
* trans.h (GTY): Declare prototypes.
gcc/testsuite/ChangeLog:
* gfortran.dg/stat_3.f90: Extend argument checking.
* gfortran.dg/stat_4.f90: New test.
David Faust [Thu, 28 Aug 2025 16:12:55 +0000 (09:12 -0700)]
ctf: fix integer truncations in very large structs [PR121411]
DWARF to CTF translation for type bit sizes was using uint32_t, and for
member offsets was inadvertently using unsigned int via get_AT_unsigned.
For very large struct types, at least one of these could be truncated
causing incorrect encoding of the struct type and member offsets.
Use HOST_WIDE_INT to avoid these truncation issues and fix the encoding
for large structs.
PR debug/121411
gcc/
* dwarf2ctf.cc (ctf_get_AT_data_member_location) Use AT_unsigned
when fetching AT_bit_offset and AT_data_member_location. Simplify.
(ctf_die_bitsize): Return unsigned HOST_WIDE_INT instead of
uint32_t.
(gen_ctf_base_type, gen_ctf_sou_type, gen_ctf_enumeration_type):
Adapt accordingly.
RISC-V: Add pattern for vector-scalar dual widening floating-point sub
This pattern enables the combine pass (or late-combine, depending on the case)
to merge a float_extend'ed vec_duplicate into a minus RTL instruction. Both
minus operands are widened.
Before this patch, we have six instructions, e.g.:
fcvt.d.s fa0,fa0
vsetvli a5,zero,e64,m1,ta,ma
vfmv.v.f v3,fa0
vfwcvt.f.f.v v1,v2
vsetvli zero,zero,e64,m1,ta,ma
vfsub.vv v1,v1,v3
After, we get only one:
vfwsub.vf v1,v2,fa0
gcc/ChangeLog:
* config/riscv/autovec-opt.md (*vfwsub_vf_<mode>): New pattern to
combine float_extend + vec_duplicate + vfwsub.vv into vfwsub.vf.
Jakub Jelinek [Tue, 9 Sep 2025 14:44:48 +0000 (16:44 +0200)]
c, c++: Allow &__real__ static_var in constant expressions [PR121678]
When looking at constexpr references, I've noticed staticp handles
COMPONENT_REFs and ARRAY_REFs (the latter if the index is INTEGER_CST),
but not {REAL,IMAG}PART_EXPR. I think that is incorrect and causes
rejection of constexpr (for C++) or static const (for C) addresses
of __real__ or __imag__ parts of static vars.
2025-09-09 Jakub Jelinek <jakub@redhat.com>
PR c++/121678
* tree.cc (staticp): Handle REALPART_EXPR and IMAGPART_EXPR.
* g++.dg/ext/pr121678.C: New test.
* gcc.dg/pr121678.c: New test.
Jonathan Wakely [Tue, 9 Sep 2025 12:57:54 +0000 (13:57 +0100)]
libstdc++: Rename _CwFixedValue::_S_type member
Rename _S_type to __type as it's not a static member.
Also rename _Tp to _Xv because it's not a type.
libstdc++-v3/ChangeLog:
* include/std/type_traits (_CwFixedValue::_S_type): Rename to
__type.
(constant_wrapper): Rename template parameter in declaration to
match later definition.
RISC-V: Add pattern for vector-scalar single widening floating-point add
This pattern enables the combine pass (or late-combine, depending on the case)
to merge a float_extend'ed vec_duplicate into a plus RTL instruction. The other
plus operand is already wide.
Before this patch, we have four instructions, e.g.:
fcvt.d.s fa0,fa0
vsetvli a5,zero,e64,m1,ta,ma
vfmv.v.f v2,fa0
vfadd.vv v1,v1,v2
After, we get only one:
vfwadd.wf v1,v1,fa0
gcc/ChangeLog:
* config/riscv/autovec-opt.md (*vfwadd_wf_<mode>): New pattern to
combine float_extend + vec_duplicate + vfadd.vv into vfwadd.wf.
* config/riscv/vector.md
(@pred_single_widen_<plus_minus:optab><mode>_scalar): Swap and reorder
operands to match the RTL emitted by expand.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: Add vfwadd.wf.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_binop.h: Add support for single
widening variants.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_binop_widen_run.h: Add support
for single widening variants.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwadd-run-2-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwadd-run-2-f32.c: New test.
Gary Dismukes [Tue, 12 Aug 2025 00:26:07 +0000 (00:26 +0000)]
ada: Warning for composite equality that calls an abstract equality function
When equality is tested for a composite type that has any record
components whose type has an abstract equality function that will
be called as part of the enclosing type's equality, Program_Error
will be raised. We now issue a warning on the equality test,
mentioning the component type whose abstract equality function
will trigger the exception. Note that this is currently only
done for top-level components of the composite type. Another
limitation is that the warning is not issued when the outer
composite type is tagged.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Op_Eq): Check for warning about call to
the abstract equality function of a component type, for both array
and record enclosing types.
(Warn_On_Abstract_Equality_For_Component): New procedure to issue
a warning when an abstract equality function of a component type
will be called and result in Program_Error.
ada: Fix spurious warning for procedure named "Continue"
The recent addition of a language extension for the "continue"
nonreserved keyword caused spurious warnings about unreferenced
subprograms for procedures named "Continue", because the call
statements that are generated when identifiers are determined not to
refer to the keyword were considered to come from expansion.
This patch fixes this by marking those generated calls as coming from
source instead.
gcc/ada/ChangeLog:
* sem_ch5.adb (Make_Call): Mark generated nodes as coming from source.
Viljar Indus [Mon, 11 Aug 2025 12:01:34 +0000 (15:01 +0300)]
ada: Ignore Ghost policy checks for some pragmas
Some pragmas where the ghostness is based on the argument of
the pragma triggered ghost policy errors because we had not marked
the pragmas as ghost. However we could only do so once the argument
of the pragma was analyzed.
We can safely ignore the policy checks for those pragmas since
if the argument was ghost then the pragma also had to be ghost.
Marking the pragma afterwards as ghost is only for the cleanup of
ignored ghost purposes.
gcc/ada/ChangeLog:
* ghost.adb (Is_OK_Pragma): Use the
Suppressed_Ghost_Policy_Check_Pragma list for ignoring certain
pragmas.
* sem_prag.ads (Suppressed_Ghost_Policy_Check_Pragma): New variable
to store the pragmas that could be ignored when checking for
consitant ghost policy.
Tonu Naks [Tue, 5 Aug 2025 11:35:02 +0000 (11:35 +0000)]
ada: Platform-specific import for read() and write()
read() and write() return int on windows, whereas
on Posix systems the return type is ssize_t (effectively long_int).
The object file was added to GNAT_ADA_OBJS only, although the unit is also
in the compilation closure of GNATbind, but this was harmless because the
object file was essentially empty; that is no longer the case.
gcc/ada/ChangeLog:
* libgnat/s-crtl.ads (read, write): remove import
* libgnat/s-crtl__mingw.adb: body for windows
* libgnat/s-crtl.adb: body for all the other targets
* Makefile.rtl: configure s-crtl.adb/libgnat/s-crtl__mingw.adb
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Alphabetize.
(GNATBIND_OBJS): Add ada/libgnat/s-crtl.o.
Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
Viljar Indus [Wed, 6 Aug 2025 11:53:05 +0000 (14:53 +0300)]
ada: Update the uses of Is_Ignored*_In_Codegen
Replace calls to Is_Ignored_Ghost_Entity and
Predicates_Ignored with their In_Codegen versions in places where
we would analyze those nodes differently from checked nodes.
Describe the motive and use cases for those In_Codegen functions.
gcc/ada/ChangeLog:
* contracts.adb: Use the In_Codegen function instead.
* exp_ch3.adb: Likewise.
* exp_ch5.adb: Likewise.
* exp_ch6.adb: Likewise.
* exp_ch7.adb: Likewise.
* exp_ch9.adb: Likewise.
* exp_disp.adb: Likewise.
* exp_util.adb: Likewise.
* freeze.adb: Likewise.
* ghost.adb: Likewise.
* inline.adb: Likewise.
* repinfo.adb: Likewise.
* sem_ch10.adb: Likewise.
* sem_ch13.adb: Likewise.
* sem_ch3.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_elab.adb: Likewise.
* sem_res.adb: Likewise.
* sem_util.adb (Predicates_Ignored_In_Codegen): Add new function for
the Predicates_Ignored property.
(Predicates_Enabled): Use Predicates_Ignored_In_Codegen instead.
* sem_util.ads (Predicates_Ignored_In_Codegen): New function.
(Is_Ignored_In_Codegen): Add documentation on how _In_Codegen
functions should be used.
This patch replaces usages of "attribute" with the more appropriate
"field" when referring to Gen_IL fields, to avoid confusion with Ada's
concept of attributes.
This patch also makes comments more explicit about Gen_IL IDs and slots
around a call to the low-level Atree.Exchange_Entities, and makes a few
other minor comment changes.
Javier Miranda [Thu, 7 Aug 2025 09:42:15 +0000 (09:42 +0000)]
ada: Spurious error on generalized prefix notation
The compiler reports a spurious error when a primitive function of
an untagged type that returns an array type is invoked using the
prefix notation, and the sources are compiled with language
extensions enabled.
gcc/ada/ChangeLog:
* sem_util.adb (Needs_One_Actual): Add support for untagged record
types when the sources are compiled with Core Extensions allowed.
The comment this patch changes was made incorrect by the possibility of
completing an incomplete view with a private type declaration in Ada
2012. To avoid any possible confusion, this patch brings the comment up
to date.
Calling Check_Nonoverridable_Aspects only makes sense when the full type
declaration being analyzed is the completion of a partial view, and the
one call site of this procedure ensures this. Therefore the handling of
all the possible cases of completion in the procedure that this patch
removes was useless.
gcc/ada/ChangeLog:
* sem_ch3.adb (Check_Nonoverridable_Aspects): Remove if statement.
Javier Miranda [Thu, 7 Aug 2025 11:26:41 +0000 (11:26 +0000)]
ada: Adding support to defer the addition of extra formals (part 2)
Adjust previous patch to improve the support for AI05-0151-1/08.
gcc/ada/ChangeLog:
* exp_attr.adb (Rewrite_Attribute_Proc_Call): Add new parameter
to calls to Create_Extra_Formals.
(Expand_N_Attribute_Reference): Ditto.
* exp_ch3.adb (Expand_Freeze_Record_Type): Ditto.
* exp_ch6.adb (Expand_Call_Helper): Ditto.
* exp_disp.adb (Expand_Dispatching_Call): Ditto.
* freeze.adb (Check_Itype): Ditto.
(Freeze_Expression): Ditto.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Ditto.
(Create_Extra_Formals): Add new formal, and use it to determine
if the creation of the extra formals can be deferred. Add the
new parameter to calls to Create_Extra_Formals.
(Is_Unsupported_Extra_Actuals_Call): Adjust the code to improve
its performance when the result is known.
(Is_Unsupported_Extra_Formals_Entity): Ditto. Add new formal
* sem_ch6.ads (Create_Extra_Formals): Add new formal.
(Is_Unsupported_Extra_Formals_Entity): Ditto.
Viljar Indus [Tue, 5 Aug 2025 13:16:04 +0000 (16:16 +0300)]
ada: Improve error message in the case of missing indices
When both a missing index and an out of bounds error are present then
we should also mention the error on out of bounds index as it suggests
removing the index that is out of bounds rather than suggesting adding
indices that are also out of bounds.
gcc/ada/ChangeLog:
* sem_aggr.adb (Resolve_Array_Aggregate): Indicate an out of
bounds index error also in the case of a missing index.
Viljar Indus [Tue, 5 Aug 2025 09:04:18 +0000 (12:04 +0300)]
ada: Create a pragma to emit a misplaced Storage_Size aspect error
We do not emit an error on misplaced Strorage_Size error when
the aspect is not applied to a task (or an access type). We
instead create an attribute definition which is ignored most of the
time. Create a temporary pragma for the aspect specification to
emit the same misplaced aspect error as we do for pragmas.
gcc/ada/ChangeLog:
* sem_ch13.adb (Analyze_Aspect_Definitions): Create a temporary
pragma for the non-task and access type cases.
Viljar Indus [Fri, 1 Aug 2025 10:20:38 +0000 (13:20 +0300)]
ada: Avoid marking a ghost pragma twice
Previously all assertion level pragmas were marked based on the
current scope. Additionally some pragmas were marked afterwards
based on the relevant entity e.g. Pre. This would lead to cases
where a pragma was marked as both ignored and checked ghost pragma.
Each pragma should get marked only once based on their individual
semantics.
gcc/ada/ChangeLog:
* sem_prag.adb (Analyze_Pragma): Set Mark_Ghost_Code individually
based on the semantics of each pragma.
Viljar Indus [Fri, 1 Aug 2025 06:06:29 +0000 (09:06 +0300)]
ada: Fix ghost policy change detection for procedure calls
gcc/ada/ChangeLog:
* ghost.adb (Check_Ghost_Policy): Use the policy in affect for
the identifier at the current moment instead of the region
around it when checking a policy change for a procedure call.
Declarations should take the ghost policy from the region if
they do not have an explicit ghost aspect/pragam themselves.
gcc/ada/ChangeLog:
* ghost.adb (Mark_And_Set_Ghost_Declaration): apply the
ghost policy and level from the declaration only if the declaration
has an explicit ghost aspect/pragma.
Denis Mazzucato [Fri, 20 Jun 2025 15:10:05 +0000 (17:10 +0200)]
ada: Fix inheritance of Is_Primitive and legality check for nonoverridable aspects
This patch fixes the identification of inherited subprograms as primitive
operations via the Is_Primitive flag. This is essential in the context of the
new legality check which makes sure that, if any subprogram denoted by a
nonoverridable aspect of a type T with formal or return of either type T or
access T, then all denoted subprograms should be primitive operations. Note
that all valid interpretations of a subprogram are denoted by the aspect under
evaluation, all of these needs to be primitive then.
This is a respin of eng/toolchain/gnat!2039
gcc/ada/ChangeLog:
* sem_ch13.adb (Check_Nonoverridable_Aspect_Subprograms): Add the new
legality check in Check_Nonoverridable_Aspect_Subprograms for
nonoverridable aspects to check whether the denoted subprograms satisfy
MR 13.1.1(18.4/6), otherwise we emit an error. Fix spacing.
* sem_ch6.adb (New_Overloaded_Entity): Set Is_Primitive flag
for inherited primitives, and filter out homonym candidates without a
function specification as parents.
Piotr Trojanek [Thu, 31 Jul 2025 15:07:48 +0000 (17:07 +0200)]
ada: Reject pragma Attach_Handler on procedures in protected bodies
Pragma Attach_Handler and Interrupt_Handler are only legal for procedures
declared in protected definition. When given for procedures declared in
protected body, they were wrongly accepted and triggered an odd error message
from expansion.
gcc/ada/ChangeLog:
* sem_prag.adb (Check_Interrupt_Or_Attach_Handler): Refine test for
protected procedures; fix typo in comment.
Unsuccessful preanalyze_and_resolve still marks identifiers as Any_Id.
Override that result if an identifier matched an assertion level.
gcc/ada/ChangeLog:
* ghost.adb (Assertion_Level_From_Arg): Ensure that assertion level
is stored as the entity for its reference.
(Enables_Ghostness): Derive the result from whether or not the
an argument indicated an assertion level.
* tbuild.adb (Make_Assertion_Level): ensure that assertion levels
have a standard scope.
ada: Add special handling for Runtime and Static in Policy_In_Effect
When one of those levels is present then we should not look
for the policy in the policy stack but rather determine the
policy immidiately like we do in Check_Applicable_Policy.
gcc/ada/ChangeLog:
* sem_util.adb (Policy_In_Effect): Add special handling
for Runtime and Static values.
ada: Fix crash with global No_Tasking and async delays
When optimizations are enabled, the runtime for delays is inlined and expanded.
If No_Tasking is set globally, for instance via a configuration file, then the
initialization of _Master, _Chain, and _Task_Name formals is skipped for task
entities. Later during expansion, these identifiers are expected but won't be
found, crashing the compiler. This patch fixes Init_Formals by removing the
check on Global_No_Tasking. If a No_Tasking restriction applies, then a
violation error will be raised when analyzing the task type.
gcc/ada/ChangeLog:
* exp_ch3.adb (Init_Formals): Remove the check on Global_No_Tasking.
* sem.adb: Fix typo.
Gary Dismukes [Fri, 25 Jul 2025 20:56:32 +0000 (20:56 +0000)]
ada: Compiler crash on container aggregate with constant element choice
The compiler fails when compiling a container aggregate with
an element association with a key choice that denotes a constant
object. The code for getting the value of the choice was only
accounting for the possibility of integer and enumeration literals,
and is corrected to handle static expressions generally.
gcc/ada/ChangeLog:
* exp_aggr.adb (Build_Container_Aggr_Code.To_Int): Replace existing
conditional expression with call to Expr_Value.
To standardize the comparisson between the levels of ghost
entities and levels of assertion pragmasTo standardize the comparisson
between the levels of ghost
entities and levels of assertion pragmas.
ada: exp_ch6.adb: perform less checks in CodePeer_Mode
As explained in the comments, the CodePeer_Mode AST isn't well-formed
for a GCC back-end, but is fine for a CodePeer one. The checks ensuring
that the AST is well-formed thus need to be disabled.
Javier Miranda [Mon, 7 Jul 2025 18:16:52 +0000 (18:16 +0000)]
ada: Unsigned_Base_Range aspect
This patch adds support for a new GNAT aspect/pragma for integer
type definitions to explicitly enforce the use of an unsigned
base type.
gcc/ada/ChangeLog:
* aspects.ads (Aspect_Unsigned_Base_Range): New aspect.
* checks.adb (Determine_Range): Handle types with unsigned base range aspect.
(Enable_Overflow_Check): ditto
(Apply_Arithmetic_Overflow_Strict): ditto
* debug.adb (d_o): Document new usage.
* einfo.ads (Has_Unsigned_Base_Range_Aspect): New flag.
* exp_attr.adb (Expand_N_Attribute_Reference): No action since
it has been already handled at this stage.
* exp_ch4.adb (Expand_N_Op_Add): Generate aritmetic overflow check on
unsigned base range type operands.
(Expand_N_Op_Subtract): ditto
(Expand_N_Op_Multiply): ditto
(Expand_N_Op_Minus): ditto
* gen_il-fields.ads (Has_Unsigned_Base_Range_Aspect): New flag.
* gen_il-gen-gen_entities.adb (Has_Unsigned_Base_Range_Aspect): New flag.
* gen_il-internals.adb (Has_Unsigned_Base_Range_Aspect): New flag.
* gnat1drv.adb (Adjust_Global_Switches): Handle -gnatd_o
* par-prag.adb (Pragma_Unsigned_Base_Range): No action since it will
be entirely handled by the semantic analyzer.
* rtsfind.ads (RE_Id): Add RE_Uns_[Add|Subtract|Multiply]_With_ Ovflo_Check
* sem_attr.ads (Attribute_Unsigned_Base_Range): Added to the set of
implementation defined attributes.
* sem_attr.adb (Analyze_Attribute): Analyze attribute Unsigned_Base_Range.
(Eval_Attribute): Evaluate attribute Unsigned_Base_Range.
* sem_ch13.adb (Analyze_One_Aspect): Defer checks for this aspect to
the analysis of the corresponding pragma.
* sem_ch3.ads (Unsigned_Base_Range_Type_Declaration): New subprogram.
* sem_ch3.adb (Build_Derived_Numeric_Type): Inherit flag
Has_Unsigned_Base_Range_Aspect.
(Unsigned_Base_Range_Type_Declaration): New subprogram.
(Has_Pragma_Unsigned_Base_Range): New subprogram.
* sem_prag.adb (Analyze_Pragma): Handle Pragma_Unsigned_Base_Range.
* snames.adb-tmpl (Get_Pragma_Id): Handle Name_Unsigned_Base_Range.
(Is_Pragma_Name): ditto.
* snames.ads-tmpl (Name_Unsigned_Base_Range): New name.
(Attribute_Unsigned_Base_Range): New attribute.
(Pragma_Unsigned_Base_Range): New pragma.
* libgnat/s-aridou.ads (Add_With_Ovflo_Check): New routine for Double_Uns.
(Subtract_With_Ovflo_Check): ditto.
(Multiply_With_Ovflo_Check): ditto.
* libgnat/s-aridou.adb (Add_With_Ovflo_Check): ditto.
(Subtract_With_Ovflo_Check): ditto.
(Multiply_With_Ovflo_Check): ditto.
* libgnat/s-arit64.ads (Uns_Add_With_Ovflo_Check64): New subprogram.
(Uns_Subtract_With_Ovflo_Check64): ditto.
(Uns_Multiply_With_Ovflo_Check64): ditto.
* libgnat/s-arit64.adb (Uns_Add_With_Ovflo_Check64): New subprogram.
(Uns_Subtract_With_Ovflo_Check64): ditto.
(Uns_Multiply_With_Ovflo_Check64): ditto.
* libgnat/s-arit128.ads (Uns_Add_With_Ovflo_Check128): New subprogram.
(Uns_Subtract_With_Ovflo_Check128): ditto.
(Uns_Multiply_With_Ovflo_Check128): ditto.
* libgnat/s-arit128.adb (Uns_Add_With_Ovflo_Check128): New subprogram.
(Uns_Subtract_With_Ovflo_Check128): ditto.
(Uns_Multiply_With_Ovflo_Check128): ditto.
* doc/gnat_rm/gnat_language_extensions.rst: Document unsigned
base range.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
Viljar Indus [Wed, 5 Mar 2025 09:18:20 +0000 (11:18 +0200)]
ada: Multiple levels of ghost code
Adds support for the new language feature that allows ghost enties and
assertion pragmas and aspects to be associated with a new entity called
assertion level.
Added support for a new pragma Assertion_Level that declares new
assertion levels. This pragma consists of the level name and assertion
levels it depends on.
There are two special assertion levels that are considered to be
declared in the Standard package that have unique properties.
Assertion level Runtime is always considered to be Checked. Its
assertion policy cannot be changed and it is considered that all other
assertion levels depend on this level.
Assertion level Static is always considered to be Ignored. Its assertion
policy cannot be changed. All assertion levels that depend on this
level can also never be activated.
Aspect Ghost now supports the assertion level as a possible argument:
... with Ghost => Level;
All pragmas and aspects which were considered to be valid assertion
kinds for pragma Assertion_Policy now support assertion level
associations. The association consists of an assertion level and a set
of existing arguments. Note that you can have multiple assertion level
associations in a given pragma or aspect. e.g.
Since now ghost regions can contain other ghost regions with a different
assertion policy then new rules needed to be added for those situations
to ensure valid compilation.
Additionally all rules where we checked for compatible assertion
policies have an additional check for a compatible assertion level dependencies.
Ghost entities A and B are considered assertion level dependent when
* A or B does not have an associated assertion level.
* Both A and B have an assertion level and either
* the level of A is or depends on the level of B.
* the level of B cannot be enabled (is or depends on Static)
gcc/ada/ChangeLog:
* atree.adb (Mark_New_Ghost_Node): Store the assertion level on the
entity.
* contracts.adb (Analyze_Package_Contract): Add support for multiple
pragma Initial_Condition orginating from multiple assertion levels.
* cstand.adb (Make_Assertion_Level_Definition): New function that
creates a new Assertion_Level and adds it to the Assertion_Levels
table.
(Create_Standard): Add definitions for assertion levels defined in
Standard.
(Print_Standard): Add assertion level pragmas do the output.
* exp_ch6.adb (Check_Subprogram_Variant): Add support for multiple
Subprogram_Variant pragmas created by assertion levels.
* einfo.ads: add info for the new nodes and attributes.
* exp_prag.adb (Consequence_Error): Fix error message string
corruption caused by another call to the internal strings during
the call to Make_Procedure_Call_Statement.
(Expand_Pragma_Initial_Condition): Ensure all ghost related
attributes are copied to the new pragma.
(Expand_Pragma_Loop_Variant): Likewise.
(Expand_Pragma_Subprogram_Variant). Likewise. Additionally
create a new Subprogram_Variant function for each pragma associated
with an assertion level.
* exp_util.adb (Add_DIC_Check): Ensure all ghost related attributes
are copied to the new pragma.
(Build_DIC_Procedure_Body): Add support for mutliple DIC pragmas
created from assertion levels.
* gen_il-fields.ads:
(Aspect_Ghost_Assertion_Level): New field.
(Original_Aspect): New field.
(Original_Pragma): New field.
(Pragma_Ghost_Assertion_Level): New field.
(Child_Levels): New field.
(Ghost_Assertion_Level): New field.
(Parent_Levels): New field.
* gen_il-gen-gen_entities.adb:
Add Ghost_Assertion_Level field for all entities
Add new E_Assertion_Level entity for storing assertion levels.
* gen_il-gen-gen_nodes.adb:
Add Aspect_Ghost_Assertion_Level for N_Aspect to store the
assertion level associated with the aspect.
Add Original_Aspect to store the original aspect where the aspect
that was transformed from an aspect with an assertion level
origninated from.
Add Pragma_Ghost_Assertion_Level and Original_Pragma to store
the same information for N_Prama nodes.
* gen_il-types.ads: Add new entity kind E_Assertion_Level
* ghost.adb (Assertion_Level_Error_Msg): Create constant for
error messages using the same main error message.
(Ghost_Policy_Error_Msg): Likewise.
(Assertion_Level_To_Name): New subprogram.
(Check_Valid_Ghost_Declaration): New subprogram.
(Get_Ghost_Aspect): New subprogram.
(Get_Ghost_Assertion_Level): New subprogram.
(Ghost_Policy_In_Effect): New subprogram.
(Install_Ghost_Region): New subprogram.
(Mark_And_Set_Ghost_Region): New subprogram.
(Mark_Ghost_Declaration_Or_Body): Add new argument for assertion
levels.
(Check_Ghost_Completion): Update ghost policy calculation with
assertion levels. Refactor error message.
(Is_OK_Statement): Add new checks for valid assertion policies and
assertion levels.
(Is_OK_Pragma): Refactor the calculation of valid ghost pragmas.
(Check_Ghost_Policy): Make the checks ghost region based.
(Check_Ghost_Context): Refactor the order of checks.
(Check_Ghost_Formal_Procedure_Or_Package): Relax the checks for
overriding procedures. Now only ignored subprograms cannot be
overridden by checked or non-ghost subprograms.
(Check_Ghost_Primitive): Relax conditions for primitve operations.
Now only checked primitive subprograms are considered invalid for
ignored tagged types. Add assertion level compatibility checks.
(Check_Ghost_Refinement): Relax conditions for ghost refinements.
Add assertion level compatibility checks for refinements.
(Install_Ghost_Region): Store the current region and the assertion
for that region in the ghost config.
(Enables_Ghostness): Refactor implementation to support assertion
levels.
(Is_Subject_To_Ghost): Simplify implementation.
(Mark_And_Set_Ghost_Assignment): Refactor implementation.
(Mark_And_Set_Ghost_Body): Add support for assertion levels.
(Mark_And_Set_Ghost_Completion): Likewise.
(Mark_And_Set_Ghost_Declaration): Likwise.
(Mark_And_Set_Ghost_Instantiation): Likwise.
(Mark_And_Set_Ghost_Procedure_Call): Refactor implementation.
(Mark_Ghost_Declaration_Or_Body): Add support for assertion levels.
(Set_Ghost_Mode): Likwise.
* ghost.ads (Assertion_Level_From_Arg): New subprogram.
(Install_Ghost_Region): Add argument Level for assertrion levels.
(Is_Assertion_Level_Dependent): New subprogram.
* lib-xref.ads: Add new mapping for E_Assertion_Level entities.
* opt.ads (Ghost_Config_Type): Add new members Ghost_Assertion_Mode
and Current_Region to the structure.
* par-prag.adb (Prag): Add new pragma name Assertion_Level.
* rtsfind.adb (Load_RTU): Update the arguments for the call to
Install_Ghost_Region.
* sem.adb (Do_Analyze): Likewise.
* sem_ch13.adb (Convert_Aspect_With_Assertion_Levels): New
subprogram.
(Make_Aitem_Pragma): Copy ghost mode attributes from the aspect to
the pragma.
(Analyze_Aspect_Specifications): Convert aspects that have an
assertion level association in the aspects without the association
and the original supported syntax and with the assertion level
stored on the aspect node.
Updated duplicate detection to avoid duplicates being called on
aspects with assertion levels that orginated from the same aspect.
* sem_prag.adb (Apply_Check_Policy): New subprogram.
(Get_Applicable_Policy): New subprogram.
(Mark_Is_Checked): New subprogram.
(Mark_Is_Disabled): New subprogram.
(Mark_Is_Ignored): New subprgram.
(Check_Arg_Is_One_Of): Remove versions that had a specific number
of arguments and replace them with a list one.
(Create_Pragma_Without_Assertion_Level): New subprogram.
(Assertion_Level_Pragma_Comes_From_Source): New subprogram.
(Analyze_Pragma): Replace aspects that have an assertion level
with aspects without them where the level is stored on the pragma
node.
(Abstract_State): Add support for assertion levels in ghost
Abstract_State pragmas.
(Assert): Update argument handling for Assert like pragmas.
(Assertion_Level): Add a new section to support the analysis of
pragma Assertion_Level.
(Assertion_Policy): Add support for setting the policy for assertion
levels.
(Check): Update argument handling. Update the assertion policy
application process.
(Check_Policy): Add support for assertion levels. Add check_policy
pragmas for assertion_level dependencis also to the stack of
known Check_Policy pragmas.
(Default_Initial_Condition): Reject the use of DIC with assertion
levels. Update duplication checks.
(Ghost): Add support for assertion levels. Fix issue where
assertion levels with Ghost => False were treated as ghost.
(Predicate): Update the policy handling of Ghost_Predicate.
(Analyze_Refined_State_In_Decl_Part): Create a new ghost region
for analyzing Refined_State.
(Check_Applicable_Policy): Refactor the implementation. Break it
down to Get_Applicable_Policy and Apply_Check_Policy.
(Check_Kind): Removed. Replaced by Get_Applicable_Policy and
Apply_Check_Policy.
(Initialize): Initialize the table storing all know assertion
levels.
* sem_prag.ads (Find_Assertion_Level): New subprogram.
(Insert_Assertion_Level): New subprogram.
(Check_Applicable_Policy): Add new argument Level.
(Check_Kind): Removed. Merged with Get_Applicable_Policy.
(Get_Assertion_Level): New subprogram.
(Is_Valid_Assertion_Level): New subprogram.
* sem_util.adb (Copy_Assertion_Policy_Attributes): New function
for copying the ghost related attributes from one pragma to
another.
(Copy_Subprogram_Spec): Additionally copy the level from the spec.
(Depends_On_Level): New function for checking if one level depends
on another level.
(From_Same_Aspect): New function for checking whether the aspects
orignate from the same original aspect.
(From_Same_Pragma): New function for checking whether the pragmas
originate from the same original aspect or pragma.
(Get_Subprogram_Entity): Avoid crash when being called when the
entity has not been set for the subprogram.
(Has_Assertion_Level_Argument): New function for checking whether
the aspect or a pragma has an argument that is using an assertion
level association.
(Policy_In_Effect): add an additional argument for the level that
should be checked along with the assertion name.
* sem_util.ads (Copy_Assertion_Policy_Attributes): New function.
(Depends_On_Level): Likewise.
(From_Same_Aspect): Likewise.
(From_Same_Pragma): Likewise.
(Has_Assertion_Level_Argument): Likewise.
(Is_Same_Or_Depends_On_Level): Likewise.
(Policy_In_Effect): Add new argument Level.
* sinfo.ads: Add documentation for all the new attributes that
were added to the nodes and entities.
* snames.ads-tmpl: Add new entries for Name_Assertion_Level,
Name_uDefault_Assertion_Level and Pragma_Assertion_Level.
* stand.ads: Add new entities for the predefined assertion levels.
(Standard_Level_Static): Definition for the predefined Static
level that is always ignored.
(Standard_Level_Runtime): Defintion for the predefined Runtime
level that is always checked.
(Standard_Level_Default): Definition for the implicit Default
level that is given for ghost entities that were not associated
with an assertion level (e.g. Ghost => True).
* tbuild.adb (Make_Assertion_Level): New function for constructin
an assertion level.
* tbuild.ads (Make_Assertion_Level): Likewise.
libstdc++: Replace "Tunables" link with one that does not have an anchor
This works around a dblatex bug, where dblatex emits invalid TeX, by
placing a raw "#" in a \href.
Fixes: f6ff531d907d ("libstdc++: Update link to "Tunables" in Glibc manual")
libstdc++-v3/ChangeLog:
* doc/xml/manual/using_exceptions.xml: Replace "Tunables" link
with one that does not have an anchor.
* doc/html/manual/using_exceptions.html: Regenerate.
Use vpermil{ps,pd} instead of vperm{d,q} when permutation is in-lane.
gcc/ChangeLog:
* config/i386/i386-expand.cc (expand_vec_perm_vpermil): Extend
to handle V8SImode.
* config/i386/i386.cc (avx_vpermilp_parallel): Extend to
handle vector integer modes with same vector size and same
component size.
* config/i386/sse.md
(<sse2_avx_avx512f>_vpermilp<mode><mask_name>): Ditto.
(V48_AVX): New mode iterator.
(ssefltmodesuffix): Extend for V16SI/V8DI/V16SF/V8DF.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx256_avoid_vec_perm-3.c: New test.
* gcc.target/i386/avx256_avoid_vec_perm-4.c: New test.
* gcc.target/i386/avx512bw-vpalignr-4.c: Adjust testcase.
* gcc.target/i386/avx512vl-vpalignr-4.c: Ditto.
liuhongt [Wed, 20 Aug 2025 05:46:40 +0000 (22:46 -0700)]
Exclude fake cross-lane permutation from avx256_avoid_vec_perm.
SLP may take a broadcast as kind of vec_perm, the patch checks the
permutation index to exclude those false positive.
gcc/ChangeLog:
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Check permutation index for vec_perm, don't count it if we
know it's not a cross-lane permutation.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx256_avoid_vec_perm.c: Adjust testcase.
* gcc.target/i386/avx256_avoid_vec_perm-2.c: New test.
* gcc.target/i386/avx256_avoid_vec_perm-5.c: New test.
H.J. Lu [Fri, 5 Sep 2025 22:40:51 +0000 (15:40 -0700)]
c: Update TLS model after processing a TLS variable
Set a tentative TLS model in grokvardecl and update TLS mode with the
default TLS access model after a TLS variable has been fully processed
if the default TLS access model is stronger.
gcc/c/
PR c/107419
* c-decl.cc (c_decl_attributes): Update TLS model with the
default TLS access model if the default TLS access model is
stronger.
(grokdeclarator): Set a tentative TLS model which will be
updated by c_decl_attributes later.