]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
21 months agoFortran: Free alloc. comp. in allocated coarrays only.
Andre Vehreschild [Thu, 28 Sep 2023 07:30:12 +0000 (09:30 +0200)] 
Fortran: Free alloc. comp. in allocated coarrays only.

When freeing allocatable components of an allocatable coarray, add
a check that the coarray is still allocated, before accessing the
components.

This patch adds to PR fortran/37336, but does not fix it completely.

gcc/fortran/ChangeLog:
PR fortran/37336
* trans-array.cc (structure_alloc_comps): Deref coarray.
(gfc_trans_deferred_array): Add freeing of components after
check for allocated coarray.

gcc/testsuite/ChangeLog:
PR fortran/37336
* gfortran.dg/coarray/alloc_comp_6.f90: New test.
* gfortran.dg/coarray/alloc_comp_7.f90: New test.

(cherry picked from commit 9a63a62dfd73e159f1956e9b04b555c445de4e78)

21 months agoAArch64: List official cores before codenames
Wilco Dijkstra [Wed, 13 Sep 2023 12:16:14 +0000 (13:16 +0100)] 
AArch64: List official cores before codenames

List official cores first so that -mcpu=native does not show a codename with
-v or in errors/warnings.

gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (neoverse-n1): Place before ares.
(neoverse-v1): Place before zeus.
(neoverse-v2): Place before demeter.
* config/aarch64/aarch64-tune.md: Regenerate.

(cherry picked from commit 64d5bc35c8c2a66ac133a3e6ace820b0ad8a63fb)

21 months agoAArch64: Fix memmove operand corruption [PR111121]
Wilco Dijkstra [Tue, 26 Sep 2023 15:42:45 +0000 (16:42 +0100)] 
AArch64: Fix memmove operand corruption [PR111121]

A MOPS memmove may corrupt registers since there is no copy of the input
operands to temporary registers.  Fix this by calling
aarch64_expand_cpymem_mops.

Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>
gcc/ChangeLog/
PR target/111121
* config/aarch64/aarch64.md (aarch64_movmemdi): Add new expander.
(movmemdi): Call aarch64_expand_cpymem_mops for correct expansion.
* config/aarch64/aarch64.cc (aarch64_expand_cpymem_mops): Add support
for memmove.
* config/aarch64/aarch64-protos.h (aarch64_expand_cpymem_mops): Add new
function.

gcc/testsuite/ChangeLog/
PR target/111121
* gcc.target/aarch64/mops_4.c: Add memmove testcases.

(cherry picked from commit d8b56c95782aeeee79ec40932ca88d00fd9f2ee2)

21 months agoDaily bump.
GCC Administrator [Fri, 29 Sep 2023 00:21:32 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Thu, 28 Sep 2023 09:54:02 +0000 (09:54 +0000)] 
Daily bump.

21 months agolibstdc++: Add test for illegal pointer arithmetic in format [PR111102]
Paul Dreik [Thu, 24 Aug 2023 10:43:43 +0000 (11:43 +0100)] 
libstdc++: Add test for illegal pointer arithmetic in format [PR111102]

libstdc++-v3/ChangeLog:

PR libstdc++/111102
* testsuite/std/format/string.cc: Check wide character format
strings with out-of-range widths.

(cherry picked from commit 7564fe98657ad5ede34bd08f5279778fa8698865)

21 months agolibstdc++: [_GLIBCXX_INLINE_VERSION] Fix <format> friend declaration
François Dumont [Wed, 23 Aug 2023 17:15:43 +0000 (19:15 +0200)] 
libstdc++: [_GLIBCXX_INLINE_VERSION] Fix <format> friend declaration

GCC do not consider the inline namespace in friend function declarations.
This is PR c++/59526, we need to explicit this namespace.

libstdc++-v3/ChangeLog:

* include/std/format (std::__format::_Arg_store): Explicit version
namespace on make_format_args friend declaration.

(cherry picked from commit 92456291849fe88303bbcab366f41dcd4a885ad5)

21 months agolibstdc++: fix illegal pointer arithmetic in format [PR111102]
Paul Dreik [Thu, 24 Aug 2023 10:43:43 +0000 (11:43 +0100)] 
libstdc++: fix illegal pointer arithmetic in format [PR111102]

When parsing a format string, the width is parsed into an unsigned short
but the result is not checked in the case the format string is not a
char string (such as a wide string). In case the parse fails, a null
pointer is returned which is used for pointer arithmetic which is
undefined behaviour.

Signed-off-by: Paul Dreik <gccpatches@pauldreik.se>
libstdc++-v3/ChangeLog:

PR libstdc++/111102
* include/std/format (__format::__parse_integer): Check for
non-null pointer.

(cherry picked from commit dd4bdb9eea436bf06f175d8dbfc2190377455be4)

21 months agolibstdc++: Minor fixes for some warnings in <format>
Jonathan Wakely [Tue, 8 Aug 2023 15:29:17 +0000 (16:29 +0100)] 
libstdc++: Minor fixes for some warnings in <format>

libstdc++-v3/ChangeLog:

* include/std/format: Fix some warnings.
(__format::__write(Ctx&, basic_string_view<CharT>)): Remove
unused function template.

(cherry picked from commit b9e5a4b4f035ba85b1a4065b751c2d583206b4e3)

21 months agolibstdc++: Fix std::format alternate form for floating-point [PR108046]
Jonathan Wakely [Thu, 27 Jul 2023 13:07:09 +0000 (14:07 +0100)] 
libstdc++: Fix std::format alternate form for floating-point [PR108046]

A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.

This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.

For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.

This can be fixed by using __z == 0 when __prec == 0.

libstdc++-v3/ChangeLog:

PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.

(cherry picked from commit 50bc490c090cc95175e6068ed7438788d7fd7040)

21 months agolibstdc++: Fix constexpr functions to conform to older standards
Jonathan Wakely [Wed, 9 Aug 2023 10:11:31 +0000 (11:11 +0100)] 
libstdc++: Fix constexpr functions to conform to older standards

Some constexpr functions were inadvertently relying on relaxed constexpr
rules from later standards.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (duration_cast): Do not use braces
around statements for C++11 constexpr rules.
* include/bits/stl_algobase.h (__lg): Rewrite as a single
statement for C++11 constexpr rules.
* include/experimental/bits/fs_path.h (path::string): Use
_GLIBCXX17_CONSTEXPR not _GLIBCXX_CONSTEXPR for 'if constexpr'.
* include/std/charconv (__to_chars_8): Initialize variable for
C++17 constexpr rules.

(cherry picked from commit b3a2b307b9deea719fb725a86df43b82176fe459)

21 months agoada: Fix missing call to Finalize_Protection for simple protected objects
Eric Botcazou [Mon, 18 Sep 2023 07:14:46 +0000 (09:14 +0200)] 
ada: Fix missing call to Finalize_Protection for simple protected objects

There is a glitch in Exp_Ch7.Build_Finalizer causing the finalizer to do
nothing for simple protected objects.

The change also removes redundant calls to the Is_Simple_Protected_Type
predicate and fixes a minor inconsistency between Requires_Cleanup_Actions
and Build_Finalizer for this case.

gcc/ada/

