]> gcc.gnu.org Git - gcc.git/log
gcc.git
6 hours agoUpdate gcc .po files
Joseph Myers [Fri, 2 Aug 2024 21:12:13 +0000 (21:12 +0000)]
Update gcc .po files

* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

8 hours agoc++: Move -Wdangling-reference to -Wextra
Marek Polacek [Thu, 1 Aug 2024 14:35:38 +0000 (10:35 -0400)]
c++: Move -Wdangling-reference to -Wextra

Despite a number of mitigations (don't warn for std::span-like classes,
lambdas, adding [[gnu::no_dangling]], etc.), the warning still seems to
cause some grief.  Let's move the warning to -Wextra, then.

gcc/c-family/ChangeLog:

* c.opt (Wdangling-reference): Move from -Wall to -Wextra.

gcc/ChangeLog:

* doc/invoke.texi: Document that -Wdangling-reference is
enabled by -Wextra.

8 hours agoc++/coroutines: check for members we use in handle_types [PR105475]
Arsen Arsenović [Thu, 25 Jul 2024 20:41:34 +0000 (22:41 +0200)]
c++/coroutines: check for members we use in handle_types [PR105475]

Currently, it is possible to ICE GCC by giving it sufficiently broken
code, where sufficiently broken means a std::coroutine_handle missing a
default on the promise_type template argument, and missing members.
As the code generator relies on lookups in the coroutine_handle never
failing (and has no way to signal that error), lets do it ahead of time,
save the result, and use that.  This saves us some lookups and allows us
to propagate an error.

PR c++/105475 - coroutines: ICE in coerce_template_parms, at cp/pt.cc:9183

gcc/cp/ChangeLog:

PR c++/105475
* coroutines.cc (struct coroutine_info): Add from_address.
Carries the from_address member we looked up earlier.
(coro_resume_identifier): Remove.  Unused.
(coro_init_identifiers): Do not initialize the above.
(void_coro_handle_address): New variable.  Contains the baselink
for the std::coroutine_handle<void>::address() instance method.
(get_handle_type_address): New function.  Looks up and validates
handle_type::address in a given handle_type.
(get_handle_type_from_address): New function.  Looks up and
validates handle_type::from_address in a given handle_type.
(coro_promise_type_found_p): Remove reliance on
coroutine_handle<> defaulting the promise type to void.  Store
get_handle_type_* results where appropriate.
(get_coroutine_from_address): New helper.  Gets the
handle_type::from_address BASELINK from a coroutine_info.
(build_actor_fn): Use the get_coroutine_from_address helper and
void_coro_handle_address.

gcc/testsuite/ChangeLog:

PR c++/105475
* g++.dg/coroutines/pr103868.C: Add std::coroutine_handle
members we check for now.
* g++.dg/coroutines/pr105287.C: Ditto.
* g++.dg/coroutines/pr105301.C: Ditto.
* g++.dg/coroutines/pr94528.C: Ditto.
* g++.dg/coroutines/pr94879-folly-1.C: Ditto.
* g++.dg/coroutines/pr94883-folly-2.C: Ditto.
* g++.dg/coroutines/pr98118.C: Ditto.
* g++.dg/coroutines/pr105475.C: New test.
* g++.dg/coroutines/pr105475-1.C: New test.
* g++.dg/coroutines/pr105475-2.C: New test.
* g++.dg/coroutines/pr105475-3.C: New test.
* g++.dg/coroutines/pr105475-4.C: New test.
* g++.dg/coroutines/pr105475-5.C: New test.
* g++.dg/coroutines/pr105475-6.C: New test.
* g++.dg/coroutines/pr105475-broken-spec.C: New test.
* g++.dg/coroutines/pr105475-broken-spec-2.C: New test.

10 hours agofortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.
Mikael Morin [Fri, 2 Aug 2024 12:24:34 +0000 (14:24 +0200)]
fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.

Protect the evaluation of BACK with a check that the reference is non-null
in case the expression is an optional dummy, in the inline code generated
for MINLOC and MAXLOC.

This change contains a revert of the non-testsuite part of commit
r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the
evaluation of BACK out of the loop using the scalarizer.  It was a bad idea,
because delegating the argument evaluation to the scalarizer makes it
cumbersome to add a null pointer check next to the evaluation.

