[COMMITTED] ada: Remove explicit decoration of wrapper created in freezing

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek We create wrapper functions associated with inherited functions with controlling results which are not overridden during freezing. We partly decorated them explicitly, even though they would be fully decorated later anyway. This early decoration didn't work as expected,

[COMMITTED] ada: Add missing guards for degenerate storage models

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) : Check that the storage model has Copy_From before instantiating loads for it. : Likewise. : Likewise. (gnat_to_gnu) : Likewise. : Likewise. Tested on x86_64-pc-linux-gnu,

[COMMITTED] ada: Fix bogus Storage_Error on dynamic array with static zero length

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This works around the limitations present for the support of arrays in the middle-end by clearing the TREE_OVERFLOW flag for arrays with zero length. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Use a local variable for the GNAT index type.

[COMMITTED] ada: Fix incorrect copies being used with 'Address

2023-05-30 Thread Marc Poulhiès via Gcc-patches
When using 'Address on an object with a size clause, gigi would end up creating a copy and using its address instead of the one of the original object, leading to incorrect behavior. Remove the conversion (that triggers the copy) when 'Address is applied to a declaration. gcc/ada/ *

[COMMITTED] ada: Fix minor issue with Mod operator

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) : Test the precision of the operation rather than that of the result type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/trans.cc | 8 1 file changed, 4 insertions(+),

[COMMITTED] ada: Make internal_error_function more robust

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * gcc-interface/misc.cc (internal_error_function): Be prepared for an input_location set to UNKNOWN_LOCATION. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/misc.cc | 22 -- 1 file changed, 16

[COMMITTED] ada: Adjust again the implementation of storage models

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The code generator must now be prepared to translate assignment statements to objects allocated with a storage model and that are not initialized yet. gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) : Tweak. (gnat_to_gnu) : Declare a local variable.

[COMMITTED] ada: Disable PIE mode during the build of the Ada front-end

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This also removes some obsolete stuff. gcc/ada/ * gcc-interface/Make-lang.in (ADA_CFLAGS): Move up. (ALL_ADAFLAGS): Add $(NO_PIE_CFLAGS). (ada/mdll.o): Remove. (ada/mdll-fil.o): Likewise. (ada/mdll-utl.o): Likewise. Tested on

[COMMITTED] ada: Simplify the implementation of storage models

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou As the additional temporaries required by the semantics of nonnative storage models are now created by the front-end, in particular for actual parameters and assignment statements, the corresponding code in gigi can be removed. gcc/ada/ * gcc-interface/trans.cc

[COMMITTED] ada: Fix internal error on qualified aggregate with storage model

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou It comes from a small oversight in get_storage_model_access. gcc/ada/ * gcc-interface/trans.cc (node_is_component): Remove parentheses. (node_is_type_conversion): New predicate. (get_atomic_access): Use it. (get_storage_model_access):

[COMMITTED] ada: Small cleanups and fixes in expansion of aggregates

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This streamlines the handling of qualified expressions in the expansion of aggregates and plugs a couple of loopholes that may cause memory leaks. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): Move the declaration of Typ to the beginning.

[COMMITTED] ada: Fix wrong expansion of array aggregate with noncontiguous choices

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Minor generic tweaks left and and right

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Replace integer_zero_node with null_pointer_node for pointer types. * gcc-interface/trans.cc (gnat_gimplify_expr) : Likewise. * gcc-interface/utils.cc

[COMMITTED] ada: Add System.Traceback.Symbolic.Module_Name support on AArch64 Linux

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Joel Brobecker This commit changes the runtime on aarch64-linux to use the Linux version of s-tsmona.adb, so as to add support for this functionality on aarch64-linux. gcc/ada/ * Makefile.rtl: Use libgnat/s-tsmona__linux.adb on aarch64-linux. Link libgnat with -ldl, as

[COMMITTED] ada: Fix internal error on array constant in expression function

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix wrong access for qualified aggregate with storage model

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The previous fix to get_storage_model_access was incomplete and needs to be extended to the node itself. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Also strip any type conversion in the node when unwinding the components. Tested on