* exp_ch7.adb (Build_Finalizer.Process_Declarations): Remove call
to Is_Simple_Protected_Type as redundant.
(Build_Finalizer.Process_Object_Declaration): Do not retrieve the
corresponding record type for simple protected objects. Make the
flow of control more explicit in their specific processing.
* exp_util.adb (Requires_Cleanup_Actions): Return false for simple
protected objects present in library-level package bodies for the
sake of consistency with Build_Finalizer and remove call to
Is_Simple_Protected_Type as redundant.

21 months agoada: Fix missing finalization of extended return object on abnormal completion
Eric Botcazou [Thu, 14 Sep 2023 14:42:45 +0000 (16:42 +0200)] 
ada: Fix missing finalization of extended return object on abnormal completion

This happens in the case of a nonlimited return type and is a fallout of the
optimization recently implemented for them.

gcc/ada/

* einfo.ads (Status_Flag_Or_Transient_Decl): Remove ??? comment.
* exp_ch6.adb (Expand_N_Extended_Return_Statement): Extend the
handling of finalizable return objects to the non-BIP case.
* exp_ch7.adb (Build_Finalizer.Process_Declarations): Adjust the
comment accordingly.
* exp_util.adb (Requires_Cleanup_Actions): Likewise.

21 months agoada: Fix minor glitch in finish_record_type
Eric Botcazou [Thu, 7 Sep 2023 08:47:31 +0000 (10:47 +0200)] 
ada: Fix minor glitch in finish_record_type

The size needs to be rounded up to the storage unit in all cases.

gcc/ada/

* gcc-interface/utils.cc (finish_record_type): Round the size in
the padding case as well.

21 months agoada: Fix wrong optimization of extended return for discriminated record type
Eric Botcazou [Thu, 7 Sep 2023 14:44:36 +0000 (16:44 +0200)] 
ada: Fix wrong optimization of extended return for discriminated record type

This happens when the discriminants of the record type have default values.

gcc/ada/ChangeLog:

* inline.adb (Expand_Inlined_Call): In the case of a function call
that returns an unconstrained type and initializes an object, set
the No_Initialization flag on the new declaration of the object.

21 months agoada: Fix internal error on aggregate nested in container aggregate
Eric Botcazou [Wed, 6 Sep 2023 07:37:29 +0000 (09:37 +0200)] 
ada: Fix internal error on aggregate nested in container aggregate

This handles the case where a component association is present.

gcc/ada/

* exp_aggr.adb (Convert_To_Assignments): In the case of a
component association, call Is_Container_Aggregate on the parent's
parent.
(Expand_Array_Aggregate): Likewise.

21 months agoada: Fix internal error on expression function with Refined_Post aspect
Eric Botcazou [Tue, 5 Sep 2023 11:21:24 +0000 (13:21 +0200)] 
ada: Fix internal error on expression function with Refined_Post aspect

This occurs when the expression function calls a protected function and the
-gnata switch is specified, because the compiler wrongly freezes the called
function when analyzing the expression function, a fallout of the wrapping
scheme used for the Post and Refined_Post aspects.

gcc/ada/

* sem_res.adb (Resolve_Call): When the target is an entity, do not
freeze it if the current scope is the inner wrapper function built
for an expression function with a Post or Refined_Post aspect.

21 months agoada: Fix late finalization for function call in delta aggregate
Eric Botcazou [Sun, 27 Aug 2023 07:34:59 +0000 (09:34 +0200)] 
ada: Fix late finalization for function call in delta aggregate

The problem occurs at library level because the temporary created for the
function call lives in the elaboration routine but is finalized only when
the package itself is.

It turns out that there is no need for this temporary, since the expansion
of delta aggregates already creates a (properly finalized) temporary.

gcc/ada/

* exp_ch6.adb (Expand_Ctrl_Function_Call): Also do nothing for the
expression of a delta aggregate.

21 months agoada: Fix premature finalization in loop over limited iterable container
Eric Botcazou [Fri, 25 Aug 2023 08:47:30 +0000 (10:47 +0200)] 
ada: Fix premature finalization in loop over limited iterable container

This happens when the iterable container is obtained as the result of a
call to a function that is a subprogram parameter of a generic construct.

gcc/ada/

* exp_util.adb (Initialized_By_Aliased_BIP_Func_Call): Make the name
matching more robust.

21 months agoada: Elide the copy in extended returns for nonlimited by-reference types
Eric Botcazou [Wed, 23 Aug 2023 13:11:57 +0000 (15:11 +0200)] 
ada: Elide the copy in extended returns for nonlimited by-reference types

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Really test Storage_Pool on
the simple return statement.

21 months agoada: Fix assertion failure on very peculiar enumeration type
Eric Botcazou [Mon, 21 Aug 2023 16:23:46 +0000 (18:23 +0200)] 
ada: Fix assertion failure on very peculiar enumeration type

The compiler currently does not support the combination of a representation
clause on an enumeration type with a size clause whose value is greater than
the size of the largest machine scalar supported by the target.

Given that such a type would have little practical value, this change causes
the compiler to give a proper error message instead of aborting.

gcc/ada/

* freeze.adb (Freeze_Enumeration_Type): Give an error on a type with
both representation clause and too large size.

21 months agoada: Fix spurious error on 'Input of private type with Type_Invariant aspect
Eric Botcazou [Tue, 25 Jul 2023 21:03:22 +0000 (23:03 +0200)] 
ada: Fix spurious error on 'Input of private type with Type_Invariant aspect

The problem is that it is necessary to break the privacy during the
expansion of the Input attribute, which may introduce a view mismatch
with the parameter of the routine checking the invariant of the type.

gcc/ada/

* exp_util.adb (Make_Invariant_Call): Convert the expression to
the type of the formal parameter if need be.

21 months agoada: Elide the copy in extended returns for nonlimited by-reference types
Eric Botcazou [Tue, 11 Jul 2023 08:59:17 +0000 (10:59 +0200)] 
ada: Elide the copy in extended returns for nonlimited by-reference types

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Restrict previous change to
the case where the simple return statement has got no storage pool.

21 months agoada: Fix memory explosion on aggregate of nested packed array type
Eric Botcazou [Tue, 11 Jul 2023 11:29:55 +0000 (13:29 +0200)] 
ada: Fix memory explosion on aggregate of nested packed array type

It occurs at compile time on an aggregate of a 2-dimensional packed array
type whose component type is itself a packed array, because the compiler
is trying to pack the intermediate aggregate and ends up rewriting a bunch
of subcomponents.  This optimization was originally devised for the case of
a scalar component type so the change adds this restriction.

gcc/ada/

* exp_aggr.adb (Is_Two_Dim_Packed_Array): Return true only if the
component type of the array is scalar.

21 months agoada: Improve error message for ambiguous subprogram call
Eric Botcazou [Wed, 5 Jul 2023 20:04:07 +0000 (22:04 +0200)] 
ada: Improve error message for ambiguous subprogram call

This restores the full listing of the types for the interpretations.

gcc/ada/

* sem_util.ads (Wrong_Type): Add Multiple parameter defaulting to
False and document it.
* sem_util.adb (Wrong_Type): Do not return early if an error has
already been posted on Expr and Multiple is True.
* sem_ch4.adb (Analyze_One_Call): Pass All_Errors_Mode as the
actual parameter for Multiple to Wrong_Type.