Instead, evaluate BACK at the beginning, before scalarization, add a check
that the argument is present if necessary, and evaluate the resulting
expression to a variable, before using the variable in the inline code.

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (maybe_absent_optional_variable): New function.
(gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and
evaluate it before.  Add a check that BACK is not null if the
expression is an optional dummy.  Save the resulting expression to a
variable.  Use the variable in the generated inline code.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_6.f90: New test.
* gfortran.dg/minloc_7.f90: New test.

10 hours agogenemit: Fix handling of explicit parallels for clobbers [PR116058]
Andrew Pinski [Thu, 1 Aug 2024 21:22:36 +0000 (14:22 -0700)]
genemit: Fix handling of explicit parallels for clobbers [PR116058]

In a define_insn, you could use either an explicit parallel for
the insns or genrecog/genemit will add one for you.
The problem when genemit is processing the pattern for clobbers
(to create the function add_clobbers), genemit hadn't add the implicit
parallel yet but at the same time forgot to ignore that there
could be an explicit parallel there.
This means in some cases (like in the sh backend), add_clobbers
and recog had a different idea if there was clobbers on the insn.
This fixes the problem by looking through the explicit parallel
for the instruction in genemit.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116058

gcc/ChangeLog:

* genemit.cc (struct clobber_pat): Change pattern to be rtvec.
Add code field.
(gen_insn): Look through an explicit parallel if there was one.
Update store to new clobber_pat.
(output_add_clobbers): Update call to gen_exp for the changed
clobber_pat.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 hours agoRISC-V: Improve length attributes for atomic insn sequences
Patrick O'Neill [Fri, 2 Aug 2024 03:27:52 +0000 (20:27 -0700)]
RISC-V: Improve length attributes for atomic insn sequences

gcc/ChangeLog:

* config/riscv/sync-rvwmo.md: Add conditional length attributes.
* config/riscv/sync-ztso.md: Ditto.
* config/riscv/sync.md: Fix incorrect insn length attributes and
reformat existing conditional checks.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
11 hours agoarm: Fix testism with mve/ivopts-3.c testcase
Andre Vieira [Fri, 2 Aug 2024 15:39:34 +0000 (16:39 +0100)]
arm: Fix testism with mve/ivopts-3.c testcase

This patch ensures this testcase is ran for armv8.1-m.main+mve as this is
testing that doloops with function calls that aren't intrinsics get rejected
as potential doloop targets during ivopts.  For other targets this loop gets
rejected for different reasons.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/ivopts-3.c: Add require target and options.

12 hours agoAArch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2
Jennifer Schmitz [Fri, 2 Aug 2024 14:58:32 +0000 (15:58 +0100)]
AArch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2

According to the Neoverse V2 Software Optimization Guide (section 4.14), the
instruction pairs CMP+CSEL and CMP+CSET can be fused, which had not been
implemented so far. This patch implements and tests the two fusion pairs.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
There was also no non-noise impact on SPEC CPU2017 benchmark.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/

* config/aarch64/aarch64.cc (aarch_macro_fusion_pair_p): Implement
fusion logic.
* config/aarch64/aarch64-fusion-pairs.def (cmp+csel): New entry.
(cmp+cset): Likewise.
* config/aarch64/tuning_models/neoversev2.h: Enable logic in
field fusible_ops.

gcc/testsuite/

* gcc.target/aarch64/fuse_cmp_csel.c: New test.
* gcc.target/aarch64/fuse_cmp_cset.c: Likewise.

12 hours agoMake may_trap_p_1 return false for constant pool references [PR116145]
Richard Sandiford [Fri, 2 Aug 2024 14:58:31 +0000 (15:58 +0100)]
Make may_trap_p_1 return false for constant pool references [PR116145]

The testcase contains the constant:

  arr2 = svreinterpret_u8(svdup_u32(0x0a0d5c3f));

which was initially hoisted by hand, but which gimple optimisers later
propagated to each use (as expected).  The constant was then expanded
as a load-and-duplicate from the constant pool.  Normally that load
should then be hoisted back out of the loop, but may_trap_or_fault_p
stopped that from happening in this case.

The code responsible was:

      if (/* MEM_NOTRAP_P only relates to the actual position of the memory
     reference; moving it out of context such as when moving code
     when optimizing, might cause its address to become invalid.  */
  code_changed
  || !MEM_NOTRAP_P (x))
{
  poly_int64 size = MEM_SIZE_KNOWN_P (x) ? MEM_SIZE (x) : -1;
  return rtx_addr_can_trap_p_1 (XEXP (x, 0), 0, size,
GET_MODE (x), code_changed);
}

where code_changed is true.  (Arguably it doesn't need to be true in
this case, if we inserted invariants on the preheader edge, but it
would still need to be true for conditionally executed loads.)

Normally this wouldn't be a problem, since rtx_addr_can_trap_p_1
would recognise that the address refers to the constant pool.
However, the SVE load-and-replicate instructions have a limited
offset range, so it isn't possible for them to have a LO_SUM address.
All we have is a plain pseudo base register.

MEM_READONLY_P is defined as:

  /* 1 if RTX is a mem that is statically allocated in read-only memory.  */
  #define MEM_READONLY_P(RTX) \
    (RTL_FLAG_CHECK1 ("MEM_READONLY_P", (RTX), MEM)->unchanging)

and so I think it should be safe to move memory references if both
MEM_READONLY_P and MEM_NOTRAP_P are true.

The testcase isn't a minimal reproducer, but I think it's good
to have a realistic full routine in the testsuite.

gcc/
PR rtl-optimization/116145
* rtlanal.cc (may_trap_p_1): Trust MEM_NOTRAP_P even for code
movement if MEM_READONLY_P is also true.

gcc/testsuite/
PR rtl-optimization/116145
* gcc.target/aarch64/sve/acle/general/pr116145.c: New test.

13 hours agoc++: DR882, main cannot be deleted [PR116169]
Marek Polacek [Thu, 1 Aug 2024 15:32:26 +0000 (11:32 -0400)]
c++: DR882, main cannot be deleted [PR116169]

This DR clarifies that "int main() = delete;" is ill-formed.

PR c++/116169

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Disallow deleting ::main.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr882.C: New test.

16 hours agoc++, coroutines: Provide a CTOR for a callback object [NFC].
Iain Sandoe [Wed, 31 Jul 2024 13:51:31 +0000 (14:51 +0100)]
c++, coroutines: Provide a CTOR for a callback object [NFC].

This provides and uses a CTOR to initialize the object used in
tree walks to track local variable uses.  This makes the idiom
used consistent.

gcc/cp/ChangeLog:

* coroutines.cc (struct local_vars_frame_data): Add a
CTOR.
(morph_fn_to_coro): Use CTOR for local_vars_frame_data
instead of brace init.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
16 hours agoc++, coroutines: Remove unused suspend point state [NFC].
Iain Sandoe [Tue, 30 Jul 2024 07:58:42 +0000 (08:58 +0100)]
c++, coroutines: Remove unused suspend point state [NFC].

We maintain state on the progress of await analysis in an object that
is passed to the various tree walks used.  Some of the state had become
stale (i.e. unused members).  Remove those and provide a CTOR so that
updates are localised.

Remove the file scope hash_map used to collect the final state for the
actor function and make that part of the suspend point state.

gcc/cp/ChangeLog:

* coroutines.cc (struct susp_frame_data): Remove unused members,
provide a CTOR.
(morph_fn_to_coro): Use susp_frame_data CTOR, and make the suspend
state hash map local to the morph function.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
16 hours agoc++, coroutines: Fix a typo in checking for void expression types.
Iain Sandoe [Wed, 24 Jul 2024 19:59:10 +0000 (20:59 +0100)]
c++, coroutines: Fix a typo in checking for void expression types.

The current code fails to check for void expression types because it does
not looup the type.  Fixed thus.

gcc/cp/ChangeLog:

* coroutines.cc (replace_continue): Look up expression type.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
17 hours agoforwprop: Don't add uses to dce list if debug statement [PR116156]
Andrew Pinski [Thu, 1 Aug 2024 17:33:34 +0000 (10:33 -0700)]
forwprop: Don't add uses to dce list if debug statement [PR116156]

The problem here is that when forwprop does a copy prop, into a statement,
we mark the uses of that statement as possibly need to be removed. But it just
happened that statement was a debug statement, there will be a difference when
compiling with debuging info turned on vs off; this is not expected.
So the fix is not to add the old use to dce list to process if it was a debug
statement.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/116156

gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Don't add
uses if the statement was a debug statement.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116156-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
18 hours agoc: Add support for byte arrays in C2Y
Martin Uecker [Sun, 23 Jun 2024 21:14:33 +0000 (23:14 +0200)]
c: Add support for byte arrays in C2Y

To get correct aliasing behavior requires that structures and unions
that contain a byte array, i.e. an array of non-atomic character
type (N3254), are marked with TYPE_TYPELESS_STORAGE.  This change
affects also earlier language modes.

gcc/c/
* c-decl.cc (grokdeclarator, finish_struct): Set and
propagate TYPE_TYPELESS_STORAGE.

gcc/testsuite/
* gcc.dg/c2y-byte-alias-1.c: New test.
* gcc.dg/c2y-byte-alias-2.c: New test.
* gcc.dg/c2y-byte-alias-3.c: New test.

18 hours agoi386: Fix comment/naming for APX NDD constraints
Lingling Kong [Fri, 2 Aug 2024 08:52:33 +0000 (16:52 +0800)]
i386: Fix comment/naming for APX NDD constraints

gcc/ChangeLog:

* config/i386/constraints.md: Fixed the comment/naming for je/jM/jO.
* config/i386/predicates.md (apx_ndd_memory_operand): Renamed and
fixed the comment.
(apx_evex_memory_operand): New name.
(apx_ndd_add_memory_operand): Ditto.
(apx_evex_add_memory_operand): Ditto.

19 hours agolibstdc++: Add missing <cstdint> to test
Jonathan Wakely [Fri, 2 Aug 2024 07:27:09 +0000 (08:27 +0100)]
libstdc++: Add missing <cstdint> to test

libstdc++-v3/ChangeLog:

* testsuite/libstdc++-prettyprinters/shared_ptr.cc: Include
<cstdint>.

20 hours agoada: Fix handling of SPARK_Mode on standalone child subprogram
Yannick Moy [Wed, 17 Jul 2024 08:43:06 +0000 (10:43 +0200)]
ada: Fix handling of SPARK_Mode on standalone child subprogram

SPARK_Mode aspect was not properly propagated to the body of
a standalone child subprogram from the generated spec for that subprogram,
leading GNATprove to not analyze this body. Now fixed.

gcc/ada/

* aspects.adb (Find_Aspect): Take into account the case of a node
of kind N_Defining_Program_Unit_Name.
* sem_ch10.adb (Analyze_Compilation_Unit): Copy the SPARK aspect
from the spec to the body. Delay semantic analysis after that
point to ensure that SPARK_Mode is properly analyzed.

20 hours agoada: Fix handling of iterated component associations with sub-aggregates
Piotr Trojanek [Tue, 16 Jul 2024 14:07:59 +0000 (16:07 +0200)]
ada: Fix handling of iterated component associations with sub-aggregates

Fix a number of problems in handling of actions generated for a
2-dimensional array aggregate where the outer aggregate has iterated
component association and the inner aggregate involves run-time checks.

gcc/ada/

* exp_aggr.adb (Add_Loop_Actions): Actions are now attached to
iterated component association just like they are attached to
ordinary component association.
(Build_Array_Aggr_Code): If resolution of the array aggregate
generated some actions, e.g. for run-time checks, then we must
keep them; same for the Other_Clause.
* sem_aggr.adb (Resolve_Iterated_Component_Association): Unset
references to iterator variable in loop actions (which might come
from run-time check), just these references are unset in the
expression itself.

20 hours agoada: Remove unused null branch
Piotr Trojanek [Fri, 5 Jul 2024 15:42:00 +0000 (17:42 +0200)]
ada: Remove unused null branch

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_util.adb (Insert_Actions): Remove null ELSE branch.

20 hours agoada: Simplify manipulation of the list with loop actions
Piotr Trojanek [Fri, 5 Jul 2024 15:16:36 +0000 (17:16 +0200)]
ada: Simplify manipulation of the list with loop actions

Code cleanup; behavior is unaffected.

gcc/ada/

* exp_aggr.adb (Add_Loop_Actions): Change manipulation of list
to avoid unnecessary calls to Parent and Loop_Actions.

20 hours agoada: Refactor negated conjuncts
Piotr Trojanek [Fri, 5 Jul 2024 15:15:49 +0000 (17:15 +0200)]
ada: Refactor negated conjuncts

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_util.adb (Insert_Actions): Move negation in front of
complex conjunctions.

20 hours agoada: Simplify code by reusing Choice_List
Piotr Trojanek [Fri, 5 Jul 2024 11:01:08 +0000 (13:01 +0200)]
ada: Simplify code by reusing Choice_List

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_aggr.adb (Gen_Assign): Fix layout.
* sem_aggr.adb (Empty_Range): Reuse Choice_List.

20 hours agoada: Errors on legal container aggregates with iterated_element_associations
Gary Dismukes [Mon, 15 Jul 2024 23:57:43 +0000 (23:57 +0000)]
ada: Errors on legal container aggregates with iterated_element_associations

The compiler rejects various cases of container aggregates with
iterated_element_associations that include a loop_parameter_subtype_indication
or that include the "reverse" keyword. The fixes are in the parser, for
naccepting the syntax for these cases, as well as for properly accounting
for reverse iterators in the analyzer and expander.

gcc/ada/

* exp_aggr.adb
(Expand_Container_Aggregate.Expand_Iterated_Component): Set the
Reverse_Present flag when creating the loop's iteration_scheme.
* gen_il-gen-gen_nodes.adb: Add flag Reverse_Present to
N_Iterated_Component_Association nodes.
* par-ch3.adb (P_Constraint_Op): Remove testing for and ignoring
of Tok_In following a constraint. It's allowed for "in" to follow
a constraint of loop_parameter_subtype_indication of an
iterator_specification, so it shouldn't be ignored.
* par-ch4.adb (P_Iterated_Component_Association): Account for
"reverse" following the "in" in an iterated_component_association,
and set the Reverse_Present flag on the
N_Iterated_Component_Association node. Add handling for a ":"
following the identifier in an iterator_specification of an
iterated_element_association, sharing the code with the "of" case
(which backs up to the identifier at the beginning of the
iterator_specification). Fix incorrect trailing comment following
the call to Scan.
(Build_Iterated_Element_Association): Set the Reverse_Present flag
on an N_Loop_Parameter_Specification node of an
N_Iterated_Element_Association.
* par-ch5.adb (P_Iterator_Specification): Remove error-recovery
and error code that reports "subtype indication is only legal on
an element iterator", as that error can no longer be emitted (and
was formerly only reported on one fixedbugs test).
* sem_aggr.adb
(Resolve_Container_Aggregate.Resolve_Iterated_Association): When
creating an N_Iterator_Specification for an
N_Iterated_Component_Association, set the Reverse_Present flag of
the N_Iterated_Specification from the flag on the latter.
* sinfo.ads: Add comments for the Reverse_Present flag, which is
now allowed on nodes of kind N_Iterated_Component_Association.

20 hours agoada: Plug loophole in handling of No_Raise pragma
Eric Botcazou [Mon, 15 Jul 2024 20:29:06 +0000 (22:29 +0200)]
ada: Plug loophole in handling of No_Raise pragma

Unlike the aspect, the pragma needs to be propagated explicitly from a
generic subprogram to its instances.

gcc/ada/

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Propagate the
No_Raise flag like the No_Return flag.

20 hours agoada: Tweak container aggregate expansion code
Ronan Desplanques [Mon, 15 Jul 2024 08:22:29 +0000 (10:22 +0200)]
ada: Tweak container aggregate expansion code

This patch makes a minor modification to Expand_Container_Aggregate
in order to silence a GNAT SAS false positive.

gcc/ada/

