aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2023-05-27Daily bump.GCC Administrator1-0/+309
2023-05-26ada: Corrections to premature-references rulesBob Duff1-5/+17
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 state of the Derived_Type to "self-hidden" while processing constraints and discriminants of a record extension.
2023-05-26ada: Fix typos "statment" and "condtion"Bob Duff6-7/+7
...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.
2023-05-26ada: Use truncation for dynamic conversions from floating point to fixed pointEric Botcazou4-24/+35
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 the Machine_Rounds attribute, which is False for all fixed-point types with GNAT. The rounding is still available under the debug switch -gnatd.N for the sake of backward compatibility with the previous implementation. gcc/ada/ * debug.adb (d.N): Document new usage. * exp_ch4.adb (Expand_N_Type_Conversion): Copy the Float_Truncate flag when rewriting a floating-point to fixed-point conversion as a floating-point to integer conversion. * exp_fixd.adb: Add with and use clauses for Debug. (Expand_Convert_Fixed_To_Fixed): Generate a truncation in all cases except if the result is explicitly rounded. (Expand_Convert_Integer_To_Fixed): Likewise. (Expand_Convert_Float_To_Fixed): Generate a truncation for all kind of fixed-point types, except if the result is explicitly rounded, or -gnatd.N is specified and the type is an ordinary fixed-point type. * sinfo.ads (Float_Truncate): Document usage for floating-point to fixed-point conversions.
2023-05-26ada: Crash on function returning allocated object containing tasksJavier Miranda1-0/+19
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 in the return statement of a function returning a general access type, then propagate to the itype the master of the general access type (since it is the master associated with the returned object).
2023-05-26ada: Default initialize entity to avoid CodePeer messageYannick Moy1-0/+6
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.
2023-05-26ada: Minor doc clarificationYannick Moy3-3/+3
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 matching limitation. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2023-05-26ada: Complete contracts of SPARK unitsYannick Moy4-58/+80
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 annotated with Might_Not_Return. gcc/ada/ * libgnat/a-calend.ads: Mark with SPARK_Mode=>Off the functions which may raise Time_Error. * libgnat/a-ngelfu.ads: Mark with SPARK_Mode=>Off the functions which may lead to an overflow (which is not the case of Tan with one parameter for example, or Arctanh or Arcoth, despite their mathematical range covering the reals). * libgnat/a-textio.ads: Remove Always_Return annotation from functions, as this is now compulsory for functions to always return in SPARK. * libgnat/i-cstrin.ads: Add Might_Not_Return annotation to Update procedure which may not return.
2023-05-26ada: Fix crash on 'Img as generic actual functionBob Duff6-33/+33
'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 (Expand_Image_Attribute): If Discard_Names, expand to 'Image instead of 'Img. * snames.ads-tmpl, par-ch4.adb, sem_attr.adb, sem_attr.ads: Cleanups: Rename Attribute_Class_Array to be Attribute_Set. Remove unnecessary qualifications. DRY: Don't repeat "True".
2023-05-26ada: Remove redundant guard against empty listsPiotr Trojanek2-4/+1
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): Remove call to Present. * sem_util.adb (Find_Untagged_Type_Of): Likewise.
2023-05-26ada: Fix double free on finalization of Vector in array aggregateEric Botcazou1-18/+9
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 case of an array of array with controlled component when its subaggregates are not expanded in place but instead are replaced by temporaries, leading to double free or memory corruption. gcc/ada/ * exp_aggr.adb (Initialize_Array_Component): Remove obsolete code. (Expand_Array_Aggregate): In the case where a temporary is created and the parent is an assignment statement with No_Ctrl_Actions set, set Is_Ignored_Transient on the temporary.
2023-05-26ada: Fix internal error on Big_Integer conversion ghost instanceEric Botcazou1-12/+12
The problem is that the ghost mode of the instance is used to analyze the parent of the generic body, whose own ghost mode has nothing to do with it. gcc/ada/ * sem_ch12.adb (Instantiate_Package_Body): Set the ghost mode to that of the instance only after loading the generic's parent. (Instantiate_Subprogram_Body): Likewise.
2023-05-26ada: Simplify expansion of set membershipPiotr Trojanek1-10/+7
Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch4.adb (Expand_Set_Membership): Simplify by using Evolve_Or_Else.
2023-05-26ada: Cleanup expansion of membership operators into attribute ValidPiotr Trojanek1-22/+4
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.
2023-05-26ada: Remove leftover code for counting protected entriesPiotr Trojanek1-20/+5
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 pragma among entry family declarations). gcc/ada/ * exp_ch9.adb (Build_Entry_Count_Expression): Remove loop over component declaration; consequently remove a parameter that is no longer used; adapt callers. (Make_Task_Create_Call): Refine type of a local variable.
2023-05-26ada: Fix detection of non-static expressions in records with pragmasPiotr Trojanek1-6/+5
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.
2023-05-26ada: Reorder components in Ada.Containers.Bounded_Doubly_Linked_ListsEric Botcazou1-1/+1
gcc/ada/ * libgnat/a-cbdlli.ads (List): Move Nodes component to the end.
2023-05-26ada: Reorder components in Ada.Containers.Restricted_Doubly_Linked_ListsEric Botcazou1-1/+1
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 "Nodes" whose length depends on a discriminant [-gnatw.q] warning: in instantiation at a-crdlli.ads:317 [-gnatw.q] warning: comes too early and was moved down [-gnatw.q] gcc/ada/ * libgnat/a-crdlli.ads (List): Move Nodes component to the end.
2023-05-26ada: Reject thin 'Unrestricted_Access value to aliased constrained arrayEric Botcazou1-23/+51
This rejects the Unrestricted_Access attribute applied to an aliased array with a constrained nominal subtype when its type is resolved to be a thin pointer. The reason is that supporting this case would require the aliased array to contain its bounds, and this is the case only for aliased arrays whose nominal subtype is unconstrained. gcc/ada/ * sem_attr.adb (Is_Thin_Pointer_To_Unc_Array): New predicate. (Resolve_Attribute): Apply the static matching legality rule to an Unrestricted_Access attribute applied to an aliased prefix if the type is a thin pointer. Call Is_Thin_Pointer_To_Unc_Array for the aliasing legality rule as well.
2023-05-26ada: Simplify iteration over record component items with possible pragmasPiotr Trojanek1-4/+2
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.
2023-05-26ada: Fix handling of Global contracts inside generic subprogramsPiotr Trojanek1-1/+3
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 Is_Generic_Declaration_Or_Body). With this patch the frontend will look at the decorated expression of the Global contract attached to the Global aspect; previously it was looking at the undecorated expression attached to the corresponding pragma. gcc/ada/ * sem_prag.adb (Get_Argument): Improve detection of generic units.
2023-05-26ada: Tune detection of expression functions within a declare expressionPiotr Trojanek2-3/+3
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.
2023-05-26ada: Crash on loop in dispatching conditional entry callJavier Miranda3-125/+30
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. (New_Copy_Separate_Tree): Removed. * sem_util.adb (New_Copy_Separate_List): Removed. (New_Copy_Separate_Tree): Removed.
2023-05-26ada: Remove redundant protection against empty listsPiotr Trojanek1-122/+116
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 needed.
2023-05-26ada: Cleanups in handling of aggregatesPiotr Trojanek5-26/+24
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; this routine is only called on type entities (and now will crash in other cases). * sem_ch3.adb (Create_Constrained_Components): Only assign Assoc_List when necessary; tune whitespace. (Is_Variant_Record): Refactor repeated calls to Parent. * sem_util.adb (Gather_Components): Assert that discriminant association has just one choice in component_association; refactor repeated calls to Next. * sem_util.ads (Gather_Components): Tune whitespace in comment.
2023-05-26ada: Fix iteration over component items with pragmasPiotr Trojanek2-4/+4
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 component declarations. gcc/ada/ * sem_ch3.adb (Check_CPP_Type_Has_No_Defaults): Iterate with First_Non_Pragma and Next_Non_Pragma. * exp_dist.adb (Append_Record_Traversal): Likewise.
2023-05-26ada: Duplicate declaration of _master entityJavier Miranda3-23/+40
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 (Is_Internal_Block): New subprogram.
2023-05-26ada: Remove redundant guards from handling of record componentsPiotr Trojanek1-6/+1
Call to First on empty list is intentionally returning Empty. gcc/ada/ * sem_util.adb (Gather_Components): Remove guard for empty list of components.
2023-05-26ada: Remove Is_Descendant_Of_Address flag from Standard_AddressEric Botcazou4-13/+20
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 signature of the gigi procedure and alphabetize other parameters. Pass Standard_Address as actual parameter for it. * cstand.adb (Create_Standard): Do not set Is_Descendant_Of_Address on Standard_Address. * gcc-interface/gigi.h (gigi): Add a standard_address parameter and alphabetize others. * gcc-interface/trans.cc (gigi): Likewise. Record a builtin address type and save it as the type for Standard.Address.
2023-05-26ada: Handle new Controlling_Tag format when converting to SCILGhjuvan Lacambre2-10/+29
This commit fixes two CodePeer crashes that were introduced when the format of the controlling tag changed. gcc/ada/ * exp_disp.adb (Expand_Dispatching_Call): Handle new Controlling_Tag. * sem_scil.adb (Check_SCIL_Node): Treat N_Object_Renaming_Declaration as N_Object_Declaration.
2023-05-26ada: Use context variables in expansion of aggregatesPiotr Trojanek1-10/+7
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 explicit Aliased_Present parameter which is equivalent to the default value. (Check_Bounds): Remove unused initial value. (Expand_Array_Aggregate): Use aggregate type from the context.
2023-05-26ada: Fix missing finalization in library-level instance bodyEric Botcazou6-228/+222
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): Document new usage. * exp_ch7.ads (Build_Finalizer): New declaration. * exp_ch7.adb (Build_Finalizer.Process_Declarations): Do not treat library-level package instantiations specially. (Build_Finalizer): Return early for package bodies and specs that are not compilation units instead of using a more convoluted test. (Expand_N_Package_Body): Do not build a finalizer if Delay_Cleanups is set on the defining entity. (Expand_N_Package_Declaration): Likewise. * inline.ads (Pending_Body_Info): Reorder and add Fin_Scop. (Add_Pending_Instantiation): Add Fin_Scop parameter. * inline.adb (Add_Pending_Instantiation): Likewise and copy it into the Pending_Body_Info appended to Pending_Instantiations. (Add_Scope_To_Clean): Change parameter name to Scop and remove now irrelevant processing. (Cleanup_Scopes): Deal with scopes that are package specs or bodies. (Instantiate_Body): For package instantiations, deal specially with scopes that are package bodies and with scopes that are dynamic. Pass the resulting scope to Add_Scope_To_Clean directly. * sem_ch12.adb (Analyze_Package_Instantiation): In the case where a body is needed, compute the enclosing finalization scope and pass it in the call to Add_Pending_Instantiation. (Inline_Instance_Body): Adjust aggregate passed in the calls to Instantiate_Package_Body. (Load_Parent_Of_Generic): Likewise.
2023-05-26ada: Minor tweak in conditionEric Botcazou1-1/+1
gcc/ada/ * sem_util.adb (Compile_Time_Constraint_Error): Test the Ekind.
2023-05-26ada: Simplify expansion of positional aggregatesPiotr Trojanek1-9/+3
Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Constrained_Type): Use List_Length to count expressions in consecutive subaggregates.
2023-05-26ada: Use computed value from os_constants to define sigset_tDoug Rupp1-1/+3
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.
2023-05-26ada: Fix another couple of unchecked conversions to Ada.Tags.TagEric Botcazou1-54/+17
They are problematic on platforms where the provenance of pointers must be tracked throughout their lifetime. gcc/ada/ * exp_sel.adb: Add clauses for Sem_Util, remove them for Opt, Sinfo and Sinfo.Nodes. (Build_K): Always use 'Tag of the object. (Build_S_Assignment): Likewise.
2023-05-26ada: Refine types for an accessibility-checking routinePiotr Trojanek1-2/+2
Code cleanup related to work on expression functions for GNATprove (which require accessibility checks even when they are not expanded and thus have no explicit return statements). gcc/ada/ * accessibility.adb (Is_Formal_Of_Current_Function): This routine expects an entity reference and not the entity itself, so its parameter is a Node_Id and not an Entity_Id.
2023-05-26ada: Clean style in expansion of array aggregatesPiotr Trojanek1-7/+5
Code cleanup only; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): Change variable to constant. (Check_Same_Aggr_Bounds): Fix style; remove unused initial value.
2023-05-26ada: Fix late extra formals creationRonan Desplanques1-0/+1
Before this patch, in some situations, a subprogram call could be expanded before the extra formals for the subprogram were created. This patch fixes the problem in those situations. gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Create extra formals in more situations.
2023-05-26ada: Add missing guards in Selected_Range_ChecksEric Botcazou1-0/+2
gcc/ada/ * checks.adb (Selected_Range_Checks): Add guards to protect calls to Expr_Value on bounds.
2023-05-26ada: Enhance Is_Null_Range and Not_Null_Range predicatesEric Botcazou3-9/+11
Both predicates bail out if the bounds of the range are not known at compile time, whereas Compile_Time_Compare can deal with them in specific cases. gcc/ada/ * sem_eval.ads (Is_Null_Range): Remove requirements of compile-time known bounds and add WARNING line. (Not_Null_Range): Remove requirements of compile-time known bounds. * sem_eval.adb (Is_Null_Range): Fall back to Compile_Time_Compare. (Not_Null_Range): Likewise. * fe.h (Is_Null_Range): New predicate.
2023-05-26Daily bump.GCC Administrator1-0/+360
2023-05-25ada: Missing warning on null-excluding array aggregate componentJavier Miranda2-3/+165
The compiler does not report warnings on the initialization of arrays of null-excluding access type components by means of iterated component association, when the expression initializing each component is either a conditional expression or a case expression that may initialize some component with a null value. gcc/ada/ * sem_aggr.adb (Warn_On_Null_Component_Association): New subprogram. (Empty_Range): Adding missing support for iterated component association node. (Resolve_Array_Aggregate): Report warning on iterated component association that may initialize some component of an array of null-excluding access type components with a null value. * exp_ch4.adb (Expand_N_Expression_With_Actions): Add missing type check since the subtype of the EWA node and the subtype of the expression may differ.
2023-05-25ada: Expect Exceptional_Cases as a context for attribute OldPiotr Trojanek1-6/+10
When determining whether attribute Old is evaluated conditionally, we must also expect it to appear in the recently added contract Exceptional_Cases. gcc/ada/ * sem_util.adb (Determining_Expressions): Fix style; fix layout and ordering of pragma names; expect pragma Exceptional_Cases.
2023-05-25ada: Use procedural variant of Next_Index where possiblePiotr Trojanek2-4/+4
Code cleanup; semantics is unaffected. gcc/ada/ * einfo-utils.adb (Write_Entity_Info): Use procedural Next_Index. * sem_aggr.adb (Collect_Aggr_Bounds): Reuse local constant. (Resolve_Null_Array_Aggregate): Use procedural Next_Index.
2023-05-25ada: Crash on empty aggregate using the Ada 2022 notationJavier Miranda1-1/+3
The compiler crashes processing an empty aggregate initializing a component of a discriminated record type using the Ada 2022 notation (that is, []). gcc/ada/ * exp_aggr.adb (Build_Record_Aggr_Code): Protect access to aggregate components when the aggregate is empty.
2023-05-25ada: Enable Support_Atomic_Primitives on VxWorks 7 PPCJohannes Kliemann2-2/+2
gcc/ada/ * libgnat/system-vxworks7-ppc-kernel.ads: Enable Support_Atomic_Primitives. * libgnat/system-vxworks7-ppc-rtp-smp.ads: Likewise.
2023-05-25ada: Fix internal error on declare-expression in post-conditionEric Botcazou1-5/+7
It comes from an incorrect node sharing in the expanded tree. gcc/ada/ * sem_ch3.adb (Find_Type_Of_Object): Copy the object definition when building the subtype declaration in the case of a spec expression.
2023-05-25ada: Require successful build of xsnamestTom Tromey1-1/+1
While experimenting, I introduced a compilation error into xsnamest. This took a little while to track down because, while the error was in the log, the build did not stop. This patch changes Make-generated.in to require a successful build of this program. gcc/ada/ * Make-generated.in (ada/stamp-snames): Check result of gnatmake.
2023-05-25ada: Minor adjustments to Standard_AddressEric Botcazou2-4/+16
Standard_Address is an internal entity that is meant to be a clone of System.Address built at compilation startup. It needs to be seen as a bona-fide address by the code generator. For the sake of completeness, it is also given its modulus, although this does not matter in practice. gcc/ada/ * cstand.adb (Create_Standard): Set the Is_Descendant_Of_Address flag on Standard_Address. * freeze.adb (Freeze_Entity): Copy the modulus of System.Address onto Standard_Address.