21 months agoada: Fix assertion failure introduced by latest change
Eric Botcazou [Wed, 5 Jul 2023 17:49:40 +0000 (19:49 +0200)] 
ada: Fix assertion failure introduced by latest change

The new processing is not properly guarded.

gcc/ada/

* sem_ch13.adb (Replace_Type_References_Generic.Visible_Component):
In the case of private discriminated types, explicitly check that we
have a private declaration before examining its discriminant part.

21 months agoada: Fix Valid_Scalars attribute applied to types from limited with
Eric Botcazou [Sun, 2 Jul 2023 08:07:55 +0000 (10:07 +0200)] 
ada: Fix Valid_Scalars attribute applied to types from limited with

The attribute is wrongly computed as always True because, unlike for e.g.
private types, Validated_View does not look through the limited view.

gcc/ada/

* sem_util.ads (Validated_View): Document enhanced behavior.
* sem_util.adb (Validated_View): Return the nonlimited view, if any,
of types coming from a limited with.

21 months agoada: Fix wrong resolution for hidden discriminant in predicate
Eric Botcazou [Sun, 2 Jul 2023 22:33:18 +0000 (00:33 +0200)] 
ada: Fix wrong resolution for hidden discriminant in predicate

The problem occurs for hidden discriminants of private discriminated types.

gcc/ada/

* sem_ch13.adb (Replace_Type_References_Generic.Visible_Component):
In the case of private discriminated types, return a discriminant
only if it is listed in the discriminant part of the declaration.

21 months agoada: Fix small inaccuracy in implementation of B.3.3(20/2)
Eric Botcazou [Tue, 20 Jun 2023 17:46:43 +0000 (19:46 +0200)] 
ada: Fix small inaccuracy in implementation of B.3.3(20/2)

This is the clause about inferable discriminants in unchecked unions.

gcc/ada/

* sem_util.adb (Has_Inferable_Discriminants): In the case of a
component with a per-object constraint, also return true if the
enclosing object is not of an unchecked union type.
In the default case, remove a useless call to Base_Type.

21 months agoada: Fix bad interaction between inlining and thunk generation
Eric Botcazou [Tue, 20 Jun 2023 22:50:40 +0000 (00:50 +0200)] 
ada: Fix bad interaction between inlining and thunk generation

This may cause the type of the RESULT_DECL of a function which returns by
invisible reference to be turned into a reference type twice.

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Add guard to the
code turning the type of the RESULT_DECL into a reference type.
(maybe_make_gnu_thunk): Use a more precise guard in the same case.

21 months agoada: Fix wrong finalization for double subtype of bounded vector
Eric Botcazou [Wed, 10 May 2023 16:00:36 +0000 (18:00 +0200)] 
ada: Fix wrong finalization for double subtype of bounded vector

The special handling of temporaries created for return values and subject
to a renaming needs to be restricted to the top level, where it is needed
to prevent dangling references to the frame of the elaboration routine from
being created, because, at a lower level, the front-end may create implicit
renamings of objects as these temporaries, so a copy is not allowed.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Restrict
the special handling of temporaries created for return values and
subject to a renaming to the top level.

21 months agoMinor tweak
Eric Botcazou [Wed, 27 Sep 2023 08:00:03 +0000 (10:00 +0200)] 
Minor tweak

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Tweak.

21 months agoada: Fix too small secondary stack allocation for returned conversion
Eric Botcazou [Fri, 19 May 2023 23:23:20 +0000 (01:23 +0200)] 
ada: Fix too small secondary stack allocation for returned conversion

The previous fix did not address a latent issue whereby the allocation
would be made using the (static) subtype of the conversion instead of
the (dynamic) subtype of the return object, so this change rewrites the
code responsible for determining the type used for the allocation, and
also contains a small improvement to the Has_Tag_Of_Type predicate.

gcc/ada/

* exp_ch3.adb (Make_Allocator_For_Return): Rewrite the logic that
determines the type used for the allocation and add assertions.
* exp_util.adb (Has_Tag_Of_Type): Also return true for extension
aggregates.

21 months agoada: Fix too small secondary stack allocation for returned aggregate
Eric Botcazou [Sat, 13 May 2023 08:55:44 +0000 (10:55 +0200)] 
ada: Fix too small secondary stack allocation for returned aggregate

This restores the specific treatment of aggregates that are returned through
an extended return statement in a function returning a class-wide type, and
which was incorrectly dropped in an earlier change.

gcc/ada/

* exp_ch3.adb (Make_Allocator_For_Return): Deal again specifically
with an aggregate returned through an object of a class-wide type.

21 months agoada: Fix missing error on function call returning incomplete view
Eric Botcazou [Fri, 12 May 2023 18:20:16 +0000 (20:20 +0200)] 
ada: Fix missing error on function call returning incomplete view

Testing for the presence of Non_Limited_View is not sufficient to detect
whether the nonlimited view has been analyzed because Build_Limited_Views
always sets the field on the limited view.  Instead the discriminant is
whether this nonlimited view is itself an incomplete type.

gcc/ada/

* sem_ch4.adb (Analyze_Call): Adjust the test to detect the presence
of an incomplete view of a type on a function call.

21 months agoada: Fix inverted implementation of RM 8.4(10) clause for operators
Eric Botcazou [Tue, 9 May 2023 22:05:55 +0000 (00:05 +0200)] 
ada: Fix inverted implementation of RM 8.4(10) clause for operators

The comment is correct but the code implements the opposite outcome.

gcc/ada/

* sem_type.adb (Disambiguate): Fix pasto in the implementation of
the RM 8.4(10) clause for operators.

21 months agoada: Fix aspect Linker_Section ignored on subprogram body
Eric Botcazou [Mon, 8 May 2023 14:17:33 +0000 (16:17 +0200)] 
ada: Fix aspect Linker_Section ignored on subprogram body

The compiler is waiting for the freeze node of the body, but it is never
generated since the freezing of the body is not delayed.  The change also
removes an obsolete piece of code.

gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Specifications): Add missing items
in the list of aspects handled by means of Insert_Pragma.
<Aspect_Linker_Section>: Remove obsolete code.  Do not delay the
processing of the aspect if the entity is already frozen.

21 months agoada: Fix exception raised on invalid contract in generic package
Eric Botcazou [Mon, 24 Apr 2023 09:07:38 +0000 (11:07 +0200)] 
ada: Fix exception raised on invalid contract in generic package

This lets the compiler give a proper error message instead.

gcc/ada/

* contracts.adb (Contract_Error): New exception.
(Add_Contract_Item): Raise Contract_Error instead of Program_Error.
(Add_Generic_Contract_Pragma): Deal with Contract_Error.

21 months agoada: Fix internal error on imported function with post-condition
Eric Botcazou [Mon, 24 Apr 2023 15:11:01 +0000 (17:11 +0200)] 
ada: Fix internal error on imported function with post-condition

The problem, which is also present for an expression function, is that the
function is invoked in the initializing expression of a variable declared
in the same declarative part as the function, which causes the freezing of
its artificial body before the post-condition is analyzed on its spec.

gcc/ada/

* contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract): For a
subprogram body that has no contracts and does not come from source,
make sure that contracts on its corresponding spec are analyzed, if
any, before expanding them.

21 months agoada: Fix wrong expansion of array aggregate with noncontiguous choices
Eric Botcazou [Wed, 12 Apr 2023 17:49:05 +0000 (19:49 +0200)] 
ada: Fix wrong expansion of array aggregate with noncontiguous choices

This extends an earlier fix done for the others choice of an array aggregate
to all the choices of the aggregate, since the same sharing issue may happen
when the choices are not contiguous.

gcc/ada/

* exp_aggr.adb (Build_Array_Aggr_Code.Get_Assoc_Expr): Duplicate the
expression here instead of...
(Build_Array_Aggr_Code): ...here.

21 months agoada: Fix internal error on array constant in expression function
Eric Botcazou [Fri, 14 Apr 2023 09:14:47 +0000 (11:14 +0200)] 
ada: Fix internal error on array constant in expression function

This happens when the peculiar check emitted by Check_Large_Modular_Array
is applied to an object whose actual subtype is an itype with dynamic size,
because the first reference to the itype in the expanded code may turn out
to be within the raise statement, which is problematic for the eloboration
of this itype by the code generator at library level.

gcc/ada/

* freeze.adb (Check_Large_Modular_Array): Fix head comment, use
Standard_Long_Long_Integer_Size directly and generate a reference
just before the raise statement if the Etype of the object is an
itype declared in an open scope.

21 months agoada: Fix fallout of recent fix for missing finalization
Eric Botcazou [Thu, 13 Apr 2023 21:11:38 +0000 (23:11 +0200)] 
ada: Fix fallout of recent fix for missing finalization

The original fix makes it possible to create transient scopes around return
statements in more cases, but it overlooks that transient scopes are reused
and, in particular, that they can be promoted to secondary stack management.

gcc/ada/

* exp_ch7.adb (Find_Enclosing_Transient_Scope): Return the index in
the scope table instead of the scope's entity.
(Establish_Transient_Scope): If an enclosing scope already exists,
do not set the Uses_Sec_Stack flag on it if the node to be wrapped
is a return statement which requires secondary stack management.

21 months agoada: Fix regression of secondary stack management in return statements
Eric Botcazou [Tue, 11 Apr 2023 23:16:20 +0000 (01:16 +0200)] 
ada: Fix regression of secondary stack management in return statements

This happens when the expression of the return statement is a call that does
not return on the same stack as the enclosing function.

gcc/ada/

* sem_res.adb (Resolve_Call): Restrict previous change to calls that
return on the same stack as the enclosing function.  Tidy up.

21 months agoada: Fix visibility error with DIC or Type_Invariant aspect on generic type
Eric Botcazou [Tue, 11 Apr 2023 10:15:22 +0000 (12:15 +0200)] 
ada: Fix visibility error with DIC or Type_Invariant aspect on generic type

The compiler fails to capture global references during the analysis of the
aspect on the generic type because it analyzes a copy of the expression.

gcc/ada/

* exp_util.adb (Build_DIC_Procedure_Body.Add_Own_DIC): When inside
a generic unit, preanalyze the expression directly.
(Build_Invariant_Procedure_Body.Add_Own_Invariants): Likewise.

21 months agoada: Fix spurious error on imported generic function with precondition
Eric Botcazou [Mon, 10 Apr 2023 08:15:59 +0000 (10:15 +0200)] 
ada: Fix spurious error on imported generic function with precondition

It occurs during the instantiation because the compiler forgets the context
of the generic declaration.

gcc/ada/

* freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec in
both cases to copy the spec of the subprogram.

21 months agoada: Fix memory leak in expression function returning Big_Integer
Eric Botcazou [Sat, 8 Apr 2023 16:29:16 +0000 (18:29 +0200)] 
ada: Fix memory leak in expression function returning Big_Integer

We fail to establish a transient scope around the return statement because
the function returns a controlled type, but this is no longer problematic
because controlled types are no longer returned on the secondary stack.

gcc/ada/

* exp_ch7.adb (Establish_Transient_Scope.Find_Transient_Context):
Bail out for a simple return statement only if the transient scope
and the function both require secondary stack management, or else
if the function is a thunk.
* sem_res.adb (Resolve_Call): Do not create a transient scope when
the call is the expression of a simple return statement.

21 months agoada: Call idiomatic routine in Expand_Simple_Function_Return
Eric Botcazou [Sat, 8 Apr 2023 10:43:54 +0000 (12:43 +0200)] 
ada: Call idiomatic routine in Expand_Simple_Function_Return

In the primary stack case, Insert_Actions is invoked when the expression is
being rewritten, whereas Insert_List_Before_And_Analyze is invoked in the
secondary stack case.  The former is idiomatic, the latter is not.

gcc/ada/

* exp_ch6.adb (Expand_Simple_Function_Return): Call Insert_Actions
consistently when rewriting the expression.

21 months agoada: Fix wrong finalization for loop on indexed container
Eric Botcazou [Fri, 7 Apr 2023 17:17:20 +0000 (19:17 +0200)] 
ada: Fix wrong finalization for loop on indexed container

The problem is that a transient temporary created for the constant indexing
of the container is finalized almost immediately after its creation.

gcc/ada/

* exp_util.adb (Is_Finalizable_Transient.Is_Indexed_Container):
New predicate to detect a temporary created to hold the result of
a constant indexing on a container.
(Is_Finalizable_Transient.Is_Iterated_Container): Adjust a couple
of obsolete comments.
(Is_Finalizable_Transient): Return False if Is_Indexed_Container
returns True on the object.

21 months agoada: Fix bogus error on conditional expression with only user-defined literals
Eric Botcazou [Fri, 7 Apr 2023 07:16:12 +0000 (09:16 +0200)] 
ada: Fix bogus error on conditional expression with only user-defined literals

This implements the recursive resolution of conditional expressions whose
dependent expressions are (all) user-defined literals the same way it is
implemented for operators.

gcc/ada/

* sem_res.adb (Has_Applicable_User_Defined_Literal): Make it clear
that the predicate also checks the node itself.
(Try_User_Defined_Literal): Move current implementation to...
Deal only with literals, named numbers and conditional expressions
whose dependent expressions are literals or named numbers.
(Try_User_Defined_Literal_For_Operator): ...this.  Remove multiple
return False statements and put a single one at the end.
(Resolve): Call Try_User_Defined_Literal instead of directly
Has_Applicable_User_Defined_Literal for all nodes.  Call
Try_User_Defined_Literal_For_Operator for operator nodes.

21 months agoada: Fix wrong finalization for case expression in expression function
Eric Botcazou [Thu, 6 Apr 2023 22:26:19 +0000 (00:26 +0200)] 
ada: Fix wrong finalization for case expression in expression function

This happens when the case expression contains a single alternative.

gcc/ada/

* exp_ch5.adb (Expand_N_Case_Statement): Do not remove the statement
if it is the node to be wrapped by a transient scope.

21 months agoada: Fix internal error with pragma Compile_Time_{Warning,Error}
Eric Botcazou [Tue, 4 Apr 2023 17:25:11 +0000 (19:25 +0200)] 
ada: Fix internal error with pragma Compile_Time_{Warning,Error}