* exp_aggr.adb (Expand_Container_Aggregate): Remove variables.
(To_Int): New function.
(Add_Range_Size): Use newly introduced function.

20 hours agoada: Add contracts to Ada.Strings.Unbounded and adapt implementation
Yannick Moy [Tue, 2 Jul 2024 14:07:05 +0000 (16:07 +0200)]
ada: Add contracts to Ada.Strings.Unbounded and adapt implementation

Add complete functional contracts to all subprograms in
Ada.Strings.Unbounded, except Count, following the specification from
Ada RM A.4.5. These contracts are similar to the contracts found in
Ada.Strings.Fixed and Ada.Strings.Bounded.

A difference is that type Unbounded_String is controlled, thus we avoid
performing copies of a parameter Source with Source'Old, and instead
apply 'Old attribute on the enclosing call, such as Length(Source)'Old.

As Unbounded_String is controlled, the implementation is not in SPARK.
Instead, we have separately proved a slightly different implementation
for which Unbounded_String is not controlled, against the same
specification. This ensures that the specification is consistent.

To minimize differences between this test from the SPARK testsuite and
the actual implementation (the one in a-strunb.adb), and to avoid
overflows in the actual implementation, some code is slightly rewritten.
Delete and Insert are modified to return the correct result in all
cases allowed by the standard.

The same contracts are added to the version in a-strunb__shared.ads and
similar implementation patches are applied to the body
a-strunb__shared.adb. In particular, tests are added to avoid overflows
on strings for which the last index is Natural'Last, and the computations
that involve Sum to guarantee that an exception is raised in case of
overflow are rewritten to guarantee correct detection and no intermediate
overflows (and such tests are applied consistently between the procedure
and the function when both exist).

gcc/ada/

* libgnat/a-strunb.adb (Sum, Saturated_Sum, Saturated_Mul): Adapt
function signatures to more precise types that allow proof.
(function "&"): Conditionally assign a slice to avoid possible
overflow which only occurs when the assignment is a noop (because
the slice is empty in that case).
(Append): Same.
(function "*"): Retype K to avoid a possible overflow. Add early
return on null length for proof.
(Delete): Fix implementation to return the correct result in all
cases allowed by the Ada standard.
(Insert): Same. Also avoid possible overflows.
(Length): Rewrite as expression function for proof.
(Overwrite): Avoid possible overflows.
(Slice): Same.
(To_String): Rewrite as expression function for proof.
* libgnat/a-strunb.ads: Extend Assertion_Policy to new contracts
used. Add complete functional contracts to all subprograms of the
public API except Count.
* libgnat/a-strunb__shared.adb (Sum): Adapt function signature to
more precise types that allow proof.
(function "&"): Conditionally assign a slice to avoid possible
overflow.
(function "*"): Retype K to avoid a possible overflow.
(Delete): Fix implementation to return the correct result in all
cases allowed by the Ada standard.
(Insert): Avoid possible overflows.
(Overwrite): Avoid possible overflows.
(Replace_Slice): Same.
(Slice): Same.
(To_String): Rewrite as expression function for proof.
* libgnat/a-strunb__shared.ads: Extend Assertion_Policy to new
contracts used. Add complete functional contracts to all
subprograms of the public API except Count. Mark public part of
spec as in SPARK.

20 hours agoada: Ensure variable is initialized before use
Ronan Desplanques [Fri, 12 Jul 2024 08:56:58 +0000 (10:56 +0200)]
ada: Ensure variable is initialized before use

This patch is motivated by a GNAT SAS report.

gcc/ada/

* scng.adb (Slit): Initialize object in uncommon path.

20 hours agoada: Remove unreferenced procedure
Richard Kenner [Fri, 12 Jul 2024 13:38:21 +0000 (09:38 -0400)]
ada: Remove unreferenced procedure

gcc/ada/

* exp_ch4.adb (Generate_Temporary): Remove unused procedure.

20 hours agoada: Clean up handling of inlining of finalizer procedures
Richard Kenner [Fri, 12 Jul 2024 13:45:26 +0000 (09:45 -0400)]
ada: Clean up handling of inlining of finalizer procedures

Change Is_Finalizer from synthesized attribute into flag. Remove duplicate
Is_Finalizer_Proc. Add new Try_Inline_Always for backend usage.

gcc/ada/

* einfo-utils.ads (Is_Finalizer): Delete.
* einfo-utils.adb (Is_Finalizer): Delete.
* einfo.ads: Adjust comment.
* gen_il-fields.ads, gen_il-gen-gen_entities.adb: Add Is_Finalizer
flag.
* exp_ch3.adb (Build_Init_Procedure): Set it.
* exp_ch7.adb (Create_Finalizer): Likewise.
* exp_util.adb (Try_Inline_Always): New function.
* exp_util.ads (Try_Inline_Always): New function.
* sem_elab.adb (Is_Finalizer_Proc): Replace with Is_Finalizer.

20 hours agoada: Add leap second support to conversion of Unix_Time
Tonu Naks [Mon, 8 Jul 2024 08:50:00 +0000 (08:50 +0000)]
ada: Add leap second support to conversion of Unix_Time

Unix timestamp jumps one second back when a leap second
is applied and doesn't count cumulative leap seconds.
This was not taken into account in conversions between
Unix time and Ada time. Now fixed.

gcc/ada/

* libgnat/a-calend.adb: Modify unix time handling.

20 hours agoada: Update doc of Style_Checks pragma
Tonu Naks [Tue, 9 Jul 2024 12:02:57 +0000 (12:02 +0000)]
ada: Update doc of Style_Checks pragma

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Add examples.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

20 hours agoada: Reject ambiguous function calls in interpolated string expressions
Javier Miranda [Sat, 6 Jul 2024 19:07:16 +0000 (19:07 +0000)]
ada: Reject ambiguous function calls in interpolated string expressions

This patch enhances support for this language feature by rejecting
more ambiguous function calls. In terms of name resolution, the
analysis of interpolated expressions is now treated as an expression
of any type, as required by the documentation. Additionally, support
for nested interpolated strings has been removed.

gcc/ada/

* gen_il-fields.ads (Is_Interpolated_String_Literal): New field.
* gen_il-gen-gen_nodes.adb (Is_Interpolated_String_Literal): The
new field is a flag handled by the parser (syntax flag).
* par-ch2.adb (P_Interpolated_String_Literal): Decorate the new
flag.
* sem_ch2.adb (Analyze_Interpolated_String_Literal): Improve code
detecting and reporting ambiguous function calls.
* sem_res.adb (Resolve_Interpolated_String_Literal): Restrict
resolution imposed by the context type to string literals that
have the new flag.
* sinfo.ads (Is_Interpolated_String_Literal): New field defined in
string literals. Fix documentation of the syntax rule of
interpolated string literal.

20 hours agoada: Compiler accepts illegal assignment to reference type target.
Steve Baird [Tue, 9 Jul 2024 23:54:59 +0000 (16:54 -0700)]
ada: Compiler accepts illegal assignment to reference type target.

An assignment statement whose LHS is of a reference type is never legal. If
no other legality rule is violated, then it is ambiguous. In some cases this
ambiguity was not correctly detected.

gcc/ada/

* sem_ch5.adb (Analyze_Assignment): Delete code that was
incorrectly implementing a preference rule.

20 hours agoada: Finish up support for relaxed finalization
Eric Botcazou [Tue, 9 Jul 2024 20:44:40 +0000 (22:44 +0200)]
ada: Finish up support for relaxed finalization

This adds a variant of the System.Finalization_Primitives unit that supports
only controlled types with relaxed finalization, and adds the description of
its implementation to Exp_Ch7.

gcc/ada/

* exp_ch7.adb (Relaxed Finalization): New paragraph in head
comment.
* sem_ch13.adb (Validate_Finalizable_Aspect): Give an error
message if strict finalization is required but not supported by
the runtime.

20 hours agoada: Fix handling reference warnings with slices
Viljar Indus [Tue, 9 Jul 2024 07:34:37 +0000 (10:34 +0300)]
ada: Fix handling reference warnings with slices

gcc/ada/

* sem_util.adb (Set_Referenced_Modified): Set referenced as LHS
for the prefixes of array slices.

20 hours agoada: Reject illegal uses of type/subtype current instance
Steve Baird [Mon, 8 Jul 2024 21:02:15 +0000 (14:02 -0700)]
ada: Reject illegal uses of type/subtype current instance

The current instance of a type or subtype (see RM 8.6) is an object or
value, not a type or subtype. So a name denoting such a current instance is
illegal in any context that requires a name denoting a type or subtype.
In some cases this error was not detected.

gcc/ada/

* sem_ch8.adb (Find_Type): If Is_Current_Instance returns True for
N (and Comes_From_Source (N) is also True) then flag an error.
Call Is_Current_Instance (twice) instead of duplicating (twice)
N_Access_Definition-related code in Is_Current_Instance.
* sem_util.adb (Is_Current_Instance): Implement
access-type-related clauses of the RM 8.6 current instance rule.
For pragmas Predicate and Predicate_Failure, distinguish between
the first and subsequent pragma arguments.

20 hours agoada: Type conversion in instance incorrectly rejected.
Steve Baird [Mon, 8 Jul 2024 21:45:55 +0000 (14:45 -0700)]
ada: Type conversion in instance incorrectly rejected.

In some cases, a legal type conversion in a generic package is correctly
accepted but the corresponding type conversion in an instance of the generic
is incorrectly rejected.

gcc/ada/

* sem_res.adb (Valid_Conversion): Test In_Instance instead of
In_Instance_Body.

20 hours agoada: Implement No_Raise aspect & pragma on subprograms
Eric Botcazou [Wed, 3 Jul 2024 16:24:37 +0000 (18:24 +0200)]
ada: Implement No_Raise aspect & pragma on subprograms

The new aspect is automatically set on the Adjust and Finalize primitives of
finalizable types, unless Relaxed_Finalization is explicitly set to False,
but it can also be specified directly on subprograms.  It is also available
in earlier versions of the language by means of the associated pragma.

gcc/ada/