[COMMITTED] ada: Fix storage model handling for dereference as lvalue and renamings

2023-05-30 Thread Marc Poulhiès via Gcc-patches
Don't require storage access for explicit dereferences used as lvalue (e.g. Some_Access.all'Address) or for renamings. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Don't require storage model access for dereference used as lvalue or renamings. Tested on

[COMMITTED] ada: Fix minor issues in user's guide

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Ronan Desplanques gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix minor issues. * doc/gnat_ugn/the_gnat_compilation_model.rst: Fix minor issues. * gnat_ugn.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Fix fallout of recent fix for missing finalization

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Make use of Cannot_Be_Superflat flag on N_Range nodes

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * gcc-interface/decl.cc (range_cannot_be_superflat): Return true immediately if Cannot_Be_Superflat is set. * gcc-interface/misc.cc (gnat_post_options): Do not override the -Wstringop-overflow setting. Tested on x86_64-pc-linux-gnu,

[COMMITTED] ada: Fix regression of secondary stack management in return statements

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Ensure Default_Stack_Size is greater than Minimum_Stack_Size

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Johannes Kliemann The Default_Stack_Size function does not check that the binder specified default stack size is greater than the minimum stack size for the runtime. This can result in tasks using default stack sizes less than the minimum stack size because the Adjust_Storage_Size only

[COMMITTED] ada: Only build access-to-subprogram wrappers when expander is active

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek For access-to-subprogram types with Pre/Post aspects we create a wrapper routine that evaluates these aspects. Spec of this wrapper was created always, while its body was only created when expansion was enabled. Now we only create these wrappers when expansion is enabled.

[COMMITTED] ada: Use generalized loop iteration in Put_Image routines

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * libgnat/a-cidlli.adb (Put_Image): Simplify. * libgnat/a-coinve.adb (Put_Image): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-cidlli.adb | 13 + gcc/ada/libgnat/a-coinve.adb | 13 + 2

[COMMITTED] ada: Fix visibility error with DIC or Type_Invariant aspect on generic type

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix coding style in init.c

2023-05-30 Thread Marc Poulhiès via Gcc-patches
From: Cedric Landet The coding style rules require to avoid using FIXME comments. ??? is preferred. gcc/ada/ * init.c: Replace FIXME by ??? Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git

Re: [COMMITTED] ada: Remove the body of System.Storage_Elements

2023-05-29 Thread Marc Poulhiès via Gcc-patches
Jan-Benedict Glaw writes: > (A full build log is at > http://toolchain.lug-owl.de/laminar/jobs/gcc-aarch64-linux/74) > > Is this an issue with the patch? Or does it need a newer Ada compiler > to for building it? Hello Jan, IIUC, your base compiler is "g++ (Debian 20230315-1) 13.0.1

[COMMITTED] ada: Use Code_Address attribute to determine subprogram addresses

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Patrick Bernardi The runtime used label addresses to determine the code address of subprograms because the subprogram's canonical address on some targets is a descriptor or a stub. Simplify the code by using the Code_Address attribute instead, which is designed to return the code address

[COMMITTED] ada: Set g-spogwa as a GNATRTL_SOCKETS_OBJS

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Cedric Landet g-spogwa.adb is the body of the procedure GNAT.Sockets.Poll.G_Wait. This is a socket specific procedure. It should only be built for systems that support sockets. gcc/ada/ * Makefile.rtl: Move g-spogwa$(objext) from GNATRTL_NONTASKING_OBJS to

[COMMITTED] ada: Define sigset for systems that does not suport sockets

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Cedric Landet In s-oscons-tmplt.c, sigset is defined inside the HAVE_SOCKETS bloc. A platform could require sigset without supporting sockets. gcc/ada/ * s-oscons-tmplt.c: move the definition of sigset out of the HAVE_SOCKETS bloc. Tested on x86_64-pc-linux-gnu,

[COMMITTED] ada: Remove extra whitespace from FOR loops

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Whitespace cleanup. gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst (Some Useful Memory Pools): Remove extra whitespace from examples. * sem_aggr.adb (Make_String_Into_Aggregate): Remove extra whitespace. * gnat_ugn.texi: Regenerate.

[COMMITTED] ada: Call idiomatic routine in Expand_Simple_Function_Return

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix spurious error on imported generic function with precondition

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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. Tested on

[COMMITTED] ada: Cleanup detection of type support subprogram entities

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Avoid repeated calls to Get_TSS_Name. Code cleanup related to handling of dispatching operations in GNATprove; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Convert_Aggr_In_Allocator): Replace Get_TSS_Name with a high-level Is_TSS. * sem_ch6.adb