This happens when the pragmas are deferred to the back-end from an external
unit to the main unit that is generic, because the back-end does not compile
a main unit that is generic.

gcc/ada/

* sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not defer
anything to the back-end when the main unit is generic.

21 months agoada: Fix small fallout of previous change
Eric Botcazou [Wed, 5 Apr 2023 21:53:18 +0000 (23:53 +0200)] 
ada: Fix small fallout of previous change

It may lead to an infinite recursion if no interpretation exists.

gcc/ada/

* sem_res.adb (Try_User_Defined_Literal): Restrict previous change
to non-leaf nodes.

21 months agoada: Fix remaining failures in Roman Numbers test
Eric Botcazou [Wed, 5 Apr 2023 18:43:54 +0000 (20:43 +0200)] 
ada: Fix remaining failures in Roman Numbers test

The test is inspired from the example of user-defined literals given in the
Ada 2022 RM.  Mixed Arabic numbers/Roman numbers computations are rejected
because the second resolution pass would try to resolve Arabic numbers only
as user-defined literals.

gcc/ada/

* sem_res.adb (Try_User_Defined_Literal): For arithmetic operators,
also accept operands whose type is covered by the resolution type.

21 months agoada: Fix wrong result for membership test of null in null-excluding access type
Eric Botcazou [Wed, 5 Apr 2023 18:34:43 +0000 (20:34 +0200)] 
ada: Fix wrong result for membership test of null in null-excluding access type

The result must be False as per the RM 4.5.2 (30.2/4) clause.

gcc/ada/

* exp_ch4.adb (Expand_N_In): Deal specifically with a null operand.

21 months agoada: Fix small fallout of previous change
Eric Botcazou [Wed, 5 Apr 2023 11:56:42 +0000 (13:56 +0200)] 
ada: Fix small fallout of previous change

The same guard must be added to Expand_Simple_Function_Return as the one
that was added to Analyze_Function_Return.

gcc/ada/

* exp_ch6.adb (Expand_Simple_Function_Return): Deal with a rewriting
of the simple return during the adjustment of its expression.

21 months agoada: Fix wrong finalization for call to BIP function in conditional expression
Eric Botcazou [Mon, 3 Apr 2023 08:53:30 +0000 (10:53 +0200)] 
ada: Fix wrong finalization for call to BIP function in conditional expression

This happens when the call is a dependent expression of the conditional
expression, and the conditional expression is either the expression of a
simple return statement or the return expression of an expression function.

The reason is that the special processing of "tail calls" for BIP functions,
i.e. calls that are the expression of simple return statements or the return
expression of expression functions, is not applied.

This change makes sure that it is applied by distributing the simple return
statements enclosing conditional expressions into the dependent expressions
of the conditional expressions in almost all cases.  As a side effect, this
elides a temporary in the nonlimited by-reference case, as well as a pair of
calls to Adjust/Finalize in the nonlimited controlled case.

gcc/ada/

* exp_ch4.adb (Expand_N_Case_Expression): Distribute simple return
statements enclosing the conditional expression into the dependent
expressions in almost all cases.
(Expand_N_If_Expression): Likewise.
(Process_Transient_In_Expression): Adjust to the above distribution.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Deal with calls in the
dependent expressions of a conditional expression.
* sem_ch6.adb (Analyze_Function_Return): Deal with the rewriting of
a simple return statement during the resolution of its expression.

21 months agoada: Repair support for user-defined literals in arithmetic operators
Eric Botcazou [Mon, 3 Apr 2023 15:11:11 +0000 (17:11 +0200)] 
ada: Repair support for user-defined literals in arithmetic operators

It was partially broken to fix a regression in error reporting, because the
fix was applied to the first pass of resolution instead of the second pass,
as needs to be done for user-defined literals.

gcc/ada/

* sem_ch4.ads (Unresolved_Operator): New procedure.
* sem_ch4.adb (Has_Possible_Literal_Aspects): Rename into...
(Has_Possible_User_Defined_Literal): ...this.  Tidy up.
(Operator_Check): Accept again unresolved operators if they have a
possible user-defined literal as operand.  Factor out the handling
of the general error message into...
(Unresolved_Operator): ...this new procedure.
* sem_res.adb (Resolve): Be prepared for unresolved operators on
entry in Ada 2022 or later.  If they are still unresolved on exit,
call Unresolved_Operator to give the error message.
(Try_User_Defined_Literal): Tidy up.

21 months agoada: Fix spurious error on nested instantiations with generic renaming
Eric Botcazou [Sat, 1 Apr 2023 19:57:21 +0000 (21:57 +0200)] 
ada: Fix spurious error on nested instantiations with generic renaming

The problem is that the renaming slightly changes the form of a global
reference that was saved during the analysis of a generic package, and
that is sufficient to fool the code adjusting global references during
the instantiation.

gcc/ada/

* sem_ch12.adb (Copy_Generic_Node): Test the original node kind
for the sake of consistency.  For identifiers and other entity
names and operators, accept an expanded name as associated node.
Replace "or" with "or else" in condtion and fix its formatting.

21 months agoada: Fix internal error on Big_Integer conversion ghost instance
Eric Botcazou [Sat, 25 Mar 2023 20:42:11 +0000 (21:42 +0100)] 
ada: Fix internal error on Big_Integer conversion ghost instance

The problem is that the ghost mode of the instance is used to analyze the
parent of the generic body, whose own ghost mode has nothing to do with it.

gcc/ada/

* sem_ch12.adb (Instantiate_Package_Body): Set the ghost mode to
that of the instance only after loading the generic's parent.
(Instantiate_Subprogram_Body): Likewise.

21 months agoada: Reject thin 'Unrestricted_Access value to aliased constrained array
Eric Botcazou [Sun, 5 Mar 2023 17:30:34 +0000 (18:30 +0100)] 
ada: Reject thin 'Unrestricted_Access value to aliased constrained array

This rejects the Unrestricted_Access attribute applied to an aliased array
with a constrained nominal subtype when its type is resolved to be a thin
pointer.  The reason is that supporting this case would require the aliased
array to contain its bounds, and this is the case only for aliased arrays
whose nominal subtype is unconstrained.

gcc/ada/

* sem_attr.adb (Is_Thin_Pointer_To_Unc_Array): New predicate.
(Resolve_Attribute): Apply the static matching legality rule to an
Unrestricted_Access attribute applied to an aliased prefix if the
type is a thin pointer.  Call Is_Thin_Pointer_To_Unc_Array for the
aliasing legality rule as well.

21 months agoada: Add missing guards in Selected_Range_Checks
Eric Botcazou [Tue, 14 Mar 2023 11:42:53 +0000 (12:42 +0100)] 
ada: Add missing guards in Selected_Range_Checks

gcc/ada/

* checks.adb (Selected_Range_Checks): Add guards to protect calls
to Expr_Value on bounds.

21 months agoada: Fix internal error on declare-expression in post-condition
Eric Botcazou [Fri, 10 Mar 2023 17:05:13 +0000 (18:05 +0100)] 
ada: Fix internal error on declare-expression in post-condition

It comes from an incorrect node sharing in the expanded tree.

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object): Copy the object definition when
building the subtype declaration in the case of a spec expression.