* aspects.ads (Aspect_Id): Add Aspect_No_Raise identifier.
(Implementation_Defined_Aspect): Add True for Aspect_No_Raise.
(Is_Representation_Aspect): Add False for Aspect_No_Raise.
(Aspect_Names): Add Name_No_Raise for Aspect_No_Raise.
(Aspect_Delay): Add Always_Delay for Aspect_No_Raise.
* checks.ads (Raise_Checks_Suppressed): New function.
(Apply_Raise_Check): New procedure.
* checks.adb (Apply_Raise_Check): New procedure.
(Raise_Checks_Suppressed): New function.
* doc/gnat_rm/gnat_language_extensions.rst (Generalized
Finalization): Update.
* doc/gnat_rm/implementation_defined_aspects.rst (No_Raise): New.
* doc/gnat_rm/implementation_defined_characteristics.rst (Check
names): Document Raise_Check and alphabetize others.
* doc/gnat_rm/implementation_defined_pragmas.rst (No_Raise): New.
* einfo.ads (No_Raise): New flag defined in subprograms and
generic subprograms.
* exp_ch6.adb (Expand_N_Subprogram_Body): Call Apply_Raise_Check
at the end of the processing.
* exp_ch11.adb (Get_RT_Exception_Name): Add alternative for
PE_Raise_Check_Failed to case statement.
* gen_il-fields.ads (Opt_Field_Enum): Add No_Raise identifier.
* gen_il-gen-gen_entities.adb (Subprogram_Kind): Add No_Raise as
semantical flag.
(Generic_Subprogram_Kind): Likewise.
* par-prag.adb (Prag): Add alternative for Pragma_No_Raise to case
statement.
* sem_ch13.adb (Validate_Finalizable_Aspect): Set No_Raise on the
Adjust and Finalize primitives if Relaxed_Finalization is set.
* sem_prag.adb (Analyze_Pragma): Add alternative for
Pragma_No_Raise to case statement.
(Sig_Flag): Add 0 for Pragma_No_Raise.
* snames.ads-tmpl (Remaining pragma names): Add Name_No_Raise.
(Names of recognized checks): Add Name_Raise_Check.
(Pragma_Id): Add Pragma_No_Raise identifier.
* types.ads (Raise_Check): New named number.
(All_Checks): Adjust.
(RT_Exception_Code): Add PE_Raise_Check_Failed identifier.
(Rkind): Add PE_Reason for PE_Raise_Check_Failed and alphabetize.
* types.h (RT_Exception_Code): Add PE_Raise_Check_Failed as 38.
(LAST_REASON_CODE): Adjust.
* libgnat/a-except.adb (Rcheck_PE_Raise_Check): New procedure with
pragmas Export, No_Return and Machine_Attributes.
(Rmsg_38): New string constant.
* gnat_rm.texi: Regenerate.

20 hours agoada: Improve documenation about security of PRGNs
Johannes Kliemann [Fri, 5 Jul 2024 11:27:44 +0000 (11:27 +0000)]
ada: Improve documenation about security of PRGNs

The pseudo random number generators used in GNAT are not
suitable for applications that require cryptographic
security. While this was mentioned in some places others
did not have a corresponding note, leading to these
generators being used in a non-suitable context.

gcc/ada/

* doc/gnat_rm/standard_library_routines.rst: Add note to section
of Ada.Numerics.Discrete_Random and Ada.Numerics.Float_Random.
* doc/gnat_rm/the_gnat_library.rst: Add note to section about
GNAT.Random_Numbers.
* libgnat/a-nudira.ads: Add note about cryptographic properties.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

20 hours agoada: Fix layout of GNAT reference manual section
Ronan Desplanques [Fri, 5 Jul 2024 08:52:58 +0000 (10:52 +0200)]
ada: Fix layout of GNAT reference manual section

gcc/ada/

* doc/gnat_rm/gnat_language_extensions.rst: Fix layout of section.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

20 hours agoada: Fix crash on expression function returning tagged type in nested package
Eric Botcazou [Thu, 4 Jul 2024 21:35:01 +0000 (23:35 +0200)]
ada: Fix crash on expression function returning tagged type in nested package

This happens when the expression is a reference to a formal parameter of
the function, or a conditional expression with such a reference as one of
its dependent expressions, because the RM 6.5(8/5) subclause prescribes a
tag reassignment in this case, which requires freezing the tagged type in
the GNAT freezing model, although the language says there is no freezing.

In other words, it's another occurrence of the discrepancy between this
model tailored to Ada 95 and the freezing rules introduced in Ada 2012,
that is papered over by Should_Freeze_Type and the associated processing.

gcc/ada/

* exp_util.ads (Is_Conversion_Or_Reference_To_Formal): New
function declaration.
* exp_util.adb (Is_Conversion_Or_Reference_To_Formal): New
function body.
* exp_ch6.adb (Expand_Simple_Function_Return): Call the predicate
Is_Conversion_Or_Reference_To_Formal in order to decide whether a
tag check or reassignment is needed.
* freeze.adb (Should_Freeze_Type): Move declaration and body to
the appropriate places. Also return True for tagged results
subject to the expansion done in Expand_Simple_Function_Return
that is guarded by the predicate
Is_Conversion_Or_Reference_To_Formal.

20 hours agoada: Fix detection of suspicious loop patterns
Ronan Desplanques [Thu, 4 Jul 2024 13:43:04 +0000 (15:43 +0200)]
ada: Fix detection of suspicious loop patterns

This patch fixes an assertion failure in some cases in the code to
warn about possible misuse of range attributes in loop. The root of
the problem is that this code failed to consider the case where the
outer loop is a while loop.

Also fix a typo in a nearby comment.

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Statement): Fix loop pattern detection
code. Fix typo.

24 hours agoi386: Fix memory constraint for APX NF
Lingling Kong [Fri, 2 Aug 2024 02:31:39 +0000 (10:31 +0800)]
i386: Fix memory constraint for APX NF

The je constraint should be used for APX NDD ADD with register source
operand. The jM is for APX NDD patterns with immediate operand.

gcc/ChangeLog:

* config/i386/i386.md (nf_mem_constraint): Fixed the constraint
for the define_subst_attr.
(nf_mem_constraint): Added new define_subst_attr.
(*add<mode>_1<nf_name>): Fixed the constraint.

25 hours agoLoongArch: Remove gawk extension from a generator script.
Yang Yujie [Tue, 23 Jul 2024 02:04:26 +0000 (10:04 +0800)]
LoongArch: Remove gawk extension from a generator script.

gcc/ChangeLog:

* config/loongarch/genopts/gen-evolution.awk: Do not use
"length()" to compute the size of an array.

26 hours agoaarch64: Improve Advanced SIMD popcount expansion by using SVE [PR113860]
Pengxuan Zheng [Thu, 1 Aug 2024 00:00:01 +0000 (17:00 -0700)]
aarch64: Improve Advanced SIMD popcount expansion by using SVE [PR113860]

This patch improves the Advanced SIMD popcount expansion by using SVE if
available.

For example, GCC currently generates the following code sequence for V2DI:
  cnt     v31.16b, v31.16b
  uaddlp  v31.8h, v31.16b
  uaddlp  v31.4s, v31.8h
  uaddlp  v31.2d, v31.4s

However, by using SVE, we can generate the following sequence instead:
  ptrue   p7.b, all
  cnt     z31.d, p7/m, z31.d

Similar improvements can be made for V4HI, V8HI, V2SI and V4SI too.

The scalar popcount expansion can also be improved similarly by using SVE and
those changes will be included in a separate patch.

PR target/113860

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (popcount<mode>2): Add TARGET_SVE
support.
* config/aarch64/aarch64-sve.md (@aarch64_pred_<optab><mode>): Use new
iterator SVE_VDQ_I.
* config/aarch64/iterators.md (SVE_VDQ_I): New mode iterator.
(VPRED): Add V8QI, V16QI, V4HI, V8HI and V2SI.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/popcnt-sve.c: New test.

Signed-off-by: Pengxuan Zheng <quic_pzheng@quicinc.com>
26 hours agotestsuite: Adjust fam-in-union-alone-in-struct-2.c to support BE [PR116148]
Kewen Lin [Fri, 2 Aug 2024 00:29:22 +0000 (19:29 -0500)]
testsuite: Adjust fam-in-union-alone-in-struct-2.c to support BE [PR116148]

As Andrew pointed out in PR116148, fam-in-union-alone-in-struct-2.c
was designed for little-endian, the recent commit r15-2403 made it
be tested with running on BE and PR116148 got exposed.

This patch is to adjust the expected data for members in with_fam_2_v
and with_fam_3_v by considering endianness, also update with_fam_3_v.b[1]
from 0x5f6f7f7f to 0x5f6f7f8f to avoid two "7f"s.

PR testsuite/116148

gcc/testsuite/ChangeLog:

* c-c++-common/fam-in-union-alone-in-struct-2.c: Define macros
WITH_FAM_2_V_B[03] and WITH_FAM_3_V_A[07] as endianness, update the
checking with these macros and initialize with_fam_3_v.b[1] with
0x5f6f7f8f instead of 0x5f6f7f7f.

27 hours agoDaily bump.
GCC Administrator [Fri, 2 Aug 2024 00:18:55 +0000 (00:18 +0000)]
Daily bump.

30 hours agolibstdc++: Remove unused helper traits
Jonathan Wakely [Sat, 23 Mar 2024 11:11:17 +0000 (11:11 +0000)]
libstdc++: Remove unused helper traits

These are not used anywhere, we have more efficient variable templates
for them instead. They're not documented as extensions, and are easy for
users to write if they need them.

libstdc++-v3/ChangeLog:

* include/bits/utility.h (__is_in_place_type): Remove.
* include/std/variant (__is_in_place_tag): Remove.

30 hours agolibstdc++: Remove unnecessary uses of <stdint.h>
Jonathan Wakely [Thu, 7 Dec 2023 12:13:59 +0000 (12:13 +0000)]
libstdc++: Remove unnecessary uses of <stdint.h>

We don't need to include all of <stdint.h> when we only need uintptr_t
from it. By using GCC's internal macro we avoid unnecessarily declaring
everything in <stdint.h>. This helps users to avoid accidentally relying
on those names being declared without explicitly including the header.