[COMMITTED] ada: Fix bogus error on conditional expression with only user-defined literals

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix wrong finalization for case expression in expression function

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Fix memory leak in expression function returning Big_Integer

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix small fallout of previous change

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 10 ++ 1

[COMMITTED] ada: Fix remaining failures in Roman Numbers test

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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/ *

[COMMITTED] ada: Attach pre/post on access-to-subprogram to internal subprogram type

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Aspects Pre/Post that annotate access-to-subprogram type were attached to the source entity (whose kind is either E_Access_Subprogram_Type or E_Access_Protected_Subprogram_Type). However, it is more convenient to attach them to the internal entity (whose kind is

[COMMITTED] ada: Fix wrong finalization for loop on indexed container

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix internal error with pragma Compile_Time_{Warning, Error}

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Allow attributes like First and Last to be read in Exceptional_Cases

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Attributes that do not read data from the object can be safely used in consequences of Exceptional_Cases regardless of the parameter passing mode. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Relax rules for Exceptional_Cases. Tested on x86_64-pc-linux-gnu,

[COMMITTED] ada: Fix crash on semi-recursive call in access-to-subprogram contract

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Calls to access-to-subprogram from its own pre/post aspects are rejected as illegal, e.g.: type F is access function (X : Natural) return Boolean with Pre => F.all (X); but they caused an assertion failure in detection of recursive calls. Now they are properly

[COMMITTED] ada: Fix small fallout of previous change

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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.

[COMMITTED] ada: Fix memory leak in multi-dimensional array aggregate of Vector

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou It comes from a superfluous adjustment for subarray components. gcc/ada/ * exp_aggr.adb (Initialize_Array_Component): Fix condition detecting the nested case that requires an adjustment. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Default_Component_Value trumps Initialize/Normalize_Scalars

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Steve Baird If the Default_Component_Value aspect is specified for an array type, then specifying Initialize_Scalars or Normalize_Scalars should have no effect on the default initialization of an object of the array type. gcc/ada/ * exp_ch3.adb

[COMMITTED] ada: Fix wrong result for membership test of null in null-excluding access type

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 8 +--- 1 file changed, 5 insertions(+), 3

[COMMITTED] ada: Remove redundant protection against empty lists

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Calls to First on No_List intentionally return Empty, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Check_Function_Writable_Actuals): Remove guard against a membership test with no

[COMMITTED] ada: Fix wrong finalization for call to BIP function in conditional expression

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Restore parent link for both lists and nodes in class-wide condition

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek When preanalysing class-wide conditions, we restore "Function (Object)" to its original "Object.Function" notation. This requires the Parent links to be fixed. We did it for nodes; now we do it for lists as well. This patch is enough to fix assertion failure in CCG and to

[COMMITTED] ada: Accept parameters of enclosing subprograms in exceptional cases

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Rules about parameters of modes OUT and IN OUT in aspect Exceptional_Cases only apply to the parameters of the current subprogram. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Refine rules for Exceptional_Cases. Tested on x86_64-pc-linux-gnu, committed on master.

[COMMITTED] ada: Repair support for user-defined literals in arithmetic operators

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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.

[COMMITTED] ada: Reuse routine for getting from body entity to spec entity

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Cleanup related to handling of access-to-subprogram types with Pre and Post aspects. Behavior is unaffected. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Replace low-level navigation with a high-level Unique_Entity. Tested on x86_64-pc-linux-gnu,

[COMMITTED] ada: Fix crash on vector initialization