21 months agoada: Rework fix for internal error on quantified expression with predicated type
Eric Botcazou [Wed, 1 Mar 2023 21:28:51 +0000 (22:28 +0100)] 
ada: Rework fix for internal error on quantified expression with predicated type

It turns out that skipping compiler-generated block scopes is problematic
when computing the public status of a subprogram, because this subprogram
may end up being nested in the elaboration procedure of a package spec or
body, in which case it may not be public.

This replaces the original fix with a pair of Push_Scope/Pop_Scope in the
Build_Predicate_Function procedure, as done elsewhere in similar cases.

gcc/ada/

* sem_ch13.adb (Build_Predicate_Functions): If the current scope
is not that of the type, push this scope and pop it at the end.
* sem_util.ads (Current_Scope_No_Loops_No_Blocks): Delete.
* sem_util.adb (Current_Scope_No_Loops_No_Blocks): Likewise.
(Set_Public_Status): Call again Current_Scope.

21 months agoada: Fix internal error on quantified expression with predicated type
Eric Botcazou [Wed, 15 Feb 2023 14:52:00 +0000 (15:52 +0100)] 
ada: Fix internal error on quantified expression with predicated type

The problem is that the special function created by the compiler to check
the predicate does not inherit the public status of the type, because it
is generated as part of the freezing of the quantified expression, which
occurs from within a couple of intermediate internal scopes.

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function_Declaration): Adjust the
commentary to the current implementation.
* sem_util.ads (Current_Scope_No_Loops): Move around.
(Current_Scope_No_Loops_No_Blocks): New declaration.
(Add_Block_Identifier): Fix formatting.
* sem_util.adb (Add_Block_Identifier): Likewise.
(Current_Scope_No_Loops_No_Blocks): New function.
(Set_Public_Status): Call Current_Scope_No_Loops_No_Blocks instead
of Current_Scope to get the current scope.

21 months agoada: Fix bogus error on predicated limited record declared in protected type
Eric Botcazou [Fri, 17 Feb 2023 17:01:52 +0000 (18:01 +0100)] 
ada: Fix bogus error on predicated limited record declared in protected type

This happens when the limited record is initialized with a function call
because of a couple of issues: incorrect tree sharing when building the
predicate check and too late freezing for a compiler-generated subtype.

It turns out that building the predicate check manually is redundant here,
since predicate checks are automatically generated during the expansion of
assignment statements, and the late freezing can be easily fixed.

gcc/ada/

* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
manually generate a predicate check.  Call Unqualify before doing
pattern matching on the expression.
* sem_ch3.adb (Analyze_Object_Declaration): Also freeze the actual
subtype when it is built in the definite case.

21 months agoada: Small code cleanup
Eric Botcazou [Tue, 14 Feb 2023 16:03:19 +0000 (17:03 +0100)] 
ada: Small code cleanup

This just merges two conditional blocks depending on the same condition.

gcc/ada/

* frontend.adb (Frontend): Merge two conditional blocks and adjust.

21 months agoada: Use idiomatic construct in Expand_N_Package_Body
Eric Botcazou [Fri, 10 Feb 2023 10:15:15 +0000 (11:15 +0100)] 
ada: Use idiomatic construct in Expand_N_Package_Body

gcc/ada/

* exp_ch7.adb (Expand_N_Package_Body): Call Defining_Entity to get
the entity of the body.

21 months agoada: Fix spurious freezing error on nonabstract null extension
Eric Botcazou [Wed, 8 Feb 2023 15:26:46 +0000 (16:26 +0100)] 
ada: Fix spurious freezing error on nonabstract null extension

This prevents the wrapper function created for each nonoverridden inherited
function with a controlling result of nonabstract null extensions of tagged
types from causing premature freezing of types referenced in its profile.

gcc/ada/

* exp_ch3.adb (Make_Controlling_Function_Wrappers): Create the body
as the expanded body of an expression function.

21 months agoada: Fix crash on Ada.Containers with No_Dispatching_Calls restriction
Eric Botcazou [Wed, 1 Feb 2023 16:46:17 +0000 (17:46 +0100)] 
ada: Fix crash on Ada.Containers with No_Dispatching_Calls restriction

This makes it so that the compiler does not crash and flags the underlying
violation of the restriction instead.

gcc/ada/

* exp_ch3.adb (Freeze_Type): Do not associate the Finalize_Address
routine for a class-wide type if restriction No_Dispatching_Calls
is in effect.

21 months agoada: Fix error and crash on imported function with precondition and 'Base
Eric Botcazou [Wed, 1 Feb 2023 11:35:08 +0000 (12:35 +0100)] 
ada: Fix error and crash on imported function with precondition and 'Base

This fixes a spurious error on an imported function with a precondition
and a parameter declared with a 'Base formal type, and even a crash in
the case where this function is declared in a generic package.

gcc/ada/

* freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec
to copy the spec from the subprogram to the generated subprogram
body.
(Freeze_Entity): Do not wrap imported subprograms inside generics.

21 months agoada: Fix double finalization in conditional exit statement
Eric Botcazou [Tue, 31 Jan 2023 15:04:01 +0000 (16:04 +0100)] 
ada: Fix double finalization in conditional exit statement

The temporary is first finalized through its enclosing block.

gcc/ada/

* exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do
not look into nested blocks.

21 months agoada: Fix handling of constrained array declarations in declare-expression
Eric Botcazou [Tue, 31 Jan 2023 13:33:44 +0000 (14:33 +0100)] 
ada: Fix handling of constrained array declarations in declare-expression

They need to go through Constrain_Array or else they do not really work.

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object): In a spec expression, also set
the Scope of the type, and call Constrain_Array for array subtypes.

21 months agoada: Use accumulator type in expansion of 'Reduce attribute
Eric Botcazou [Thu, 26 Jan 2023 14:59:37 +0000 (15:59 +0100)] 
ada: Use accumulator type in expansion of 'Reduce attribute

The current expansion of the 'Reduce attribute uses the resolution type of
the expression for the accumulator. Now this type can be unresolved or set
to a universal type, for example if it is itself the prefix of the 'Image
attribute, and this may yield a spurious type mismatch error in that case.

This changes the expansion to use the accumulator type instead as defined
by the RM 4.5.10 clause, albeit only in the prefixed case for now.

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Reduce>:
Use the canonical accumulator type as the type of the accumulator
in the prefixed case.

21 months agoada: Fix crash on iterated component in expression function
Eric Botcazou [Sun, 29 Jan 2023 23:05:42 +0000 (00:05 +0100)] 
ada: Fix crash on iterated component in expression function

The problem is that the freeze node generated for the type of a static
subexpression present in the expression function is incorrectly placed
inside instead of outside the function.

gcc/ada/

* freeze.adb (Freeze_Expression): When the freezing is to be done
outside the current scope, skip any scope that is an internal loop.

21 months agoada: Fix internal error on 'Image applied to array component
Eric Botcazou [Thu, 26 Jan 2023 17:16:14 +0000 (18:16 +0100)] 
ada: Fix internal error on 'Image applied to array component

This happens because the array component depends on a discriminant.

gcc/ada/

* exp_imgv.adb (Rewrite_Object_Image): If the prefix is a component
that depends on a discriminant, create an actual subtype for it.