libstdc++-v3/ChangeLog:

* include/bits/align.h (align, assume_aligned): Use
__UINTPTR_TYPE__ instead of uintptr_t. Do not include
<stdint.h>.
* include/bits/atomic_base.h (__atomic_ref): Likewise.
* include/bits/atomic_wait.h (__waiter_pool_base::_S_for):
Likewise.
* include/std/atomic: Include <cstdint>.

30 hours agolibstdc++: Remove unused parameters from atomic impl details
Jonathan Wakely [Sat, 9 Mar 2024 00:19:11 +0000 (00:19 +0000)]
libstdc++: Remove unused parameters from atomic impl details

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (__atomic_impl::compare_exchange_weak):
Remove unused parameter.
(__atomic_impl::compare_exchange_strong): Likewise.

30 hours agolibstdc++: Use memcmp to optimize std::bitset::_M_is_equal() [PR113807]
Jonathan Wakely [Thu, 8 Feb 2024 15:46:08 +0000 (15:46 +0000)]
libstdc++: Use memcmp to optimize std::bitset::_M_is_equal() [PR113807]

As noted in the PR the compiler doesn't seem able to do this on its own,
so we get better code at all optimization levels by using memcmp.

libstdc++-v3/ChangeLog:

PR libstdc++/113807
* include/std/bitset (bitset::_M_is_equal()): Use memcmp to
optimize operator==.

30 hours agolibstdc++: Fix incomplete change to reduce iterations for simulators
Jonathan Wakely [Wed, 31 Jul 2024 21:15:40 +0000 (22:15 +0100)]
libstdc++: Fix incomplete change to reduce iterations for simulators

This should have been done as part of r13-693-ge3b8b4f7814c54, but I
only added the preprocessor logic and didn't use ARGS in the code.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/discrete_distribution/operators/values.cc:
Use ARGS to limit number of iterations for simulators.

30 hours agolibstdc++: Constrain std::basic_string default constructor [PR113841]
Jonathan Wakely [Thu, 7 Mar 2024 16:00:01 +0000 (16:00 +0000)]
libstdc++: Constrain std::basic_string default constructor [PR113841]

This is needed to avoid errors outside the immediate context when
evaluating is_default_constructible_v<basic_string<C, T, A>> when A is
not default constructible.

This change is not sufficient to solve the problem because there are a
large number of member functions which have a default argument that
constructs an allocator.

libstdc++-v3/ChangeLog:

PR libstdc++/113841
* include/bits/basic_string.h (basic_string::basic_string()):
Constrain so that it's only present if the allocator is default
constructible.
* include/bits/cow_string.h (basic_string::basic_string()):
Likewise.
* testsuite/21_strings/basic_string/cons/113841.cc: New test.

30 hours agolibstdc++: Remove noexcept from non-const std::basic_string::data() [PR99942]
Jonathan Wakely [Wed, 27 Mar 2024 11:07:17 +0000 (11:07 +0000)]
libstdc++: Remove noexcept from non-const std::basic_string::data() [PR99942]

The C++17 non-const overload of data() allows modifying the string
contents directly, so for the COW string we must do a copy-on-write to
unshare it. That means allocating, which can throw, so it shouldn't be
noexcept.

libstdc++-v3/ChangeLog:

PR libstdc++/99942
* include/bits/cow_string.h (data()): Change to noexcept(false).

31 hours agoRISC-V: Correct mode_idx attribute for viwalu wx variants [PR116149].
Robin Dapp [Wed, 31 Jul 2024 14:54:03 +0000 (16:54 +0200)]
RISC-V: Correct mode_idx attribute for viwalu wx variants [PR116149].

In PR116149 we choose a wrong vector length which causes wrong values in
a reduction.  The problem happens in avlprop where we choose the
number of units in the instruction's mode as vector length.  For the
non-scalar variants the respective operand has the correct non-widened
mode.  For the scalar variants, however, the same operand has a scalar
mode which obviously only has one unit.  This makes us choose VL = 1
leaving three elements undisturbed (so potentially -1).  Those end up
in the reduction causing the wrong result.

This patch adjusts the mode_idx just for the scalar variants of the
affected instruction patterns.

gcc/ChangeLog:

PR target/116149

* config/riscv/vector.md: Fix mode_idx attribute of scalar
widen add/sub variants.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr116149.c: New test.

32 hours agofortran: Fix up pasto in gfc_get_array_descr_info
Jakub Jelinek [Thu, 1 Aug 2024 18:23:15 +0000 (20:23 +0200)]
fortran: Fix up pasto in gfc_get_array_descr_info

A static analyzer found a pasto in gfc_get_array_descr_info.
The code does
      t = base_decl;
      if (!integer_zerop (dtype_off))
        t = fold_build_pointer_plus (t, dtype_off);
      dtype = TYPE_MAIN_VARIANT (get_dtype_type_node ());
      field = gfc_advance_chain (TYPE_FIELDS (dtype), GFC_DTYPE_RANK);
      rank_off = byte_position (field);
      if (!integer_zerop (dtype_off))
        t = fold_build_pointer_plus (t, rank_off);
i.e. uses the same !integer_zerop check between both, while it should
be checking rank_off in the latter case.
This actually doesn't change anything on the generated code, because
both the dtype_off and rank_off aren't zero,
typedef struct dtype_type
{
  size_t elem_len;
  int version;
  signed char rank;
  signed char type;
  signed short attribute;
}
dtype_type;
struct {
  type *base_addr;
  size_t offset;
  dtype_type dtype;
  index_type span;
  descriptor_dimension dim[];
};
dtype_off is 16 on 64-bit arches and 8 on 32-bit ones and rank_off is
12 on 64-bit arches and 8 on 32-bit arches, so this patch is just to
pacify those static analyzers or be prepared if the ABI changes in the
future.  Because in the current ABI both of those are actually non-zero,
doing
if (!integer_zerop (something)) t = fold_build_pointer_plus (t, something);
actually isn't an optimization, it will consume more compile time.  If
the ABI changes and we forget to readd it, nothing bad happens,
fold_build_pointer_plus handles 0 addends fine, just takes some compile
time to handle that.
I've kept this if (!integer_zerop (data_off)) guard earlier because
data_off is 0 in the current ABI, so it is an optimization there.

2024-08-01  Jakub Jelinek  <jakub@redhat.com>

* trans-types.cc (gfc_get_array_descr_info): Don't test if
!integer_zerop (dtype_off), use fold_build_pointer_plus
unconditionally.

32 hours agoRISC-V: Reject 'd' extension with ILP32E ABI
Patrick O'Neill [Tue, 30 Jul 2024 21:28:23 +0000 (14:28 -0700)]
RISC-V: Reject 'd' extension with ILP32E ABI

Also add a testcase for -mabi=lp64d where 'd' is required.

gcc/ChangeLog:

PR target/116111
* config/riscv/riscv.cc (riscv_option_override): Add error.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-41.c: New test.
* gcc.target/riscv/pr116111.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
34 hours agolibstdc++: Make dg-error pattern more accurate
Jonathan Wakely [Thu, 1 Aug 2024 04:53:03 +0000 (06:53 +0200)]
libstdc++: Make dg-error pattern more accurate

Remove useless test variable and use a more accurate dg-error pattern so
that only the ill-formed expression compilation error is considered.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/map/operators/1_neg.cc (test01): Remove test variable
and use 'no match' dg-error patter.
* testsuite/23_containers/set/operators/1_neg.cc (test01): Likewise.

34 hours agoc++: Fix up error recovery of invalid structured bindings used in conditions [PR116113]
Jakub Jelinek [Thu, 1 Aug 2024 16:49:39 +0000 (18:49 +0200)]
c++: Fix up error recovery of invalid structured bindings used in conditions [PR116113]

The following testcase ICEs, because for structured binding error recovery
DECL_DECOMP_BASE is kept NULL and the newly added code to pick up saved
value from the base assumes that on structured binding bases the
TARGET_EXPR will be always there (that is the case if there are no errors).

The following patch fixes it by testing DECL_DECOMP_BASE before
dereferencing it, another option would be not to do that if
error_operand_p (cond).

2024-08-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/116113
* semantics.cc (maybe_convert_cond): Check DECL_DECOMP_BASE
is non-NULL before dereferencing it.
(finish_switch_cond): Likewise.

* g++.dg/cpp26/decomp11.C: New test.

35 hours agoAArch64: Add Cortex-X925 core definition and cost model
Tamar Christina [Thu, 1 Aug 2024 15:55:10 +0000 (16:55 +0100)]
AArch64: Add Cortex-X925 core definition and cost model

This adds a cost model and core definition for Cortex-X925.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (cortex-x925): New.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/tuning_models/cortexx925.h: New file.
* config/aarch64/aarch64.cc: Use it.
* doc/invoke.texi: Document it.

35 hours agoAArch64: Update Neoverse N2 cost model to release costs
Tamar Christina [Thu, 1 Aug 2024 15:54:49 +0000 (16:54 +0100)]
AArch64: Update Neoverse N2 cost model to release costs

This updates the cost for Neoverse N2 to reflect the updated
Software Optimization Guide.

gcc/ChangeLog:

* config/aarch64/tuning_models/neoversen2.h: Update costs.

35 hours agoAArch64: Update Generic Armv9-a cost model to release costs
Tamar Christina [Thu, 1 Aug 2024 15:54:31 +0000 (16:54 +0100)]
AArch64: Update Generic Armv9-a cost model to release costs

this updates the costs for gener-armv9-a based on the updated costs for
Neoverse V2 and Neoverse N2.

gcc/ChangeLog:

* config/aarch64/tuning_models/generic_armv9_a.h: Update costs.

35 hours agoAArch64: Add Neoverse N3 and Cortex-A725 core definition and cost model
Tamar Christina [Thu, 1 Aug 2024 15:54:15 +0000 (16:54 +0100)]
AArch64: Add Neoverse N3 and Cortex-A725 core definition and cost model

This adds a cost model and core definition for Neoverse N3 and Cortex-A725.

It also makes Cortex-A725 use the Neoverse N3 cost model.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (neoverse-n3, cortex-a725): New.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/tuning_models/neoversen3.h: New file.
* config/aarch64/aarch64.cc: Use it.
* doc/invoke.texi: Document it.

