aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2023-07-18ada: Fix expanding container aggregates with Iterator specificationViljar Indus1-2/+5
The compiler should use unnamed addition methods such as Append when expanding a container aggregate with Iterator Specification. gcc/ada/ * exp_aggr.adb (Expand_Container_Aggregate): Use the positional addition method only when dealing with a container aggregate without an Iterator Specification e.g. with a loop parameter specification
2023-07-18ada: Improve error message for ambiguous subprogram callEric Botcazou3-8/+21
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.
2023-07-18ada: Constraint_Error caused by interface conversionJavier Miranda1-90/+4
When the sources have a type conversion from an interface type T2 to some ancestor interface type T1 (that is, T2 extends T1) the tag check added by the compiler may fail at runtime. gcc/ada/ * exp_disp.adb (Has_Dispatching_Constructor_Call): Removed. (Expand_Interface_Conversion): Reverse patch.
2023-07-18ada: Tweak CPU affinity handling on LinuxRonan Desplanques1-31/+7
Before this patch, the run-time assumed that not specifying a CPU affinity mask when creating a thread was equivalent to specifying a CPU affinity mask that included all CPUs. As documented in the man pages for pthread_create and pthread_setaffinity_np, this assumption is incorrect: a thread created using pthread_create inherits the CPU affinity mask of the creating thread by default. There was a comment in Set_Task_Affinity that acknowledged this behavior, but the actual code made the erroneous assumption mentioned above. That assumption caused the run-time to behave incorrectly when tasks were explicity assigned to Not_A_Specific_CPU: those tasks were assigned to the same CPUs as their parents instead of being allowed to run on any CPU. This patch fixes that behavior. This patch has the negative effect of making the runtime issue sched_setaffinity syscalls that are not necessary. gcc/ada/ * libgnarl/s-taprop__linux.adb (Set_Task_Affinity, Create_Task): Tweak handling of CPU affinities.
2023-07-18ada: Fix internal error on aggregates of self-referencing typesEric Botcazou3-13/+18
The front-end contains a specific mechanism to deal with aggregates of self-referencing types by means of the Has_Self_Reference flag, which is supposed to be set during semantic analysis and used during expansion. The problem is that the first part overlooks aggregates of derived types which implicitly contain references to an ancestor type (the second part uses a broader condition but it is effectively guarded by the first one). This changes both parts to use the same condition based on the Is_Ancestor predicate, which seems to implement the expected semantic in this case. gcc/ada/ * sem_type.ads (Is_Ancestor): Remove mention of tagged type. * exp_aggr.adb: Add with and use clauses for Sem_Type. (Build_Record_Aggr_Code.Replace_Type): Call Is_Ancestor to spot self-references to the type of the aggregate. * sem_aggr.adb (Resolve_Record_Aggregate.Add_Discriminant_Values): Likewise.
2023-07-18ada: Fix assertion failure introduced by latest changeEric Botcazou1-4/+5
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.
2023-07-18ada: Expose expected_throw attributeAlexandre Oliva6-5/+146
Mark exception-raising subprograms with expected_throw attribute. Document the use of the attribute in Control Flow Redundancy. Enable marking subprograms as expected_throw with Machine_Attribute pragmas. gcc/ada/ * libgnat/a-except.ads (Raise_Exception): Mark expected_throw. (Reraise_Occurrence): Likewise. (Raise_Exception_Always): Likewise. (Raise_From_Controlled_Operation): Likewise. (Reraise_Occurrence_Always): Likewise. (Reraise_Occurrence_No_Defer): Likewise. * libgnat/a-except.adb (Exception_Propagation.Propagate_Exception): Likewise. (Complete_And_Propagate_Occurrence): Likewise. (Raise_Exception_No_Defer): Likewise. (Raise_From_Signal_Handler): Likewise. (Raise_With_Msg): Likewise. (Raise_With_Location_And_Msg): Likewise. (Raise_Constraint_Error): Likewise. (Raise_Constraint_Error_Msg): Likewise. (Raise_Program_Error): Likewise. (Raise_Program_Error_Msg): Likewise. (Raise_Storage_Error): Likewise. (Raise_Storage_Error_Msg): Likewise. (Reraise, Rcheck_*): Likewise. * doc/gnat_rm/security_hardening_features.rst (Control Flow Hardening): Note the influence of expected_throw. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate. * gcc-interface/utils.cc (handle_expected_throw_attribute): New. (gnat_internal_attribute_table): Add expected_throw.
2023-07-18ada: Refactor s-pack* units to remove multiple returnsVasiliy Fofanov120-4248/+4071
The aim of this refactoring is to replace multiple returns from branches of case and if statements by a single return statement with a conditional expression. This is more readable and maintainable, and also conformant with a Highly Recommended design principle of ISO 26262-6. gcc/ada/ * libgnat/s-pack03.adb: Update copyright year; refactor return statements. * libgnat/s-pack05.adb: Likewise. * libgnat/s-pack06.adb: Likewise. * libgnat/s-pack07.adb: Likewise. * libgnat/s-pack09.adb: Likewise. * libgnat/s-pack10.adb: Likewise. * libgnat/s-pack100.adb: Likewise. * libgnat/s-pack101.adb: Likewise. * libgnat/s-pack102.adb: Likewise. * libgnat/s-pack103.adb: Likewise. * libgnat/s-pack104.adb: Likewise. * libgnat/s-pack105.adb: Likewise. * libgnat/s-pack106.adb: Likewise. * libgnat/s-pack107.adb: Likewise. * libgnat/s-pack108.adb: Likewise. * libgnat/s-pack109.adb: Likewise. * libgnat/s-pack11.adb: Likewise. * libgnat/s-pack110.adb: Likewise. * libgnat/s-pack111.adb: Likewise. * libgnat/s-pack112.adb: Likewise. * libgnat/s-pack113.adb: Likewise. * libgnat/s-pack114.adb: Likewise. * libgnat/s-pack115.adb: Likewise. * libgnat/s-pack116.adb: Likewise. * libgnat/s-pack117.adb: Likewise. * libgnat/s-pack118.adb: Likewise. * libgnat/s-pack119.adb: Likewise. * libgnat/s-pack12.adb: Likewise. * libgnat/s-pack120.adb: Likewise. * libgnat/s-pack121.adb: Likewise. * libgnat/s-pack122.adb: Likewise. * libgnat/s-pack123.adb: Likewise. * libgnat/s-pack124.adb: Likewise. * libgnat/s-pack125.adb: Likewise. * libgnat/s-pack126.adb: Likewise. * libgnat/s-pack127.adb: Likewise. * libgnat/s-pack13.adb: Likewise. * libgnat/s-pack14.adb: Likewise. * libgnat/s-pack15.adb: Likewise. * libgnat/s-pack17.adb: Likewise. * libgnat/s-pack18.adb: Likewise. * libgnat/s-pack19.adb: Likewise. * libgnat/s-pack20.adb: Likewise. * libgnat/s-pack21.adb: Likewise. * libgnat/s-pack22.adb: Likewise. * libgnat/s-pack23.adb: Likewise. * libgnat/s-pack24.adb: Likewise. * libgnat/s-pack25.adb: Likewise. * libgnat/s-pack26.adb: Likewise. * libgnat/s-pack27.adb: Likewise. * libgnat/s-pack28.adb: Likewise. * libgnat/s-pack29.adb: Likewise. * libgnat/s-pack30.adb: Likewise. * libgnat/s-pack31.adb: Likewise. * libgnat/s-pack33.adb: Likewise. * libgnat/s-pack34.adb: Likewise. * libgnat/s-pack35.adb: Likewise. * libgnat/s-pack36.adb: Likewise. * libgnat/s-pack37.adb: Likewise. * libgnat/s-pack38.adb: Likewise. * libgnat/s-pack39.adb: Likewise. * libgnat/s-pack40.adb: Likewise. * libgnat/s-pack41.adb: Likewise. * libgnat/s-pack42.adb: Likewise. * libgnat/s-pack43.adb: Likewise. * libgnat/s-pack44.adb: Likewise. * libgnat/s-pack45.adb: Likewise. * libgnat/s-pack46.adb: Likewise. * libgnat/s-pack47.adb: Likewise. * libgnat/s-pack48.adb: Likewise. * libgnat/s-pack49.adb: Likewise. * libgnat/s-pack50.adb: Likewise. * libgnat/s-pack51.adb: Likewise. * libgnat/s-pack52.adb: Likewise. * libgnat/s-pack53.adb: Likewise. * libgnat/s-pack54.adb: Likewise. * libgnat/s-pack55.adb: Likewise. * libgnat/s-pack56.adb: Likewise. * libgnat/s-pack57.adb: Likewise. * libgnat/s-pack58.adb: Likewise. * libgnat/s-pack59.adb: Likewise. * libgnat/s-pack60.adb: Likewise. * libgnat/s-pack61.adb: Likewise. * libgnat/s-pack62.adb: Likewise. * libgnat/s-pack63.adb: Likewise. * libgnat/s-pack65.adb: Likewise. * libgnat/s-pack66.adb: Likewise. * libgnat/s-pack67.adb: Likewise. * libgnat/s-pack68.adb: Likewise. * libgnat/s-pack69.adb: Likewise. * libgnat/s-pack70.adb: Likewise. * libgnat/s-pack71.adb: Likewise. * libgnat/s-pack72.adb: Likewise. * libgnat/s-pack73.adb: Likewise. * libgnat/s-pack74.adb: Likewise. * libgnat/s-pack75.adb: Likewise. * libgnat/s-pack76.adb: Likewise. * libgnat/s-pack77.adb: Likewise. * libgnat/s-pack78.adb: Likewise. * libgnat/s-pack79.adb: Likewise. * libgnat/s-pack80.adb: Likewise. * libgnat/s-pack81.adb: Likewise. * libgnat/s-pack82.adb: Likewise. * libgnat/s-pack83.adb: Likewise. * libgnat/s-pack84.adb: Likewise. * libgnat/s-pack85.adb: Likewise. * libgnat/s-pack86.adb: Likewise. * libgnat/s-pack87.adb: Likewise. * libgnat/s-pack88.adb: Likewise. * libgnat/s-pack89.adb: Likewise. * libgnat/s-pack90.adb: Likewise. * libgnat/s-pack91.adb: Likewise. * libgnat/s-pack92.adb: Likewise. * libgnat/s-pack93.adb: Likewise. * libgnat/s-pack94.adb: Likewise. * libgnat/s-pack95.adb: Likewise. * libgnat/s-pack96.adb: Likewise. * libgnat/s-pack97.adb: Likewise. * libgnat/s-pack98.adb: Likewise. * libgnat/s-pack99.adb: Likewise.
2023-07-18ada: Allow warnings with explain codeYannick Moy1-2/+4
Change the way explain codes are handled to generate the command for the user to get the explanations, as this was not working for warnings. gcc/ada/ * errout.adb (Error_Msg_Internal): Remove call to Prescan_Message on the special continuation for the explain code command, as this does not play well with the setting of global variables for the message (like its status as a warning or not). Instead, set directly the global variables regarding content of the message in terms of special characters.
2023-07-18ada: Fix Valid_Scalars attribute applied to types from limited withEric Botcazou2-2/+9
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.
2023-07-12Daily bump.GCC Administrator1-0/+11
2023-07-11ada: Avoid renaming_decl in case of constrained arrayBob Duff1-1/+15
This patch avoids rewriting "X: S := F(...);" as "X: S renames F(...);". That rewrite is incorrect if S is a constrained array subtype, because it changes the semantics. In the original, the bounds of X are that of S. But constraints are ignored in renamings, so the bounds of X would come from F'Result. This can cause spurious Constraint_Errors in some obscure cases. It causes unnecessary checks to be inserted, and even when such checks pass (more common case), they might be less efficient. gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Avoid transforming to a renaming in case of constrained array that comes from source.
2023-07-11ada: Fix wrong resolution for hidden discriminant in predicateEric Botcazou1-7/+42
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.
2023-07-11Daily bump.GCC Administrator1-0/+49
2023-07-10ada: Follow-up fix for compilation issue with recent MinGW-w64 versionsEric Botcazou1-0/+3
It turns out that adaint.c includes other Windows header files than just windows.h, so defining WIN32_LEAN_AND_MEAN is not sufficient for it. gcc/ada/ * adaint.c [_WIN32]: Undefine 'abort' macro.
2023-07-10ada: Add typedefs to snames.h-tmplTom Tromey1-2/+6
A future patch will change sname.h-tmpl to use enums rather than preprocessor defines. In order to do this, first introduce some typedefs that can be used in gcc-interface. gcc/ada/ * snames.h-tmpl (Name_Id, Attribute_Id, Convention_Id) (Pragma_Id): New typedefs. (Get_Attribute_Id, Get_Pragma_Id): Use typedef.
2023-07-10ada: Simplify assertion to remove CodePeer messageYannick Moy1-3/+1
CodePeer is correctly warning on a test always true in an assertion. It can be rewritten without loss of proof to avoid that message. gcc/ada/ * libgnat/s-aridou.adb (Lemma_Powers_Of_2_Commutation): Rewrite assertion.
2023-07-10ada: Documentation for mixed declarations and statementsBob Duff3-45/+91
This patch documents the new feature that allows declarations mixed with statements, primarily by referring to the RFC. gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst (Local Declarations Without Block): Document the feature very briefly, and refer the reader to the RFC for details and examples. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2023-07-10ada: hardcfr: optionally disable in leaf functionsAlexandre Oliva2-0/+10
Document -fhardcfr-skip-leaf. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst (Control Flow Hardening): Document -fhardcfr-skip-leaf. * gnat_rm.texi: Regenerate.
2023-07-10ada: hardcfr: mark throw-expected functionsAlexandre Oliva2-16/+18
Adjust documentation to reflect the introduction of -fhardcfr-check-noreturn-calls=no-xthrow. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst (Control Flow Redundancy): Add -fhardcfr-check-noreturn-calls=no-xthrow. * gnat_rm.texi: Regenerate.
2023-07-10ada: Adapt proof of System.Arith_Double to remove CVC4Yannick Moy1-9/+75
The proof of System.Arith_Double still required the use of CVC4, now replaced by its successor cvc5. Adapt the proof to be able to remove CVC4 in the proof of run-time units. gcc/ada/ * libgnat/s-aridou.adb (Lemma_Div_Mult): New simple lemma. (Lemma_Powers_Of_2_Commutation): State post in else branch. (Lemma_Div_Pow2): Introduce local lemma and use it. (Scaled_Divide): Use cut operations in assertions, lemmas, new assertions. Introduce local lemma and use it.
2023-07-10ada: Add leafy mode for zero-call-used-regsAlexandre Oliva2-1/+13
Document leafy mode. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst (Register Scrubbing): Document leafy mode. * gnat_rm.texi: Regenerate.
2023-07-07Daily bump.GCC Administrator1-0/+91
2023-07-06ada: Add specification source files of runtime unitsClaire Dross1-0/+3
gcc/ada/ * gcc-interface/Make-lang.in: Add object files of specification files.
2023-07-06ada: Refactor the proof of the Value and Image runtime unitsClaire Dross38-729/+835
The aim of this refactoring is to avoid unnecessary dependencies between Image and Value units even though they share the same specification functions. These functions are grouped inside ghost packages which are then withed by Image and Value units. gcc/ada/ * libgnat/s-vs_int.ads: Instance of Value_I_Spec for Integer. * libgnat/s-vs_lli.ads: Instance of Value_I_Spec for Long_Long_Integer. * libgnat/s-vsllli.ads: Instance of Value_I_Spec for Long_Long_Long_Integer. * libgnat/s-vs_uns.ads: Instance of Value_U_Spec for Unsigned. * libgnat/s-vs_llu.ads: Instance of Value_U_Spec for Long_Long_Unsigned. * libgnat/s-vslllu.ads: Instance of Value_U_Spec for Long_Long_Long_Unsigned. * libgnat/s-imagei.ads: Take instances of Value_*_Spec as parameters. * libgnat/s-imagei.adb: Idem. * libgnat/s-imageu.ads: Idem. * libgnat/s-imageu.adb: Idem. * libgnat/s-valuei.ads: Idem. * libgnat/s-valuei.adb: Idem. * libgnat/s-valueu.ads: Idem. * libgnat/s-valueu.adb: Idem. * libgnat/s-imgint.ads: Adapt instance to new ghost parameters. * libgnat/s-imglli.ads: Adapt instance to new ghost parameters. * libgnat/s-imgllli.ads: Adapt instance to new ghost parameters. * libgnat/s-imglllu.ads: Adapt instance to new ghost parameters. * libgnat/s-imgllu.ads: Adapt instance to new ghost parameters. * libgnat/s-imguns.ads: Adapt instance to new ghost parameters. * libgnat/s-valint.ads: Adapt instance to new ghost parameters. * libgnat/s-vallli.ads: Adapt instance to new ghost parameters. * libgnat/s-valllli.ads: Adapt instance to new ghost parameters. * libgnat/s-vallllu.ads: Adapt instance to new ghost parameters. * libgnat/s-valllu.ads: Adapt instance to new ghost parameters. * libgnat/s-valuns.ads: Adapt instance to new ghost parameters. * libgnat/s-vaispe.ads: Take instance of Value_U_Spec as parameter and remove unused declaration. * libgnat/s-vaispe.adb: Idem. * libgnat/s-vauspe.ads: Remove unused declaration. * libgnat/s-valspe.ads: Factor out the specification part of Val_Util. * libgnat/s-valspe.adb: Idem. * libgnat/s-valuti.ads: Move specification to Val_Spec. * libgnat/s-valuti.adb: Idem. * libgnat/s-valboo.ads: Use Val_Spec. * libgnat/s-valboo.adb: Idem. * libgnat/s-imgboo.adb: Idem. * libgnat/s-imagef.adb: Adapt instances to new ghost parameters. * Makefile.rtl: List new files.
2023-07-06ada: Evaluate static expressions in Range attributesViljar Indus1-3/+13
Gigi assumes that the value of range expressions is an integer literal. Force evaluation of such expressions since static non-literal expressions are not always evaluated to a literal form by gnat. gcc/ada/ * sem_attr.adb (analyze_attribute.check_array_type): Replace valid indexes with their staticly evaluated values.
2023-07-06ada: Refer to non-Ada binding limitations in user guideViljar Indus2-31/+37
The limitation of resetting the FPU mode for non 80-bit precision was not referenced from "Creating a Stand-alone Library to be used in a non-Ada context". Reference it the same way it is already referenced from "Interfacing to C". gcc/ada/ * doc/gnat_ugn/the_gnat_compilation_model.rst: Reference "Binding with Non-Ada Main Programs" from "Creating a Stand-alone Library to be used in a non-Ada context". * gnat_ugn.texi: Regenerate.
2023-07-06ada: Reuse code in Is_Fully_Initialized_TypeViljar Indus1-1/+1
gcc/ada/ * sem_util.adb (Is_Fully_Initialized_Type): Avoid recalculating the underlying type twice.
2023-07-06ada: Avoid crash in Find_Optional_Prim_OpViljar Indus1-0/+5
Find_Optional_Prim_Op can crash when the Underlying_Type is Empty. This can happen when you are dealing with a structure type with a private part that does not have its Full_View set yet. gcc/ada/ * exp_util.adb (Find_Optional_Prim_Op): Stop deriving primitive operation if there is no underlying type to derive it from.
2023-07-06ada: Improve error message on violation of SPARK_Mode rulesYannick Moy2-1/+4
SPARK_Mode On can only be used on library-level entities. Improve the error message here. gcc/ada/ * errout.ads: Add explain code. * sem_prag.adb (Check_Library_Level_Entity): Refine error message and add explain code.
2023-07-06ada: Finalization not performed for component of protected typeSteve Baird2-1/+16
In some cases involving a discriminated protected type with an array component that is subject to a discriminant-dependent index constraint, where the element type of the array requires finalization and the array type has not yet been frozen at the point of the declaration of the protected type, finalization of an object of the protected type may incorrectly omit finalization of the array component. One case where this scenario can arise is an instantiation of Ada.Containers.Bounded_Synchronized_Queues, passing in an Element type that requires finalization. gcc/ada/ * exp_ch7.adb (Make_Final_Call): Add assertion that if no finalization call is generated, then the type of the object being finalized does not require finalization. * freeze.adb (Freeze_Entity): If freezing an already-frozen subtype, do not assume that nothing needs to be done. In the case of a frozen subtype of a non-frozen type or subtype (which is possible), freeze the non-frozen entity.
2023-07-05Daily bump.GCC Administrator1-0/+36
2023-07-04ada: Do not unnecessarily use component-wise loop for slice assignmentEric Botcazou3-27/+31
This relaxes the condition under which Expand_Assign_Array leaves the assignment to or from an array slice untouched. The main prerequisite for the code generator is that everything be aligned on byte boundaries and Is_Possibly_Unaligned_Slice is too strong a predicate for this, so it is replaced by the combination of Possible_Bit_Aligned_Component and Is_Bit_Packed_Array, modulo a change to Possible_Bit_Aligned_Component to take into account the specific case of slices. gcc/ada/ * exp_ch5.adb (Expand_Assign_Array): Adjust comment above the calls to Possible_Bit_Aligned_Component on the LHS and RHS. Do not call Is_Possibly_Unaligned_Slice in the slice case. * exp_util.ads (Component_May_Be_Bit_Aligned): Add For_Slice boolean parameter. (Possible_Bit_Aligned_Component): Likewise. * exp_util.adb (Component_May_Be_Bit_Aligned): Do not return False for the slice of a small record or bit-packed array component. (Possible_Bit_Aligned_Component): Pass For_Slice in recursive calls, except in the slice case where True is passed, as well as in call to Component_May_Be_Bit_Aligned.
2023-07-04ada: Small adjustments to new procedure Expand_Unchecked_Union_EqualityEric Botcazou3-16/+14
The procedure is not stable under repeated invocation. Now it may be called twice on the same node, for example during the expansion of the renaming of the predefined equality operator after the unchecked union type is frozen. gcc/ada/ * exp_ch4.ads (Expand_Unchecked_Union_Equality): Only take a single parameter. * exp_ch4.adb (Expand_Unchecked_Union_Equality): Add guard against repeated invocation on the same node. * exp_ch6.adb (Expand_Call): Only pass a single actual parameter in the call to Expand_Unchecked_Union_Equality.
2023-07-04ada: Add No_Use_Of_Attribute & No_Use_Of_Pragma to gnat_rmViljar Indus3-377/+415
gcc/ada/ * doc/gnat_rm/standard_and_implementation_defined_restrictions.rst: add No_Use_Of_Attribute & No_Use_Of_Pragma restrictions. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2023-07-04ada: Fix list of inherited subprograms in query for GNATproveYannick Moy2-0/+35
The query Inherited_Subprograms was returning a list containing some subprograms whose overridding was also in the list, when interfaces was present. This was an issue for GNATprove. Now propose a mode for this function to filter out overridden primitives. gcc/ada/ * sem_disp.adb (Inherited_Subprograms): Add parameter to filter out results. * sem_disp.ads: Likewise.
2023-07-04Daily bump.GCC Administrator1-0/+38
2023-07-03ada: Fix renaming of predefined equality operator for unchecked union typesEric Botcazou6-427/+390
The problem is that the predefined equality operator for unchecked union types is implemented out of line by invoking a function that takes more parameters than the two operands, which means that the renaming is not seen as type conforming with this function and, therefore, is rejected. The way out is to implement these additional parameters as "extra" formal parameters, since this kind of parameters is not taken into account for semantic checks. The change also factors out the duplicated generation of actuals for these additional parameters into a single procedure. gcc/ada/ * exp_ch3.ads (Build_Variant_Record_Equality): Add Spec_Id as second parameter. * exp_ch3.adb (Build_Variant_Record_Equality): For unchecked union types, build the additional parameters as extra formal parameters. (Expand_Freeze_Record_Type.Build_Variant_Record_Equality): Pass Empty as Spec_Id in call to Build_Variant_Record_Equality. * exp_ch4.ads (Expand_Unchecked_Union_Equality): New procedure. * exp_ch4.adb (Expand_Composite_Equality): In the presence of a function implementing composite equality, do not special case the unchecked union types, and only convert the operands if the base types are not the same like in Build_Equality_Call. (Build_Equality_Call): Do not special case the unchecked union types and relocate the operands only once. (Expand_N_Op_Eq): Do not special case the unchecked union types. (Expand_Unchecked_Union_Equality): New procedure implementing the specific expansion of calls to the predefined equality function. * exp_ch6.adb (Is_Unchecked_Union_Equality): New predicate. (Expand_Call): Call Is_Unchecked_Union_Equality to determine whether to call Expand_Unchecked_Union_Equality or Expand_Call_Helper. * exp_ch8.adb (Build_Body_For_Renaming): Set Has_Delayed_Freeze flag earlier on Id and pass Id in call to Build_Variant_Record_Equality.
2023-07-03ada: Fix discrepancy in expansion of untagged record equalityEric Botcazou1-25/+16
The expansion of the predefined equality operator for untagged record types can be done either in line, i.e. into the component-wise comparison of the operands, or out of line, i.e. into a call to a function implementing this comparison, and the heuristics of the selection are essentially based on the complexity of the implementation. For discriminated record types with a variant part, which comprise unchecked union types, the expansion is always done out of line. For nondiscriminated types, the expansion is done in line, unless one of the components is of a record type for which a user-defined equality operator exists, in which case the expansion is done out of line. For the third case, i.e. discriminated record types without a variant part, the expansion is always done in line. Now given that the discriminants are considered as mere components for the purpose of predefined equality in this case, there does not seem to be any reason for treating it differently from the second case above. gcc/ada/ * exp_ch3.adb (Build_Untagged_Equality): Rename into... (Build_Untagged_Record_Equality): ...this. (Expand_Freeze_Record_Type): Adjust to above renaming and invoke the procedure also for discriminated types without a variant part.
2023-07-03ada: Fix small inaccuracy in implementation of B.3.3(20/2)Eric Botcazou1-21/+14
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.
2023-06-30Daily bump.GCC Administrator1-0/+4
2023-06-29A couple of va_gc_atomic tweaksRichard Sandiford1-11/+0
The only current user of va_gc_atomic is Ada's: vec<Entity_Id, va_gc_atomic> It uses the generic gt_pch_nx routines (with gt_pch_nx being the “note pointers” hooks), such as: template<typename T, typename A> void gt_pch_nx (vec<T, A, vl_embed> *v) { extern void gt_pch_nx (T &); for (unsigned i = 0; i < v->length (); i++) gt_pch_nx ((*v)[i]); } It then defines gt_pch_nx routines for Entity_Id &. The problem is that if we wanted to take the same approach for an array of unsigned ints, we'd need to define: inline void gt_pch_nx (unsigned int &) { } which would then be ambiguous with: inline void gt_pch_nx (unsigned int) { } The point of va_gc_atomic is that the elements don't need to be GCed, and so we have: template<typename T> void gt_ggc_mx (vec<T, va_gc_atomic, vl_embed> *v ATTRIBUTE_UNUSED) { /* Nothing to do. Vectors of atomic types wrt GC do not need to be traversed. */ } I think it's therefore reasonable to assume that no pointers will need to be processed for PCH either. The patch also relaxes the array_slice constructor for vec<T, va_gc> * so that it handles all embedded vectors. gcc/ * vec.h (gt_pch_nx): Add overloads for va_gc_atomic. (array_slice): Relax va_gc constructor to handle all vectors with a vl_embed layout. gcc/ada/ * gcc-interface/decl.cc (gt_pch_nx): Remove overloads for Entity_Id.
2023-06-28Daily bump.GCC Administrator1-0/+69
2023-06-27ada: Fix build of GNAT toolsEric Botcazou1-3/+6
gcc/ada/ * gcc-interface/Makefile.in (LIBIBERTY): Fix condition. (TOOLS_LIBS): Add @LD_PICFLAG@.
2023-06-27ada: Fix bad interaction between inlining and thunk generationEric Botcazou1-3/+6
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.
2023-06-27ada: Make the identification of case expressions more robustEric Botcazou1-5/+3
gcc/ada/ * gcc-interface/trans.cc (Case_Statement_to_gnu): Rename boolean constant and use From_Conditional_Expression flag for its value.
2023-06-27ada: Fix double finalization of case expression in concatenationEric Botcazou4-72/+23
This streamlines the expansion of case expressions by not wrapping them in an Expression_With_Actions node when the type is not by copy, which avoids the creation of a temporary and the associated finalization issues. That's the same strategy as the one used for the expansion of if expressions when the type is by reference, unless Back_End_Handles_Limited_Types is set to True. Given that it is never set to True, except by a debug switch, and has never been implemented, this parameter is removed in the process. gcc/ada/ * debug.adb (d.L): Remove documentation. * exp_ch4.adb (Expand_N_Case_Expression): In the not-by-copy case, do not wrap the case statement in an Expression_With_Actions node. (Expand_N_If_Expression): Do not test Back_End_Handles_Limited_Types * gnat1drv.adb (Adjust_Global_Switches): Do not set it. * opt.ads (Back_End_Handles_Limited_Types): Delete.
2023-06-27ada: Fix incorrect handling of iterator specifications in recent changeEric Botcazou1-7/+11
Unlike for loop parameter specifications where it references an index, the defining identifier references an element in them. gcc/ada/ * sem_ch12.adb (Check_Generic_Actuals): Check the component type of constants and variables of an array type. (Copy_Generic_Node): Fix bogus handling of iterator specifications.
2023-06-27ada: Correct the contract of Ada.Text_IO.Get_LineClaire Dross1-9/+13
Item might not be entirely initialized after a call to Get_Line. gcc/ada/ * libgnat/a-textio.ads (Get_Line): Use Relaxed_Initialization on the Item parameter of Get_Line.
2023-06-27ada: Fix too late finalization and secondary stack release in iterator loopsEric Botcazou2-31/+14
Sem_Ch5 contains an entire machinery to deal with finalization actions and secondary stack releases around iterator loops, so this removes a recent fix that was made in a narrower case and instead refines the condition under which this machinery is triggered. As a side effect, given that finalization and secondary stack management are still entangled in this machinery, this also fixes the counterpart of a leak for the former, which is a finalization occurring too late. gcc/ada/ * exp_ch4.adb (Expand_N_Quantified_Expression): Revert the latest change as it is subsumed by the machinery in Sem_Ch5. * sem_ch5.adb (Prepare_Iterator_Loop): Also wrap the loop statement in a block in the name contains a function call that returns on the secondary stack.