2023-05-29 Thread Marc Poulhiès via Gcc-patches
Initializing a vector using Vec : V.Vector := [Some_Type'(Some_Abstract_Type with F => 0)]; may crash the compiler. The expander marks the N_Extension_Aggregate for delayed expansion which never happens and incorrectly ends up in gigi. The delayed expansion is needed for nested aggregates,

[COMMITTED] ada: Tune message for missing 'Result in Contract_Cases

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Make the message consistent with the one for postcondition. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Tune message. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

[COMMITTED] ada: Crash on aggregate for tagged record with discriminants

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda The frontend may crash processing an aggregate initializing a derived tagged record type that has discriminants. gcc/ada/ * sem_aggr.adb (Resolve_Record_Aggregate): For aggregates of derived tagged record types with discriminants, when collecting

[COMMITTED] ada: Fix spurious error on nested instantiations with generic renaming

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Tune message for pre/post on access-to-subprogram in old Ada

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Fix grammar in error message; make it consistent with a similar message for pre/postcondition on formal subprogram. gcc/ada/ * sem_prag.adb (Analyze_Pre_Post_Condition): Tune error message. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Fix retrieval of spec entity from entry body entity

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek When retrieving entities of subprogram spec we only handled functions and procedures, but not entries. This had no consequences, because we then only applied checks to functions, but still is worth a cleanup, so the code is easier to adapt for access-to-subprogram entities

[COMMITTED] ada: Refining handling of inlining for CCG

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Arnaud Charlet By marking relevant functions inline when -gnatn is used. gcc/ada/ * sem_ch7.adb: Refine handling of inlining for CCG Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch7.adb | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff

[COMMITTED] ada: Spurious error on string interpolation

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda The frontend reports spurious errors on operators found in interpolated string literals. gcc/ada/ * scans.ads (Inside_Interpolated_String_Expression): New variable. * par-ch2.adb (P_Interpolated_String_Literal): Set/clear new variable when parsing

[COMMITTED] ada: Add QNX specific version of System.Parameters

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Johannes Kliemann The QNX runtimes used the default implementation of System.Parameters that defines a default stack size of 2 MB. The QNX specific version uses the QNX default stack size of 256 KB instead. gcc/ada/ * Makefile.rtl (QNX): Use s-parame__qnx.adb for s-parame.adb.

[COMMITTED] ada: Simplify removal of formals from the scope

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Calls to Install_Formals are typically enclosed by Push_Scope/End_Scope. There were just two such calls that instead used Pop_Scope, but most likely that was by mistake. Cleanup related to handling of class-wide contracts. Behavior appears to be unaffected. gcc/ada/

[COMMITTED] ada: Restore SPARK_Mode On for numerical functions

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy GNATprove has ad-hoc support for the standard numerical functions, which consists in emitting an unprovable preconditions on cases which could lead to an overflow. These functions are thus valid to call from SPARK code. gcc/ada/ * libgnat/a-ngelfu.ads: Restore

[COMMITTED] ada: Analyze pre/post on access-to-subprogram without a wrapper

2023-05-29 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Aspects Pre/Post attached to an access-to-subprogram type were relocated to a spec of a wrapper subprogram and analyzed there; the body of the wrapper was only created with expansion enabled. However, there were several problems with this approach. When switch -gnat2022 was

[COMMITTED] ada: Fix restoration of parent link

2023-05-29 Thread Marc Poulhiès via Gcc-patches
When resetting the parent link after having restored the selected component node, the assertion used was incorrectly triggered when the traversal hits the members of the parameters association list, as in: This.Some_Func (Param1, Param2).Dispatching_Call When restoring the selected component

[COMMITTED] ada: Use truncation for dynamic conversions from floating point to fixed point

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This changes the implementation of dynamic conversions from floating-point to ordinary fixed-point types, from rounding (to the nearest number) to truncation (toward zero), so as to make them consistent with both static conversions between these types and also the value of

[COMMITTED] ada: Crash on function returning allocated object containing tasks

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda The frontend crashes when a function returns an object of a limited type that may have task components, has discriminants, and the object is created with an allocator. gcc/ada/ * exp_ch4.adb (Expand_N_Allocator): If an allocator with constraints is called

[COMMITTED] ada: Complete contracts of SPARK units

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy SPARK units in the standard library (both Ada and GNAT ones) should have subprograms correctly annotated with contracts, so that a SPARK subprogram should always return (not fail or raise an exception) under the conditions expressed in its precondition, unless it is a procedure

[COMMITTED] ada: Remove redundant guard against empty lists

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek There is no need to guard against routine Contains being called on No_Elist, because it will return False. Code cleanup related to handling of primitive operations in GNATprove; semantics is unaffected. gcc/ada/ * sem_prag.adb (Record_Possible_Body_Reference):

[COMMITTED] ada: Fix double free on finalization of Vector in array aggregate

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The handling of finalization is delicate during the expansion of aggregates since the generated assignments must not cause the finalization of the RHS. That's why the No_Ctrl_Actions flag is set on them and the adjustments are generated manually. This was not done in the

[COMMITTED] ada: Remove leftover code for counting protected entries

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek We used to count protected entries by iterating over component declarations, but then switched to iterating over entities and left some code that is no longer needed. Cleanup; semantics is unaffected (maybe except fixing an assertion failure in developer builds when there is

[COMMITTED] ada: Reorder components in Ada.Containers.Bounded_Doubly_Linked_Lists

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * libgnat/a-cbdlli.ads (List): Move Nodes component to the end. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/a-cbdlli.ads | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/a-cbdlli.ads

[COMMITTED] ada: Corrections to premature-references rules

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff This patch corrects the implementation of RM-8.3(17), which says that a record extension is self-hidden until "record". Previously, such premature references could cause a compiler crash. gcc/ada/ * sem_ch3.adb (Build_Derived_Record_Type): Temporarily set the

[COMMITTED] ada: Fix crash on 'Img as generic actual function

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff 'Image is allowed as an actual for a generic formal function. This patch fixes a crash when 'Img is used instead of 'Image in that context. Misc cleanups. gcc/ada/ * exp_put_image.adb (Build_Image_Call): Treat 'Img the same as 'Image. * exp_imgv.adb

[COMMITTED] ada: Reject thin 'Unrestricted_Access value to aliased constrained array

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Fix typos "statment" and "condtion"

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff ...caused by moving code here from Atree. gcc/ada/ * einfo.ads: Add comma. * contracts.adb: Fix typos. * exp_attr.adb: Likewise. * exp_ch5.adb: Likewise. * exp_ch6.adb: Likewise. * lib-xref.adb: Likewise. Tested on

[COMMITTED] ada: Simplify iteration over record component items with possible pragmas

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Is_Null_Record_Definition): Use First_Non_Pragma and Next_Non_Pragma to ignore pragmas within component list. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 6

[COMMITTED] ada: Fix detection of non-static expressions in records with pragmas

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek When iterating over record components we must ignore pragmas. Minor bug, as pragmas within record components do not appear often. gcc/ada/ * sem_cat.adb (Check_Non_Static_Default_Expr): Detect components inside loop, not in the loop condition itself.

[COMMITTED] ada: Default initialize entity to avoid CodePeer message

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy CodePeer issues a false alarm when reading local entity Component later if not initialized by default. Fix this. gcc/ada/ * sem_aggr.adb (Resolve_Record_Aggregate): Add dummy initialization and assertion that clarifies when we reassigned to a useful value.

[COMMITTED] ada: Fix internal error on Big_Integer conversion ghost instance

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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

[COMMITTED] ada: Cleanups in handling of aggregates

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Assorted cleanups related to recent fixes of aggregate handling for GNATprove; semantics is unaffected. gcc/ada/ * sem_aggr.adb (Resolve_Record_Aggregate): Remove useless assignment. * sem_aux.adb (Has_Variant_Part): Remove useless guard;

[COMMITTED] ada: Fix handling of Global contracts inside generic subprograms

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Routine Get_Argument works differently for generic units (as explained in its comment), but it failed to reliably detect such units when their kind is temporarily made non-generic (for resolving recursive calls, as explained in the comment at the end of

[COMMITTED] ada: Minor doc clarification

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy Pattern Matching extension does not apply yet to case expressions. This is worth stating clearly, as this is a natural use of pattern matching to program in more functional style. gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst: Be more explicit on pattern

[COMMITTED] ada: Cleanup expansion of membership operators into attribute Valid

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch4.adb (Is_OK_Object_Reference): Replace loop with a call to Unqual_Conv; consequently, change object from variable to constant; replace an IF statement with an AND THEN expression. Tested on

[COMMITTED] ada: Fix iteration over component items with pragmas

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Component items in a record declaration might include pragmas, which must be ignored when detecting components with default expressions. More a code cleanup than a bugfix, as it only affects artificial corner cases. Found while fixing missing legality checks for variant

[COMMITTED] ada: Tune detection of expression functions within a declare expression

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * sem_ch4.adb (Check_Action_OK): Replace low-level test with a high-level routine. * sem_ch13.adb (Is_Predicate_Static): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Simplify expansion of set membership

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch4.adb (Expand_Set_Membership): Simplify by using Evolve_Or_Else. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 17 +++-- 1 file changed, 7 insertions(+), 10

[COMMITTED] ada: Reorder components in Ada.Containers.Restricted_Doubly_Linked_Lists

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou An instantiation of the package compiled with -gnatw.q yields: warning: in instantiation at a-crdlli.ads:317 [-gnatw.q] warning: record layout may cause performance issues [-gnatw.q] warning: in instantiation at a-crdlli.ads:317 [-gnatw.q] warning: component

[COMMITTED] ada: Minor tweak in condition

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * sem_util.adb (Compile_Time_Constraint_Error): Test the Ekind. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb

[COMMITTED] ada: Crash on loop in dispatching conditional entry call

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda gcc/ada/ * exp_ch9.adb (Expand_N_Conditional_Entry_Call): Factorize code to avoid duplicating subtrees; required to avoid problems when the copied code has implicit labels. * sem_util.ads (New_Copy_Separate_List): Removed.

[COMMITTED] ada: Duplicate declaration of _master entity

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda gcc/ada/ * exp_ch9.adb (Build_Class_Wide_Master): Remember internal blocks that have a task master entity declaration. (Build_Master_Entity): Code cleanup. * sem_util.ads (Is_Internal_Block): New subprogram. * sem_util.adb

[COMMITTED] ada: Remove redundant protection against empty lists

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Calls to Length on No_List intentionally return 0, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * sem_ch13.adb (Check_Component_List): Local variable Compl is now a constant; a nested block is no longer

[COMMITTED] ada: Simplify expansion of positional aggregates

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Constrained_Type): Use List_Length to count expressions in consecutive subaggregates. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 12 +++- 1

[COMMITTED] ada: Remove redundant guards from handling of record components

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Call to First on empty list is intentionally returning Empty. gcc/ada/ * sem_util.adb (Gather_Components): Remove guard for empty list of components. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 7 +-- 1 file

[COMMITTED] ada: Remove Is_Descendant_Of_Address flag from Standard_Address

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou It breaks the Allow_Integer_Address special mode. Add new standard_address parameters to gigi and alphabetize others, this is necessary when addresses are not treated like integers. gcc/ada/ * back_end.adb (Call_Back_End): Add gigi_standard_address to the

[COMMITTED] ada: Use context variables in expansion of aggregates

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Constrained_Type): Remove local constants that were shadowing equivalent global constants; replace a wrapper that calls Make_Integer_Literal with a numeric literal; remove

[COMMITTED] ada: Use computed value from os_constants to define sigset_t

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Doug Rupp Remove hard coded definition and conform to standard usage of using computed os_constants for opaque type declarations. gcc/ada/ * libgnarl/s-osinte__qnx.ads (sigset_t): Modify declaration to use system.os_constants computed value. Align it. Tested on

[COMMITTED] ada: Fix missing finalization in library-level instance body

2023-05-26 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This extends the delaying mechanism present in the cases where the instance is not at library level, so as to wait until after the instantiation of the body is performed, before generating the finalizer of the compilation unit. gcc/ada/ * einfo.ads (Delay_Cleanups):

<    4   5   6   7   8   9   10   11   12   13   >