21 months agoada: Fix internal error on chain of predicated record types
Eric Botcazou [Fri, 27 Jan 2023 14:13:07 +0000 (15:13 +0100)] 
ada: Fix internal error on chain of predicated record types

The preanalysis of a predicate set on one of the record types was causing
premature freezing of another record type.

gcc/ada/

* sem_ch13.adb: Add with and use clauses for Expander.
(Resolve_Aspect_Expressions) <Aspect_Predicate>: Emulate a
bona-fide preanalysis setup before calling
Resolve_Aspect_Expression.

21 months agoada: Implement inheritance of user-defined literal aspects for untagged types
Eric Botcazou [Fri, 27 Jan 2023 23:08:24 +0000 (00:08 +0100)] 
ada: Implement inheritance of user-defined literal aspects for untagged types

In Ada 2022, user-defined literal aspects are nonoverridable but the named
subprograms present in them can be overridden, including for untagged types.

gcc/ada/

* sem_res.adb (Has_Applicable_User_Defined_Literal): Apply the
same processing for derived untagged types as for tagged types.
* sem_util.ads (Corresponding_Primitive_Op): Adjust description.
* sem_util.adb (Corresponding_Primitive_Op): Handle untagged
types.

21 months agoada: Fix internal error on instance in package body with -gnatn
Eric Botcazou [Thu, 12 Jan 2023 14:51:40 +0000 (15:51 +0100)] 
ada: Fix internal error on instance in package body with -gnatn

This plugs a small loophole in the procedure responsible for attempting to
hide entities that have been previously made public by the semantic analyzer
in package bodies.

gcc/ada/

* sem_ch7.adb (Hide_Public_Entities): Use the same condition for
subprogram bodies without specification as for those with one.

21 months agoada: Fix invalid JSON for extended variant record with -gnatRj
Eric Botcazou [Wed, 4 Jan 2023 15:41:47 +0000 (16:41 +0100)] 
ada: Fix invalid JSON for extended variant record with -gnatRj

This fixes the output of -gnatRj for an extension of a tagged type which has
a variant part and also deals with the case where the parent type is private
with unknown discriminants.

gcc/ada/

* repinfo.ads (JSON output format): Document special case of
Present member of a Variant object.
* repinfo.adb (List_Structural_Record_Layout): Change the type of
Ext_Level parameter to Integer. Restrict the first recursion with
increasing levels to the fixed part and implement a second
recursion with decreasing levels for the variant part. Deal with
an extension of a type with unknown discriminants.

21 months agolibstdc++: Prevent unwanted ADL in std::to_array [PR111512]
Jonathan Wakely [Thu, 21 Sep 2023 08:14:57 +0000 (09:14 +0100)] 
libstdc++: Prevent unwanted ADL in std::to_array [PR111512]

Qualify the calls to the __to_array helper to prevent ADL, so we don't
try to complete associated classes.

libstdc++-v3/ChangeLog:

PR libstdc++/111511
PR c++/111512
* include/std/array (to_array): Qualify calls to __to_array.
* testsuite/23_containers/array/creation/111512.cc: New test.

(cherry picked from commit 77cf3773021b0a20d89623e09d620747a05588ec)

21 months agoAdd missing return in gori_compute::logical_combine
Eric Botcazou [Mon, 25 Sep 2023 18:48:53 +0000 (20:48 +0200)] 
Add missing return in gori_compute::logical_combine

The varying case currently falls through to the 1/true case.

gcc/
* gimple-range-gori.cc (gori_compute::logical_combine): Add missing
return statement in the varying case.

gcc/testsuite/
* gnat.dg/opt102.adb:New test.
* gnat.dg/opt102_pkg.adb, gnat.dg/opt102_pkg.ads: New helper.

21 months agoPR modula2/111510 runtime ICE findChildAndParent has caused internal runtime error
Gaius Mulley [Tue, 26 Sep 2023 18:39:59 +0000 (19:39 +0100)] 
PR modula2/111510 runtime ICE findChildAndParent has caused internal runtime error

This patch fixes the runtime bug above.  The full runtime message is:
findChildAndParent has caused internal runtime error, RTentity is either
corrupt or the module storage has not been initialized yet.  The bug is
due to a non nul terminated string determining the module initialization order.
This results in modules being uninitialized and the above crash.  The bug
manifests itself on 32 bit systems - but obviously is latent on all
targets and the fix should be applied to both gcc-14 and gcc-13.

gcc/m2/ChangeLog:

PR modula2/111510
* gm2-compiler/M2GenGCC.mod (IsExportedGcc): Minor spacing changes.
(BuildTrashTreeFromInterface): Minor spacing changes.
* gm2-compiler/M2Options.mod (GetRuntimeModuleOverride): Call
string to generate a nul terminated C style string.
* gm2-compiler/M2Quads.mod (BuildStringAdrParam): New procedure.
(BuildM2InitFunction): Replace inline parameter generation with
calls to BuildStringAdrParam.

(cherry picked from commit 53daf67fd55e005e37cb3ab33ac0783a71761de9)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
21 months agoReduce the initial size of int_range_max.
Andrew MacLeod [Tue, 26 Sep 2023 13:44:39 +0000 (09:44 -0400)] 
Reduce the initial size of int_range_max.

This patch adds the ability to resize ranges as needed, defaulting to no
resizing.  int_range_max now defaults to 3 sub-ranges (instead of 255)
and grows to 255 when the range being calculated does not fit.

PR tree-optimization/110315
* value-range-storage.h (vrange_allocator::alloc_irange): Adjust
new params.
* value-range.cc (irange::operator=): Resize range.
(irange::irange_union): Same.
(irange::irange_intersect): Same.
(irange::invert): Same.
* value-range.h (irange::maybe_resize): New.
(~int_range): New.
(int_range_max): Default to 3 sub-ranges and resize as needed.
(int_range::int_range): Adjust for resizing.
(int_range::operator=): Same.

21 months agoada: Fix deferred constant wrongly rejected
Eric Botcazou [Sat, 16 Sep 2023 18:29:20 +0000 (20:29 +0200)] 
ada: Fix deferred constant wrongly rejected

This recent regression occurs when the nominal subtype of the constant is a
discriminated record type with default discriminants.

gcc/ada/
PR ada/110488
* sem_ch3.adb (Analyze_Object_Declaration): Do not build a default
subtype for a deferred constant in the definite case too.

21 months agoDaily bump.
GCC Administrator [Tue, 26 Sep 2023 00:21:48 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Mon, 25 Sep 2023 00:21:25 +0000 (00:21 +0000)] 
Daily bump.

21 months agoc++: missing SFINAE in grok_array_decl [PR111493]
Patrick Palka [Fri, 22 Sep 2023 10:27:48 +0000 (06:27 -0400)] 
c++: missing SFINAE in grok_array_decl [PR111493]

We should guard both the diagnostic and backward compatibilty fallback
code with tf_error, so that in a SFINAE context we don't issue any
diagnostics and correctly treat ill-formed C++23 multidimensional
subscript operator expressions as such.

PR c++/111493

gcc/cp/ChangeLog:

* decl2.cc (grok_array_decl): Guard diagnostic and backward
compatibility fallback code paths with tf_error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/subscript15.C: New test.