35 hours agoAArch64: Add Neoverse V3AE core definition and cost model
Tamar Christina [Thu, 1 Aug 2024 15:53:59 +0000 (16:53 +0100)]
AArch64: Add Neoverse V3AE core definition and cost model

This adds a cost model and core definition for Neoverse V3AE.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (neoverse-v3ae): New.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/tuning_models/neoversev3ae.h: New file.
* config/aarch64/aarch64.cc: Use it.
* doc/invoke.texi: Document it.

35 hours agoAArch64: Add Neoverse V3 core definition and cost model
Tamar Christina [Thu, 1 Aug 2024 15:53:41 +0000 (16:53 +0100)]
AArch64: Add Neoverse V3 core definition and cost model

This adds a cost model and core definition for Neoverse V3.

It also makes Cortex-X4 use the Neoverse V3 cost model.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (cortex-x4): Update.
(neoverse-v3): New.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/tuning_models/neoversev3.h: New file.
* config/aarch64/aarch64.cc: Use it.
* doc/invoke.texi: Document it.

35 hours agoAArch64: Update Neoverse V2 cost model to release costs
Tamar Christina [Thu, 1 Aug 2024 15:53:22 +0000 (16:53 +0100)]
AArch64: Update Neoverse V2 cost model to release costs

This updates the cost for Neoverse V2 to reflect the updated
Software Optimization Guide.

It also makes Cortex-X3 use the Neoverse V2 cost model.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (cortex-x3): Use Neoverse-V2 costs.
* config/aarch64/tuning_models/neoversev2.h: Update costs.

36 hours agomatch: Fix wrong code due to `(a ? e : f) !=/== (b ? e : f)` patterns [PR116120]
Andrew Pinski [Mon, 29 Jul 2024 21:00:13 +0000 (14:00 -0700)]
match: Fix wrong code due to `(a ? e : f) !=/== (b ? e : f)` patterns [PR116120]

When this pattern was converted from being only dealing with 0/-1, we missed that if `e == f` is true
then the optimization is wrong and needs an extra check for that.

This changes the patterns to be:
/* (a ? x : y) != (b ? x : y) --> (a^b & (x != y)) ? TRUE  : FALSE */
/* (a ? x : y) == (b ? x : y) --> (a^b & (x != y)) ? FALSE : TRUE  */
/* (a ? x : y) != (b ? y : x) --> (a^b | (x == y)) ? FALSE : TRUE  */
/* (a ? x : y) == (b ? y : x) --> (a^b | (x == y)) ? TRUE  : FALSE */

Also this can't be done if the X can be a NaNs either. Since that changes the value there too.

This still produces better code than the original case and in many cases (x != y) will
still reduce to either false or true.

With this change we also need to make sure `a`, `b` and the resulting types are all
the same for the same reason as the previous patch.

I updated (well added) to the testcases to make sure there are the right amount of
comparisons left.

Changes since v1:
* v2: Fixed the testcase names and fixed dg-run to be `dg-do run`. Added a check for HONORS_NANS too.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/116120

gcc/ChangeLog:

* match.pd (`(a ? x : y) eq/ne (b ? x : y)`): Add test for `x != y`
in result.
(`(a ? x : y) eq/ne (b ? y : x)`): Add test for `x == y` in result.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr111150.C: Add extra checks on the test.
* gcc.dg/tree-ssa/pr111150-1.c: Likewise.
* gcc.dg/tree-ssa/pr111150.c: Likewise.
* g++.dg/torture/pr116120-1.C: New test.
* g++.dg/torture/pr116120-2.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
36 hours agoada: Fix computation of new size when reallocating unbounded string
Yannick Moy [Wed, 3 Jul 2024 13:23:34 +0000 (15:23 +0200)]
ada: Fix computation of new size when reallocating unbounded string

The procedure Realloc_For_Chunk which is used to reallocate an unbounded
string when needed may lead in theory to an overflow, due to the use of
variable S_Length denoting the current allocated length instead of
Source.Last denoting the current string length. Now fixed.

This has no effect in practice since the only targets that use this
version of Ada.Strings.Unbounded do not have enough memory to make it
possible to have an overflow here.

gcc/ada/

* libgnat/a-strunb.adb (Realloc_For_Chunk): Fix computation of new
size.

36 hours agoada: Update contracts on Strings libraries
Yannick Moy [Fri, 28 Jun 2024 15:31:19 +0000 (17:31 +0200)]
ada: Update contracts on Strings libraries

The contracts of Ada.Strings.Bounded.To_String and
Ada.Strings.Fixed.Delete are updated to reflect the standard spec and to
allow proof of callers.

gcc/ada/

* libgnat/a-strbou.ads (To_String): Add a postcondition to state
the value of bounds of the returned string, which helps with proof
of callers.
* libgnat/a-strfix.adb (Delete): Fix implementation to produce
correct result in all cases. For example, returned string should
always have a lower bound of 1, which was not respected in one
case. This was not detected by proof, since this code was dead
according to the too strict precondition.
* libgnat/a-strfix.ads (Delete): State the correct precondition
from standard which allows a value of Through beyond the last
valid index, and also restricts values of From from below. Update
the Contract_Cases accordingly to allow new values of parameters.

36 hours agoada: Accept duplicate SPARK_Mode pragmas in configuration files
Piotr Trojanek [Tue, 2 Jul 2024 13:19:41 +0000 (15:19 +0200)]
ada: Accept duplicate SPARK_Mode pragmas in configuration files

For consistency, we now accept duplicate SPARK_Mode pragmas in
configuration files just like we accept other duplicate pragas there.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Don't check for duplicate
SPARK_Mode pragmas in configuration files.

36 hours agoada: Crash on access attribute with overloaded prefix denoting reference object
Gary Dismukes [Tue, 2 Jul 2024 00:42:12 +0000 (00:42 +0000)]
ada: Crash on access attribute with overloaded prefix denoting reference object

The compiler fails to accept an access attribute where the prefix is the name
of an object of a user-defined reference type, and is not prepared to deal
with the possibility of overloaded prefixes other than subprogram cases.
Such a prefix can either represent the reference object directly, or it
can be interpreted as an implicit dereferencing of the object's reference
value, depending on the expected type.  Special handling for this kind of
prefix is added alongside the normal handling for overloaded prefixes of
access attributes.

gcc/ada/

* sem_attr.adb (Resolve_Attribute, Attribute_*Access): Resolve
overloaded prefixes that denote objects of reference types,
determining whether to use the prefix object directly, or expand
it as an explicit dereference.

36 hours agoada: Fix oversight in documentation of At_End_Proc
Eric Botcazou [Tue, 2 Jul 2024 17:16:45 +0000 (19:16 +0200)]
ada: Fix oversight in documentation of At_End_Proc

It is documented for N_Subprogram_Body_Stub instead of N_Subprogram_Body.

gcc/ada/

* sinfo.ads (N_Block_Statement): Move At_End_Proc to the end of
slot list and alphabetize flag list.
(N_Subprogram_Body): Add At_End_Proc.
(N_Package_Body): Move At_End_Proc to the end of slot list.
(N_Subprogram_Body_Stub): Remove At_End_Proc.

36 hours agoada: Deconstruct workarounds for quantified expressions in contracts
Piotr Trojanek [Tue, 2 Jul 2024 09:24:56 +0000 (11:24 +0200)]
ada: Deconstruct workarounds for quantified expressions in contracts

Apparently we can always safely set the type of a loop parameter from
its discrete subtype definition. It looks like the conditional setting
was only necessary when preconditions were expanded into dedicated
procedures, but we no longer use this expansion.

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Parameter_Specification):
Unconditionally set the type of loop parameter.

36 hours agoada: Style fixes: remove blank lines following 'begin' keywords
Ghjuvan Lacambre [Tue, 2 Jul 2024 09:26:19 +0000 (11:26 +0200)]
ada: Style fixes: remove blank lines following 'begin' keywords

The GNAT style guide specifies that there must not be blank lines after
'begin' keywords.

gcc/ada/

* backend_utils.adb (Scan_Common_Back_End_Switch): Remove blank
line.
* errout.adb (Output_JSON_Message): Likewise.
* erroutc.adb (Set_Msg_Char): Likewise.
* exp_aggr.adb (Two_Dim_Packed_Array_Handled): Likewise.
* exp_pakd.adb (Expand_Packed_Address_Reference): Likewise.
(Expand_Packed_Bit_Reference): Likewise.
(Expand_Packed_Boolean_Operator): Likewise.
(Expand_Packed_Element_Reference): Likewise.
(Expand_Packed_Eq): Likewise.
(Expand_Packed_Not): Likewise.
* exp_prag.adb (Build_Dim3_Declaration): Likewise.
* exp_strm.adb (Build_Elementary_Input_Call): Likewise.
* freeze.adb (Find_Aspect_No_Parts): Likewise.
(Get_Aspect_No_Parts_Value): Likewise.
* gen_il-gen.adb (Compile): Likewise.
* gnat1drv.adb (Adjust_Global_Switches): Likewise.
* gnat_cuda.adb (Expand_CUDA_Package): Likewise.
* gnatchop.adb (Read_File): Likewise.
* gnatls.adb (Get_Runtime_Path): Likewise.
* make.adb (Binding_Phase): Likewise.
* par-ch11.adb (P_Exception_Choice): Likewise.
* par-ch5.adb (P_Loop_Parameter_Specification): Likewise.
* par-ch6.adb (Is_Extended): Likewise.
* sem_attr.adb (Check_Dereference): Likewise.
* sem_ch12.adb (Build_Subprogram_Decl_Wrapper): Likewise.
* sem_ch3.adb (Build_Itype_Reference): Likewise.
* sem_prag.adb (Validate_Compile_Time_Warning_Errors): Likewise.
* sem_res.adb (Resolve_Declare_Expression): Likewise.
* sem_util.adb (Build_Default_Subtype): Likewise.
* sprint.adb (Sprint_Paren_Comma_List): Likewise.

36 hours agoada: Restrict string interpolation to single string literal
Javier Miranda [Fri, 28 Jun 2024 21:46:12 +0000 (21:46 +0000)]
ada: Restrict string interpolation to single string literal

