[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 f

[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: 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 SPARK_Mo

[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: 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 in

[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: 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: 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 as

[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. --- gcc/ada/sem_prag.

[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 (Copy_Gener

[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 com

[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: 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, whic

[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: 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: 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: 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 ma

[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 call

[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 alterna

[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: 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 (Expand_N_Object_Declaration

[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. --- gcc/ada/exp_a

[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. Te

[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 reco

[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, commit

[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: 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 creat

[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 E_Subprogram_

[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/ * sem

[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 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 (Establish_Transient_Sc

[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 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: 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 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 x86_64-pc-linux-gnu

[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 (Expand_Simple_Function_Ret

[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. T

[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

[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 GNATRTL_SOCKETS_

[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 of

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 20230315"

[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 a/g

[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 expr

[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: 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. In

[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 adju

[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 functi

[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, c

[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 (Find_Enclosing

[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. --- ...build

[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 x86_64-pc

[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 x86_64-

[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 problemat

[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 th

[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 (maybe_pad_ty

[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 th

[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. (Initiali

[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): Likewise

[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 (Call

[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 x86_64-p

[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: 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 inse

[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: 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/ * gcc-i

[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: 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, c

[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, beca

[COMMITTED] ada: Simplify appending to a newly created list

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_disp.adb (Make_Disp_Asynchronous_Select_Spec): Use a single call to New_List. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_disp.adb | 6 +++--- 1 file changed, 3 insertions(+), 3

[COMMITTED] ada: Fix expansion of aggregates with controlled components

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The expansion is incorrect in the case where the initialization expression of a component is a conditional expression that has a function call as one of its dependent expressions, leading to a wrong order of initialization, adjustment and finalization. gcc/ada/ * exp

[COMMITTED] ada: Factor out tag assignments from type in expander

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou They are performed in a few different places during expansion. gcc/ada/ * exp_util.ads (Make_Tag_Assignment_From_Type): Declare. * exp_util.adb (Make_Tag_Assignment_From_Type): New function. * exp_aggr.adb (Build_Record_Aggr_Code): Call the above func

[COMMITTED] ada: Tune style in detection of writable function actuals

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Check_Function_Writable_Actuals): Tune style; use subtype name to detect membership test nodes. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 10 ++ 1 file

[COMMITTED] ada: Factor common processing in expansion of aggregates

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The final processing at the component level of array aggregates and record aggregates is very similar, so this factors out the common processing into three new library-level subprograms. There should be no functional changes, but the expanded code may be changed in the case o

[COMMITTED] ada: Add No_Elaboration_Code_All pragma to System.Storage_Elements

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Daniel King Allows System.Storage_Elements to be used in units that have the No_Elaboration_Code_All restriction. gcc/ada/ * libgnat/s-stoele.ads: Add No_Elaboration_Code_All pragma. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-stoele.ads | 3 +++ 1

[COMMITTED] ada: Cleanup expansion of locally handled exception handlers

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup related to handling exceptions in GNATprove; semantics is unaffected. gcc/ada/ * exp_ch11.ads (Find_Local_Handler): Fix typo in comment. * exp_ch11.adb (Find_Local_Handler): Remove redundant check for the Exception_Handler list being pre

[COMMITTED] ada: Small housekeeping work in expansion of extension aggregates

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This avoids repeatedly calling Unqualify on the same node, removes a dead call to Generate_Finalization_Actions, a redundant setting of Assignment_OK and reuses a local variable more consistently. No functional changes. gcc/ada/ * exp_aggr.adb (Build_Record_Aggr_Cod

[COMMITTED] ada: Fix wrong expansion of limited extension aggregate

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This happens when the ancestor part is itself an aggregate: in this case, the tag of the extension aggregate is wrongly set to that of the ancestor. gcc/ada/ * exp_aggr.adb (Build_Record_Aggr_Code): In the case of an extension aggregate of a limited type whos

[COMMITTED] ada: Cleanup finding of locally handled exception handlers

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup related to handling exceptions in GNATprove; semantics is unaffected. gcc/ada/ * exp_ch11.adb (Find_Local_Handler): Replace guard against other constructs appearing in the list of exception handlers with iteration using First_Non_Pragma/

[COMMITTED] ada: Remove obsolete code in Analyze_Assignment

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This code was dealing with build-in-place calls for nonlimited types, but they no longer exist since Is_Build_In_Place_Result_Type => Is_Limited_View. gcc/ada/ * sem_ch5.adb (Analyze_Assignment): Turn Rhs into a constant and remove calls to the following subp

[COMMITTED] ada: Fix internal error on imported function with post-condition

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

[COMMITTED] ada: Remove wrong comment about expansion of exceptions for GNATprove

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Code cleanup related to handling exceptions in GNATprove. gcc/ada/ * exp_ch11.adb (Expand_N_Raise_Statement): Expansion of raise statements never happens in GNATprove mode. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch11.adb | 8 +

[COMMITTED] ada: Remove unreferenced routine Is_Inherited_Operation_For_Type

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Remove routine that is no referenced after deconstructing of restriction SPARK_05. gcc/ada/ * sem_util.ads (Is_Inherited_Operation_For_Type): Remove spec. * sem_util.adb (Is_Inherited_Operation_For_Type): Remove body. Tested on x86_64-pc-linux-gnu, committe

[COMMITTED] ada: Fix exception raised on invalid contract in generic package

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

[COMMITTED] ada: Add missing ss_mark/ss_release in quantified expressions

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff If a quantified expression says "for all ... of F(...)" where F(...) is a function call that returns on the secondary stack, we need to clean up the secondary stack. This patch adds the required ss_mark/ss_release in that case. gcc/ada/ * exp_ch4.adb (Expand_N_Qua

[COMMITTED] ada: Use ghost predicate in standard library

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy In preparation for attribute Initialized to become ghost, use aspect Ghost_Predicate instead of Predicate in unit Ada.Strings.Superbounded of the standard library. gcc/ada/ * libgnat/a-strsup.ads: Change predicate aspect. * sem_ch13.adb (Add_Predicate): Fix for

[COMMITTED] ada: Streamline expansion of controlled actions for aggregates

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This changes the strategy used to expand controlled actions for array and record aggregates so as to make it simpler and more robust. The current strategy is to set the No_Ctrl_Actions flag on the assignments generated during the expansion of aggregate, as done during the exp

[COMMITTED] ada: Skip elaboration checks for abstract subprograms on derived types

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Elaboration checks skip abstract subprogram declarations, which have no body that could be examined. Now these checks also skip abstract subprograms of a derived type, which have no body either. gcc/ada/ * sem_elab.adb (Check_Overriding_Primitive): Prevent Correspon

[COMMITTED] ada: Mark attribute Initialized as ghost code

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Yannick Moy Implement the SPARK RM change that defines attribute Initialized as being ghost, i.e. only allowed where a ghost entity would be allowed. gcc/ada/ * ghost.adb (Check_Ghost_Context): Allow absence of Ghost_Id for attribute. Update error message to mention Ghost_

[COMMITTED] ada: Implement new aspect Always_Terminates for SPARK

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek This patch allows subprograms to be annotated with aspect Always_Terminates that requires a boolean expression. When this expression evaluates to True, the subprogram is required to terminate or raise an exception, but not loop infinitely. This aspect is only meant to be use

[COMMITTED] ada: Fix spurious error on call to function returning private in generic

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The spurious error is given on a call to a parameterless function returning a private type, present in the body of a generic construct both declared and instantiated in the presence of the full view of the type, because this full view is not properly restored for the instantia

[COMMITTED] ada: Disable inlining in potentially unevaluated contexts

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Instead of explicitly disabling inlining in quantified expressions, (which happen to be only preanalysed) and then disabling inlining in potentially unevaluated contexts that are fully analysed (which happen to include quantified expressions), we now simply disable inlining i

[COMMITTED] ada: Fix iterated component initialization

2023-06-13 Thread Marc Poulhiès via Gcc-patches
The call to Resolve_Aggr_Expr may leave references to temporary entities used to check for the construct legality and meant to be removed. Using Preanalyze_And_Resolve correctly guarantees that there is no visible occurrence of such entities. gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Com

[COMMITTED] ada: Recognize iterated_component_association as potentially unevaluated

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Routine Is_Potentially_Unevaluated was written for Ada 2012, but now we use it for Ada 2022 as well, so it must recognize iterated component associations (which were added by Ada 2022) as an array component association. gcc/ada/ * sem_util.adb (Is_Potentially_Uneval

[COMMITTED] ada: Recognize iterated_component_association as repeatedly evaluated

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek As iterated_component_association is an array_component_association (because of a grammar rule Ada 2022 RM 4.3.3(5/5)), its expression is repeatedly evaluated (because of Ada 2022 RM 6.1.1(22.14/5)). With this patch we will now get errors for both conjuncts in this code, whi

[COMMITTED] ada: Fix another case of missing Has_Private_View flag

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou It occurs for the case of a function call first parsed as an identifier. gcc/ada/ * sem_ch12.adb (Save_References_In_Identifier): In the case where the identifier has been turned into a function call by analysis, call Set_Global_Type on the entity if

[COMMITTED] ada: Fix decoration of iterated component association for GNATprove

2023-06-13 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek This patch is an alternative solution for a recent fix in analysis of iterated component association. To recap, if the iterated expression is an aggregate, we want to propagate the component type downward with a call to Resolve_Aggr_Expr; otherwise we want this expression to

[COMMITTED] ada: Cleanup analysis of iterated component association

2023-06-15 Thread Marc Poulhiès via Gcc-patches
From: Piotr Trojanek Cleanups related to analysis of iterated component association for GNATprove. gcc/ada/ * sem_aggr.adb (Resolve_Array_Aggregate): Simplify comment. (Resolve_Iterated_Component_Association): Tune comment; change variable to constant. Tested on

[COMMITTED] ada: Remove obsolete references for Build_Transient_Object_Statements

2023-06-15 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou gcc/ada/ * exp_util.ads (Build_Transient_Object_Statements): Remove obsolete references to array and record aggregates in documentation. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_util.ads | 6 +++--- 1 file changed, 3 insertions(+)

[COMMITTED] ada: Crash on C++ constructor of private type

2023-06-15 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda The compiler crashes compiling a function that has pragma CPP_constructor when its return type is a private type. gcc/ada/ * sem_util.adb (Is_CPP_Constructor_Call): Add missing support for calls to functions returning a private type. Tested on x86_6

[COMMITTED] ada: Fix inverted implementation of RM 8.4(10) clause for operators

2023-06-15 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_type.ad

[COMMITTED] ada: Fix aspect Linker_Section ignored on subprogram body

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

  1   2   3   4   5   6   7   8   9   >