(cherry picked from commit 1fea14def849dd38b098b0e2d54e64801f9c1f43)

21 months agoc++: constraint rewriting during ttp coercion [PR111485]
Patrick Palka [Fri, 22 Sep 2023 10:25:49 +0000 (06:25 -0400)] 
c++: constraint rewriting during ttp coercion [PR111485]

In order to compare the constraints of a ttp with that of its argument,
we rewrite the ttp's constraints in terms of the argument template's
template parameters.  The substitution to achieve this currently uses a
single level of template arguments, but that never does the right thing
because a ttp's template parameters always have level >= 2.  This patch
fixes this by including the outer template arguments in the substitution,
which ought to match the depth of the ttp.

The second testcase demonstrates it's better to substitute the concrete
outer template arguments instead of generic ones since a ttp's constraints
could depend on outer parameters.

PR c++/111485

gcc/cp/ChangeLog:

* pt.cc (is_compatible_template_arg): New parameter 'args'.
Add the outer template arguments 'args' to 'new_args'.
(convert_template_argument): Pass 'args' to
is_compatible_template_arg.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp5.C: New test.
* g++.dg/cpp2a/concepts-ttp6.C: New test.

(cherry picked from commit 6f902a42b0afe3f3145bcb864695fc290b5acc3e)

21 months agoc++: constness of decltype of NTTP object [PR99631]
Patrick Palka [Tue, 19 Sep 2023 12:21:05 +0000 (08:21 -0400)] 
c++: constness of decltype of NTTP object [PR99631]

This corrects resolving decltype of a (class) NTTP object as per
[dcl.type.decltype]/1.2 and [temp.param]/6 in the type-dependent case.

Note that in the non-dependent case we resolve the decltype ahead of
time, in which case finish_decltype_type drops the const VIEW_CONVERT_EXPR
wrapper around the TEMPLATE_PARM_INDEX, and the latter has the desired
non-const type.

In the type-dependent case, at instantiation time tsubst drops the
VIEW_CONVERT_EXPR since the substituted NTTP is the already-const object
created by get_template_parm_object.  So in this case finish_decltype_type
sees the const object, which this patch now adds special handling for.

PR c++/99631

gcc/cp/ChangeLog:

* semantics.cc (finish_decltype_type): For an NTTP object,
return its type modulo cv-quals.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class60.C: New test.

(cherry picked from commit ddd064e3571c4a9e6258c75eba65585a07367712)

21 months agoFortran: Supply a missing dereference [PR92586]
Paul Thomas [Sun, 24 Sep 2023 14:34:57 +0000 (15:34 +0100)] 
Fortran: Supply a missing dereference [PR92586]

2023-09-24  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/92586
* trans-expr.cc (gfc_trans_arrayfunc_assign): Supply a missing
dereference for the call to gfc_deallocate_alloc_comp_no_caf.

gcc/testsuite/
PR fortran/92586
* gfortran.dg/pr92586.f90 : New test

21 months agoFortran: Pad mismatched charlens in component initializers [PR68155]
Paul Thomas [Sun, 24 Sep 2023 14:26:01 +0000 (15:26 +0100)] 
Fortran: Pad mismatched charlens in component initializers [PR68155]

2023-09-24  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/68155
* decl.cc (fix_initializer_charlen): New function broken out of
add_init_expr_to_sym.
(add_init_expr_to_sym, build_struct): Call the new function.

gcc/testsuite/
PR fortran/68155
* gfortran.dg/pr68155.f90: New test.

21 months agoDaily bump.
GCC Administrator [Sun, 24 Sep 2023 00:21:40 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Sat, 23 Sep 2023 00:22:19 +0000 (00:22 +0000)] 
Daily bump.

21 months agoc++: improve class NTTP object pretty printing [PR111471]
Patrick Palka [Wed, 20 Sep 2023 16:09:36 +0000 (12:09 -0400)] 
c++: improve class NTTP object pretty printing [PR111471]

1. Move class NTTP object pretty printing to a more general spot in
   the pretty printer, so that we always print its value instead of
   its (mangled) name even when it appears outside of a template
   argument list.
2. Print the type of an class NTTP object alongside its CONSTRUCTOR
   value, like dump_expr would have done.
3. Don't print const VIEW_CONVERT_EXPR wrappers for class NTTPs.

PR c++/111471

gcc/cp/ChangeLog:

* cxx-pretty-print.cc (cxx_pretty_printer::expression)
<case VAR_DECL>: Handle class NTTP objects by printing
their type and value.
<case VIEW_CONVERT_EXPR>: Strip const VIEW_CONVERT_EXPR
wrappers for class NTTPs.
(pp_cxx_template_argument_list): Don't handle class NTTP
objects here.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic19.C: New test.

(cherry picked from commit 75c4b0cde4835b45350da0a5cd82f1d1a0a7a2f1)

21 months agoDaily bump.
GCC Administrator [Fri, 22 Sep 2023 00:21:02 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Thu, 21 Sep 2023 00:22:00 +0000 (00:22 +0000)] 
Daily bump.

21 months agoaarch64: Fix loose ldpstp check [PR111411]
Richard Sandiford [Wed, 20 Sep 2023 10:07:50 +0000 (11:07 +0100)] 
aarch64: Fix loose ldpstp check [PR111411]

aarch64_operands_ok_for_ldpstp contained the code:

  /* One of the memory accesses must be a mempair operand.
     If it is not the first one, they need to be swapped by the
     peephole.  */
  if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
       && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
    return false;

But the requirement isn't just that one of the accesses must be a
valid mempair operand.  It's that the lower access must be, since
that's the access that will be used for the instruction operand.

gcc/
PR target/111411
* config/aarch64/aarch64.cc (aarch64_operands_ok_for_ldpstp): Require
the lower memory access to a mem-pair operand.

gcc/testsuite/
PR target/111411
* gcc.dg/rtl/aarch64/pr111411.c: New test.

(cherry picked from commit 2d38f45bcca62ca0c7afef4b579f82c5c2a01610)

21 months agoaarch64: Fix return register handling in untyped_call
Richard Sandiford [Wed, 20 Sep 2023 10:07:50 +0000 (11:07 +0100)] 
aarch64: Fix return register handling in untyped_call

While working on another patch, I hit a problem with the aarch64
expansion of untyped_call.  The expander emits the usual:

  (set (mem ...) (reg resN))

instructions to store the result registers to memory, but it didn't
say in RTL where those resN results came from.  This eventually led
to a failure of gcc.dg/torture/stackalign/builtin-return-2.c,
via regrename.

This patch turns the untyped call from a plain call to a call_value,
to represent that the call returns (or might return) a useful value.
The patch also uses a PARALLEL return rtx to represent all the possible
return registers.

gcc/
* config/aarch64/aarch64.md (untyped_call): Emit a call_value
rather than a call.  List each possible destination register
in the call pattern.

(cherry picked from commit 629efe27744d13c3b83bbe8338b84c37c83dbe4f)

21 months agoDaily bump.
GCC Administrator [Wed, 20 Sep 2023 00:21:54 +0000 (00:21 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Tue, 19 Sep 2023 00:21:28 +0000 (00:21 +0000)] 
Daily bump.