gcc/ada/

* par-ch2.adb (P_Interpolated_String_Literal): remove support of
multi-line string literals.
* doc/gnat_rm/gnat_language_extensions.rst: Update documentation.
* gnat_rm.texi: Regenerate.

36 hours agoada: Use ?j? in Output_Obsolescent_Entity_Warnings messages
Viljar Indus [Mon, 1 Jul 2024 09:45:26 +0000 (12:45 +0300)]
ada: Use ?j? in Output_Obsolescent_Entity_Warnings messages

These messages are conditionally activated only when
-gnatwj (Warn_On_Obsolescent_Feature) is activated. They
should use the switch specific insertion character instead.

gcc/ada/

* sem_warn.adb (Output_Obsolescent_Entity_Warnings): use the ?j?
in warning messages.

36 hours agoada: Fix crash in quantified expression expansion
Ronan Desplanques [Mon, 1 Jul 2024 08:16:27 +0000 (10:16 +0200)]
ada: Fix crash in quantified expression expansion

Before this patch, the compiler failed to handle the case where the for loop
created by expansion of a quantified expression required cleanup handlers.

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Fix test for
expanded quantified expression context.
(Is_Expanded_Quantified_Expr): New function.

36 hours agoada: Fix bug in resolution of Ghost_Predicate
Bob Duff [Mon, 1 Jul 2024 13:23:17 +0000 (09:23 -0400)]
ada: Fix bug in resolution of Ghost_Predicate

This patch fixes a failure of name resolution when
a range attribute reference appears in a Ghost_Predicate
and the ghost policy is Ignore.

gcc/ada/

* sem_ch13.adb (Add_Predicate): Remove the premature "return;".
Ghost code needs to be processed by later code in this procedure
even when ignored; otherwise the second pass of name resolution
fails much later. However, protect Set_SCO_Pragma_Enabled and
Add_Condition with "if not Is_Ignored_Ghost_Pragma"; these parts
should not happen if the ghost code is Ignored.
* libgnat/interfac__2020.ads (Unsigned_8): Minor reformatting.
* libgnat/interfac.ads (IEEE_Extended_Float): Minor comment
improvement.

36 hours agoada: Define No_Return flag only for subprograms
Eric Botcazou [Mon, 1 Jul 2024 08:25:07 +0000 (10:25 +0200)]
ada: Define No_Return flag only for subprograms

...instead of defining it for all entities.

gcc/ada/

* einfo.ads (No_Return): Change description and adjust
accordingly.
* gen_il-gen-gen_entities.adb (Entity_Kind): Remove No_Return.
(Subprogram_Kind): Add No_Return.
(Generic_Subprogram_Kind): Likewise.
* sem_ch6.adb (Analyze_Return_Statement): Adjust No_Return test.

36 hours agoada: Implement full relaxed finalization semantics for controlled objects
Eric Botcazou [Wed, 26 Jun 2024 16:09:18 +0000 (18:09 +0200)]
ada: Implement full relaxed finalization semantics for controlled objects

These semantics state that the compiler is permitted to enforce none of
the guarantees specified by the RM 7.6.1(14/1) and following subclauses,
and to instead just let the exception be propagated upward.

The guarantees impose a significant overhead in terms of complexity and
run-time performance compared to similar constructs in other languages,
and the goal is to reduce it significantly, if not eliminate it totally:
for example, untagged record types declared with the Finalizable aspect,
the relaxed finalization semantics and inline Initialize/Adjust/Finalize
primitives, and used with abort disabled:

  pragma Restrictions (No_Abort_Statements);
  pragma Restrictions (Max_Asynchronous_Select_Nesting => 0);
  pragma Restrictions (No_Asynchronous_Control);

should behave like simple C++ classes.

The implementation morally boils down to undoing the changes made a few
months ago to the support of finalization for controlled objects, i.e.
to getting rid of the added linked list and the associated indirection
for controlled objects with relaxed finalization semantics.

But, in order to keep a unified processing for both kinds of controlled
objects and not to bring back the issues addressed by the aforementioned
changes, the work is split between the front-end and the code generator:
the front-end drops the linked list and the code generator is in charge
of eliminating the indirection with the help of the optimizer.

gcc/ada/

* doc/gnat_rm/gnat_language_extensions.rst (Generalized
Finalization): Update status.
* einfo.ads (Has_Relaxed_Finalization): Add more details.
* exp_ch4.adb (Process_Transients_In_Expression): Invoke
Make_Finalize_Call_For_Node instead of building the call.
* exp_ch5.adb (Expand_N_Assignment_Statement): Do not set up an
exception handler around the assignment for a controlled type with
relaxed finalization semantics. Streamline the code implementing
the protection against aborts and do not use an At_End handler for
a controlled type with relaxed finalization semantics.
* exp_ch7.ads (Make_Finalize_Call_For_Node): New function.
* exp_ch7.adb (Finalize_Address_For_Node): New function renaming.
(Set_Finalize_Address_For_Node): New procedure renaming.
(Attach_Object_To_Master_Node): Also attach the Finalize_Address
primitive to the Master_Node statically.
(Build_Finalizer): Add Has_Strict_Ctrl_Objs local variable. Insert
back the body of the finalizer at the end of the statement list in
the non-package case and restore the associated support code to
that effect. When all the controlled objects have the relaxed
finalization semantics, do not create a Finalization_Master and
finalize the objects directly instead.
(Processing_Actions): Add Strict parameter and use it to set the
Has_Strict_Ctrl_Objs variable.
(Process_Declarations): Make main loop more robust and adjust
calls to Processing_Actions.
(Make_Finalize_Address_Body): Mark the primitive as inlined if the
type has relaxed finalization semantics.
(Make_Finalize_Call_For_Node): New function.
* sem_ch6.adb (Check_Statement_Sequence): Skip subprogram bodies.
* libgnat/s-finpri.ads (Finalize_Object): Add Finalize_Address
parameter.
(Master_Node): Remove superfluous qualification.
* libgnat/s-finpri.adb (Attach_Object_To_Node): Likewise.
(Finalize_Master): Adjust calls to Finalize_Object.
(Finalize_Object): Add Finalize_Address parameter and assert that
it is equal to the component of the node. Use the Object_Address
component as guard.
(Suppress_Object_Finalize_At_End): Clear Object_Address component.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

36 hours agoada: Put back -G for binder
Arnaud Charlet [Fri, 28 Jun 2024 08:35:25 +0000 (08:35 +0000)]
ada: Put back -G for binder

gcc/ada/

* bindgen.adb (Gen_Main): Put back support for -G
* bindusg.adb (Display): Put back line for -G
* opt.ads (CCG_Mode): Update doc
* switch-b.adb (Scan_Binder_Switches): Put back support for -G

36 hours agoada: exp_pakd.adb: disable packed expansions in CodePeer_Mode
Ghjuvan Lacambre [Fri, 28 Jun 2024 08:13:17 +0000 (10:13 +0200)]
ada: exp_pakd.adb: disable packed expansions in CodePeer_Mode

A previous commit disabled the removal of the Component_Size aspect from
GNAT's tree when in CodePeer_Mode. This effectively resulted in CodePeer
not ignoring Component_Size anymore. As a side effect, GNAT started
expanding packed operations on array types from their high-level
representations to operations operating on bits. It wasn't caught during
the original testing, but this actually confuses CodePeer. We thus need
to disable expansion of packed operations while in CodePeer_Mode.

gcc/ada/

* exp_pakd.adb (Expand_Bit_Packed_Element_Set): Disable expansion
in CodePeerMode.
(Expand_Packed_Address_Reference): Likewise.
(Expand_Packed_Bit_Reference): Likewise.
(Expand_Packed_Boolean_Operator): Likewise.
(Expand_Packed_Element_Reference): Likewise.
(Expand_Packed_Eq): Likewise.
(Expand_Packed_Not): Likewise.

36 hours agoada: Check default value aspects before resolving their expressions
Piotr Trojanek [Mon, 24 Jun 2024 13:25:06 +0000 (15:25 +0200)]
ada: Check default value aspects before resolving their expressions

Check expressions of aspects Default_Value and Default_Component_Value
for references to the annotated types just before resolving these
expressions.

This patch fixes both an asymmetry in processing of those aspects and
adds a missing check in GNATprove on aspect Default_Component_Value.

gcc/ada/

* sem_ch13.adb (Check_Aspect_Too_Late): Move routine to top-level.
(Resolve_Aspect_Expressions): Check aspects Default_Value and
Default_Component_Value before resolving their expressions.

36 hours agoada: Fix freezing of Default_Value expressions
Piotr Trojanek [Mon, 24 Jun 2024 11:07:13 +0000 (13:07 +0200)]
ada: Fix freezing of Default_Value expressions

This patch fixes an infinite loop in freezing that occurred when
expression of the Default_Value aspect includes a declare expression
with an object of the annotated type.

gcc/ada/

* sem_ch13.adb (Check_Aspect_Too_Late): Prevent freezing during
preanalysis.

36 hours agoada: Remove Must_Not_Freeze flags from default value expressions
Piotr Trojanek [Fri, 21 Jun 2024 13:27:41 +0000 (15:27 +0200)]
ada: Remove Must_Not_Freeze flags from default value expressions

This is a code cleanup and apparently has no impact on the behavior.

The Must_Not_Freeze is saved/set/restored by Preanalyze_Spec_Expression,
so it doesn't need to be set before calling that routine and apparently
doesn't need to be set after that calling that routine either.

gcc/ada/

* sem_ch13.adb (Resolve_Aspect_Expression): Don't set
Must_Not_Freeze before preanalyzing spec expressions.

36 hours agoada: Change "missing overriding indicator" message from error to warning
Steve Baird [Wed, 26 Jun 2024 20:50:48 +0000 (13:50 -0700)]
ada: Change "missing overriding indicator" message from error to warning

There is no RM rule requiring an overriding indicator in the case where
this message is generated; such a rule was discussed many years ago in an
AI, but that AI was never approved. So generate a warning message instead
of an error message. And don't even do that if we are in an instance (warning
a user they should change the source of an instance seems unlikely to be
helpful, at least in this case).

gcc/ada/

* sem_disp.adb (Check_Dispatching_Operation): When calling
Error_Msg_NE to generate a "missing overriding indicator" message,
generate a warning message instead of an error message (and update
comment to describe this new behavior).

36 hours agoada: Miscomputed bounds for inner null array aggregates
Javier Miranda [Mon, 24 Jun 2024 11:29:57 +0000 (11:29 +0000)]
ada: Miscomputed bounds for inner null array aggregates

gcc/ada/

* sem_aggr.adb (Collect_Aggr_Bounds): Adjust previous patch to
store the bounds of inner null aggregates in the itype; required
generate the runtime check of ARM 4.3.3(30).

36 hours agoada: Followup on previous change for -gnatceg
Arnaud Charlet [Thu, 27 Jun 2024 09:59:27 +0000 (09:59 +0000)]
ada: Followup on previous change for -gnatceg

gcc/ada/

* osint-c.ads, osint-c.adb (Create_C_File, Close_C_File,
Delete_C_File): Put back, needed by LLVM based CCG.
* exp_unst.adb (Unnest_Subprogram): Complete previous change by
removing now dead code and corresponding ??? comment.

36 hours agoada: Missing adjust of controlled component initialized from container aggregate
Gary Dismukes [Wed, 26 Jun 2024 22:00:49 +0000 (22:00 +0000)]
ada: Missing adjust of controlled component initialized from container aggregate

In the case of controlled components initialized by a container aggregate,
the compiler was suppressing the call to the needed Adjust operation,
because it was suppressed for all aggregates. But container aggregates
aren't built in place, so target adjustment should still be done in that
case.

gcc/ada/

* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do the
component adjustment in the case of initialization by a container
aggregate.

36 hours agoada: Fix internal error on limited aggregate in nested conditional expression
Eric Botcazou [Wed, 26 Jun 2024 17:55:44 +0000 (19:55 +0200)]
ada: Fix internal error on limited aggregate in nested conditional expression

This is a fallout of an earlier fix to Is_Build_In_Place_Aggregate_Return
that made it take into account intermediate conditional expressions, but
turned out to work only for a single nesting level of them.

The fix reuses the delayed expansion mechanism recently extended to deal
with conditional expressions in a straightforward way.

gcc/ada/

* exp_aggr.adb (Convert_To_Assignments): Set Expansion_Delayed on
intermediate conditional expressions for BIP aggregate returns
too.
* exp_ch4.adb (Expand_N_Case_Expression): Also deal with delayed
expansion in the return case.
(Expand_N_If_Expression): Likewise.

36 hours agoada: Operator visibility bug in static expression functions
Steve Baird [Mon, 24 Jun 2024 18:57:59 +0000 (11:57 -0700)]
ada: Operator visibility bug in static expression functions

In some cases, an expanded name refering to a predefined operator (such as
Some_Package."+") occurring in a static expression function would be
incorrectly rejected with a message saying that the operator is not directly
visible (which, while True, does not make the reference illegal).

gcc/ada/

* sem_ch4.adb (Is_Effectively_Visible_Opertor): Return True if
Checking_Potentially_Static_Expression is True. The accompanying
comment says True is returned "if there is a reason it is ok for
Is_Visible_Operator to return False"; if
Checking_Potentially_Static_Expression is true, that is such a
reason.

36 hours agoada: Stop ignoring Component_Size attribute in CodePeer_Mode
Ghjuvan Lacambre [Wed, 26 Jun 2024 14:08:20 +0000 (16:08 +0200)]
ada: Stop ignoring Component_Size attribute in CodePeer_Mode

This piece of code was introduced in 2011 in order to prevent spurious
false positives from appearing on specific code patterns making use of
Component_Size.
It seems that now this piece of code is causing small false positives
instead of preventing them, so let's remove it.

gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Stop
ignoring Component_Size attribute in CodePeer_Mode.

36 hours agoada: Fix test for wrapping loop parameter spec
Ronan Desplanques [Mon, 17 Jun 2024 15:55:51 +0000 (17:55 +0200)]
ada: Fix test for wrapping loop parameter spec

This patches fixes a problem where cleanup statements would be
missing for some cases of loop parameter specifications that allocate
on the secondary stack.

gcc/ada/

* sem_ch5.adb (Prepare_Param_Spec_Loop): Fix criterion for
wrapping loop statements into blocks.

36 hours agoada: Remove support for bodies in -gnatceg
Arnaud Charlet [Thu, 13 Jun 2024 07:20:49 +0000 (07:20 +0000)]
ada: Remove support for bodies in -gnatceg

The support for generating C for Ada code is moved to GNAT LLVM.
Keep support for generating header files from Ada spec files which
is the remaining usage of -gnatceg.

gcc/ada/

* bindgen.adb, bindusg.adb, debug.adb, einfo.ads,
exp_aggr.adb, exp_attr.adb, exp_ch11.adb, exp_ch3.adb,
exp_ch4.adb, exp_ch6.adb, exp_ch7.adb, exp_ch8.adb, exp_dbug.adb,
exp_dbug.ads, exp_intr.adb, exp_unst.adb, exp_util.adb,
exp_util.ads, freeze.adb, gen_il-fields.ads,
gen_il-gen-gen_entities.adb, gnat1drv.adb, inline.adb, opt.ads,
osint-c.adb, osint-c.ads, sem_attr.adb, sem_ch12.adb, sem_ch3.adb,
sem_ch4.adb, sem_ch6.adb, sem_elab.adb, sem_res.adb, sinfo.ads,
snames.ads-tmpl, switch-b.adb, switch-c.adb: Major
clean up to remove C code generation for bodies.

36 hours agoada: Allow making empty aggregates positional
Ronan Desplanques [Wed, 19 Jun 2024 07:26:35 +0000 (09:26 +0200)]
ada: Allow making empty aggregates positional

This patch makes Exp_Aggr.Convert_To_Positional accepts appropriate
empty aggregates. The end goal is to remove violations of the
No_Elaboration_Code restriction in some cases of library-level array
objects.

gcc/ada/

* exp_aggr.adb (Flatten): Do not reject empty aggregates. Adjust
criterion for emitting warning about ineffective others clause.
* sem_aggr.adb (Array_Aggr_Subtype): Fix typo. Add handling of
aggregates that were converted to positional form.
(Resolve_Aggregate): Tweak criterion for transforming into a
string literal.
(Resolve_Array_Aggregate): Tweak criterion for reusing existing
bounds of aggregate.
(Retrieve_Aggregate_Bounds): New procedure.
* sem_util.adb (Has_Static_Empty_Array_Bounds): New function.
* sem_util.ads (Has_Static_Empty_Array_Bounds): Likewise.

36 hours agoada: Couple of cleanups in finalization machinery
Eric Botcazou [Mon, 24 Jun 2024 12:46:21 +0000 (14:46 +0200)]
ada: Couple of cleanups in finalization machinery

This removes a parameter and a variable that are entirely determined by
another parameter and another variable respectively.

gcc/ada/

* exp_ch7.ads (Build_Finalizer): Remove Top_Decls parameter.
* exp_ch7.adb (Build_Finalizer): Likewise. Rename Counter_Val into
Count, replace Has_Ctrl_Objs local variable by expression
function, remove Spec_Decls local variable and do not reset
Finalizer_Decls.
(Expand_Cleanup_Actions): Adjust call to Build_Finalizer.
(Expand_N_Package_Body): Likewise.
(Expand_N_Package_Declaration): Likewise.
* inline.adb (Cleanup_Scopes): Likewise.

36 hours agoada: Remove obsolete workaround
Eric Botcazou [Fri, 21 Jun 2024 21:01:11 +0000 (23:01 +0200)]
ada: Remove obsolete workaround

It is possible to call the "+" operator of System.Storage_Elements directly
as done for example in Expand_Interface_Thunk.

gcc/ada/

* exp_ch7.adb (Make_Address_For_Finalize): Generate a direct call
to the "+" operator of System.Storage_Elements.
(Make_Finalize_Address_Stmts): Likewise.
* rtsfind.ads (RE_Id): Remove RE_Add_Offset_To_Address.
(RE_Unit_Table): Remove entry for RE_Add_Offset_To_Address.
* libgnat/s-finpri.ads (Add_Offset_To_Address): Delete.
* libgnat/s-finpri.adb (Add_Offset_To_Address): Likewise.

36 hours agotestsuite: Add filters for default_packed targets [PR116155]
Dimitar Dimitrov [Tue, 30 Jul 2024 20:08:38 +0000 (23:08 +0300)]
testsuite: Add filters for default_packed targets [PR116155]

A few recent C++ test cases are assuming non-zero structure field
padding.  Consequently they fail for targets defaulting to packed
structure layout.  Fix by adding the necessary DejaGnu filters.

There are no test result changes for x86_64-pc-linux-gnu:
  $ dg-cmp-results.sh -v -v "" pre-g++.sum post-g++.sum
  -> No differences.

The tests for pru-unknown-elf changed from FAIL to UNSUPPORTED.

PR testsuite/116155

gcc/testsuite/ChangeLog:

* g++.dg/abi/nsdmi-aggr1a.C: Disable test for effective
default_packed targets.
* g++.dg/abi/nullptr-align2.C: Ignore warning for default_packed
targets.
* g++.dg/cpp1z/aligned-new9.C: Disable test for effective
default_packed targets.
* g++.dg/cpp2a/bit-cast5.C: Ignore dg-error for default_packed
targets.
* g++.dg/pr53037-1.C: Match any default packing value.
* g++.dg/warn/Wpadded-1.C: Ignore warning for default_packed
targets.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
36 hours agogccrs: Add a test for inherent impl type name resolve
Pierre-Emmanuel Patry [Thu, 18 Apr 2024 20:39:47 +0000 (22:39 +0200)]
gccrs: Add a test for inherent impl type name resolve

A previous bug with name resolution 2.0 was caused by an incorrectly
resolved inherent impl name. This test shall highlight the behavior
and prevent regression.

gcc/testsuite/ChangeLog:

* rust/compile/name_resolution25.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
This page took 0.111034 seconds and 5 git commands to generate.