aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2023-05-25ada: Add size clause to System.AddressEric Botcazou43-0/+86
Standard'Address_Size is the value provided by the code generator for the size of pointers, and it is set as the default size of every thin pointer by the front-end. Now it is documented in the GNAT RM as having the value of System.Address'Size, which is indeed the case on (correctly configured) platforms where pointers contain exactly the number of bits that are needed to address the memory space. However, on platforms where pointers contain additional bits of metadata, it has a larger value and the documented relation does not hold, which also means that unchecked conversions between System.Address and pointers are seen as potentially problematic. In order to fix the discrepancy on these platforms, this change adds the obvious size clause to System.Address, which is confirming on all the other (correctly configured) platforms. gcc/ada/ * libgnat/system-aix.ads (Address): Likewise. * libgnat/system-darwin-arm.ads (Address): Likewise. * libgnat/system-darwin-ppc.ads (Address): Likewise. * libgnat/system-darwin-x86.ads (Address): Likewise. * libgnat/system-djgpp.ads (Address): Likewise. * libgnat/system-dragonfly-x86_64.ads (Address): Likewise. * libgnat/system-freebsd.ads (Address): Likewise. * libgnat/system-hpux-ia64.ads (Address): Likewise. * libgnat/system-hpux.ads (Address): Likewise. * libgnat/system-linux-alpha.ads (Address): Likewise. * libgnat/system-linux-arm.ads (Address): Likewise. * libgnat/system-linux-hppa.ads (Address): Likewise. * libgnat/system-linux-ia64.ads (Address): Likewise. * libgnat/system-linux-m68k.ads (Address): Likewise. * libgnat/system-linux-mips.ads (Address): Likewise. * libgnat/system-linux-ppc.ads (Address): Likewise. * libgnat/system-linux-riscv.ads (Address): Likewise. * libgnat/system-linux-s390.ads (Address): Likewise. * libgnat/system-linux-sh4.ads (Address): Likewise. * libgnat/system-linux-sparc.ads (Address): Likewise. * libgnat/system-linux-x86.ads (Address): Likewise. * libgnat/system-lynxos178-ppc.ads (Address): Likewise. * libgnat/system-lynxos178-x86.ads (Address): Likewise. * libgnat/system-mingw.ads (Address): Likewise. * libgnat/system-qnx-arm.ads (Address): Likewise. * libgnat/system-rtems.ads (Address): Likewise. * libgnat/system-solaris-sparc.ads (Address): Likewise. * libgnat/system-solaris-x86.ads (Address): Likewise. * libgnat/system-vxworks-ppc-kernel.ads (Address): Likewise. * libgnat/system-vxworks-ppc-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks-ppc-rtp.ads (Address): Likewise. * libgnat/system-vxworks7-aarch64-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks7-aarch64.ads (Address): Likewise. * libgnat/system-vxworks7-arm-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks7-arm.ads (Address): Likewise. * libgnat/system-vxworks7-ppc-kernel.ads (Address): Likewise. * libgnat/system-vxworks7-ppc-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks7-ppc64-kernel.ads (Address): Likewise. * libgnat/system-vxworks7-ppc64-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks7-x86-kernel.ads (Address): Likewise. * libgnat/system-vxworks7-x86-rtp-smp.ads (Address): Likewise. * libgnat/system-vxworks7-x86_64-kernel.ads (Address): Likewise. * libgnat/system-vxworks7-x86_64-rtp-smp.ads (Address): Likewise.
2023-05-25ada: Fix error message for Aggregate aspectMarc Poulhiès1-2/+2
The error message was wrongly using % instead of & in the format string, causing the displayed message to refer to incorrect names in some cases. gcc/ada/ * sem_ch13.adb (Check_Aspect_At_Freeze_Point): fix format string, use existing local Ident.
2023-05-25ada: Switch from E_Void to Is_Not_Self_HiddenBob Duff6-80/+71
We had previously used Ekind = E_Void to indicate that a declaration is self-hidden. We now use the Is_Not_Self_Hidden flag instead. This allows us to avoid many "vanishing fields", which are (possibly-latent) bugs, and we now enable the assertions in Atree that detect such bugs. gcc/ada/ * atree.adb (Check_Vanishing_Fields): Fix bug in the "blah type only" cases. Remove the special cases for E_Void. Misc cleanup. (Mutate_Nkind): Disallow mutating to the same kind. (Mutate_Ekind): Disallow mutating to E_Void. (From E_Void is still OK -- entities start out as E_Void by default.) Fix bug in statistics gathering -- was setting the wrong count. Enable Check_Vanishing_Fields for entities. * sem_ch8.adb (Is_Self_Hidden): New function. (Find_Direct_Name): Call Is_Self_Hidden to use the new Is_Not_Self_Hidden flag to determine whether a declaration is hidden from all visibility by itself. This replaces the old method of checking E_Void. (Find_Expanded_Name): Likewise. (Find_Selected_Component): Likewise. * sem_util.adb (Enter_Name): Remove setting of Ekind to E_Void. * sem_ch3.adb: Set the Is_Not_Self_Hidden flag in appropriate places. Comment fixes. (Inherit_Component): Remove setting of Ekind to E_Void. * sem_ch9.adb (Analyze_Protected_Type_Declaration): Update comment. Skip Itypes, which should not be turned into components. * atree.ads (Mutate_Nkind): Document error case. (Mutate_Ekind): Remove comments apologizing for E_Void mutations. Document error cases.
2023-05-25ada: Decouple size of addresses and pointers from size of memory spaceEric Botcazou11-31/+18
This decouples the size of the types representing addresses and pointers, which is Standard'Address_Size, from the size of the memory space, which is System.Memory_Size (more precisely log2 of it). They are tied through the definition of System.Address: type Address is mod Memory_Size; so Standard'Address_Size >= log2 (System.Memory_Size) necessarily, but the equality does not hold on platforms where addresses and pointers contain additional bits of metadata. gcc/ada/ * libgnat/a-ststio.adb (Set_Mode): Test System.Memory_Size. * libgnat/g-debuti.ads (Address_64): Likewise. * libgnat/i-c.ads: Add with clause for System. (ptrdiff_t): Define based on the size of memory space. (size_t): Likewise. * libgnat/s-crtl.ads (size_t): Likewise. (ssize_t): Likewise. * libgnat/s-memory.ads (size_t): Likewise. * libgnat/s-parame.ads (Size_Type): Likewise. * libgnat/s-parame__hpux.ads (Size_Type): Likewise. * libgnat/s-parame__posix2008.ads (Size_Type): Likewise. * libgnat/s-parame__vxworks.ads (Size_Type): Likewise. * libgnat/s-putima.adb (Signed_Address): Likewise. (Unsigned_Address): Likewise. * libgnat/s-stoele.ads (Storage_Offset): Likewise.
2023-05-25ada: Fix copying of quantified expressionsPiotr Trojanek1-1/+4
While visiting the AST as part of routine New_Copy_Tree we maintain an EWA_Level variable in a stack-like fashion. This worked fine for expression with actions nodes but not for quantified expressions. gcc/ada/ * sem_util.adb (Visit_Node): Decrement EWA_Level with the same condition as when it was incremented.
2023-05-25ada: Deconstruct a no longer used parameter of New_Copy_TreePiotr Trojanek2-19/+10
Parameter Scopes_In_EWA_OK of New_Copy_Tree was introduced in 2018 to deal with expressions-with-actions (EWA) in the build-in-place machinery. However, after changes made in 2022 it is no longer used by any caller. Cleanup related to handling of expression functions in GNATprove; semantics is unaffected. gcc/ada/ * sem_util.ads (New_Copy_Tree): Remove Scopes_In_EWA_OK from spec; adapt comment. * sem_util.adb (New_Copy_Tree): Remove Scopes_In_EWA_OK from body; adapt code.
2023-05-25ada: Clean up copying of node treesPiotr Trojanek1-3/+1
Before calling routine In_Entity_Map we checked if the entity map is present; inside this routine we checked this again. Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Update_New_Entities): Remove redundant check for entity map being present.
2023-05-25ada: Simplify copying of node listsPiotr Trojanek1-6/+1
When creating a copy of a node list we called Copy_Entity for entities and Copy_Separate_Tree for other nodes. This was unnecessary, because the Copy_Separate_Tree when called on entities will just do Copy_Entity. Code cleanup; semantics is unaffected. gcc/ada/ * atree.adb (Copy_List): Call Copy_Separate_Tree for both entities and other nodes.
2023-05-25ada: Avoid duplicated streaming subprogramsSteve Baird5-150/+286
In some common cases, a reference to Some_Type'Some_Streaming_Attribute causes the needed subprogram to be generated "on demand". If there are multiple such references (e.g., two calls to Some_Type'Write) then we want to avoid generating multiple essentially-identical subprograms. This change implies that a generated streaming subprogram may now have multiple call sites, so we can no longer use the source position information from the (one and only) call site. If an exception is raised during a streaming operation, this can make a difference in the reported raise location. gcc/ada/ * exp_attr.adb (Cached_Streaming_Ops): A new package, providing maps to save previously-generated Read/Write/Input/Output procedures. (Expand_N_Attribute_Reference): When a new subprogram is generated for a Read/Write/Input/Output attribute reference, record that type/subp pair in the appropriate Cached_Streaming_Ops map. (Find_Stream_Subprogram): Check the appropriate Cached_Streaming_Ops map to see if an appropriate subprogram has already been generated. If so, then return it. The appropriateness test includes a call to a new nested subprogram, In_Available_Context. * exp_strm.ads, exp_strm.adb: Do not pass in a Loc parameter (or a source-location-bearing Nod parameter) to the 16 procedures provided for building streaming-related subprograms. Use the source location of the type instead. * exp_dist.adb, exp_ch3.adb: Adapt to Exp_Strm spec changes. For these calls the source location of the type was already being used.
2023-05-25ada: Fix crash during function return analysisMarc Poulhiès1-0/+1
The compiler would crash when checking type relation between the function's return type and the type of the expression used in the return statement. It would not work if the function's return type is an access type and the expression is not. gcc/ada/ * sem_ch6.adb (Analyze_Function_Return): Add missing Is_Access_Type check before accessing the Designated_Type field.
2023-05-25ada: Remove unused initial value of a local variablePiotr Trojanek1-1/+1
Cleanup related to improved handling of expression functions in GNATprove; semantics is unaffected. gcc/ada/ * sem_ch6.adb (Analyze_Return_Type): Remove unused initial value.
2023-05-25ada: Fix (again) incorrect handling of Aggregate aspectMarc Poulhiès2-7/+14
Previous fix stopped the processing of the Aggregate aspect early, skipping the call to Record_Rep_Item, making later call to Resolve_Container_Aggregate fail. Also, the previous fix would not handle correctly the case where the type is private and the check for non-array type can only be done at the freeze point with the full type. Adapt the resolving of the aspect when the input is not correct and the parameters can't be resolved. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Call Record_Rep_Item. (Check_Aspect_At_Freeze_Point): Check the aspect is specified on non-array type only... (Analyze_One_Aspect): ... instead of doing it too early here. * sem_aggr.adb (Resolve_Container_Aggregate): Do nothing in case the parameters failed to resolve.
2023-05-25ada: Prevent search of calls in preconditions from going too farPiotr Trojanek1-0/+5
When determining whether a call to protected function appears within a pragma expression we can safely stop at the subprogram body. Cleanup related to recently added support for a new SPARK aspects, whose implementation was based on Contract_Cases. gcc/ada/ * sem_util.adb (Check_Internal_Protected_Use): Add standard protection against search going too far.
2023-05-25ada: Fix comments for recently added SPARK aspectsPiotr Trojanek5-9/+19
Implementation of contract Subprogram_Variant and Exceptional_Cases was based on the existing code for Contract_Cases, i.e. on the existing occurrences of Aspect_Contract_Cases, Name_Contract_Cases and Pragma_Contract_Cases. However, occurrences of "Contract_Cases" itself in the comments were not updated. gcc/ada/ * contracts.adb (Add_Pre_Post_Condition): Mention new aspects in the comment. * contracts.ads (Add_Contract_Item): Likewise. (Analyze_Subprogram_Body_Stub_Contract): Likewise. * sem_prag.adb (Contract_Freeze_Error): Likewise. (Ensure_Aggregate_Form): Likewise. * sem_prag.ads (Find_Related_Declaration_Or_Body): Likewise. * sinfo.ads (Is_Generic_Contract_Pragma): Likewise.
2023-05-25ada: Add missing supportive code for recently added SPARK aspectsPiotr Trojanek2-21/+27
Fix minor inconsistencies with the recently added SPARK aspects Exceptional_Cases and Subprogram_Variant, whose implementation is based on Contract_Cases. gcc/ada/ * aspects.ads (Implementation_Defined_Aspect): Recently added aspects are implementation-defined, just like Contract_Cases. * sem_prag.ads (Aspect_Specifying_Pragma): Recently added aspects have corresponding pragmas, just like Contract_Cases. (Pragma_Significant_To_Subprograms): Recently added aspects are significant to subprograms, just like Contract_Cases.
2023-05-25ada: Tune handling of attributes Old in contract Exceptional_CasesPiotr Trojanek1-2/+30
Contract Exceptional_Cases allows formal parameters to appear *in* prefixes of attributes Old, but the code only allowed them to appear *as* prefixes of those attributes. For example, we now accetp expressions like "X.all'Old" that were previously rejected. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Tune handling of formal parameters in contract Exceptional_Cases.
2023-05-25ada: Remove redundant guards from calls to Move_AspectsPiotr Trojanek3-12/+4
Routine Move_Aspects does nothing if its From parameter has no aspects. There is no need to check this at the call sites. Code cleanup related to changes in handling of expressions functions in GNATprove; semantics is unaffected. gcc/ada/ * par-ch7.adb (P_Package): Remove redundant guard from call to Move_Aspects. * par-ch9.adb (P_Task): Likewise. * sem_ch6.adb (Analyze_Expression_Function, Is_Inline_Pragma): Likewise.
2023-05-25ada: Small tweak to implementation of by-copy semantics for storage modelsEric Botcazou1-25/+4
Get_Actual_Subtype can be used to access the Actual_Designated_Subtype of explicit dereferences with a storage model. As a side effect, this also handles the case where the prefix of the dereference is a formal parameter. gcc/ada/ * exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Use Get_Actual_Subtype to retrieve the actual subtype for all actuals and do it in only one place for all unconstrained composite formal types.
2023-05-25ada: Fix copy-paste mistake in analysis of Exceptional_CasesPiotr Trojanek1-3/+3
Trivial mistakes in copied code. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Fix references to Exceptional_Cases in code copied from handling of Subprogram_Variant.
2023-05-25ada: Enrich documentation of subprogramRonan Desplanques1-1/+5
This patch adds documentation to the subprogram Replace_Type in Sem_Ch3. In particular, references to relevant parts of the Ada reference manual are added. gcc/ada/ * sem_ch3.adb (Replace_Type): Add more documentation.
2023-05-25ada: Maximize use of existing constantRonan Desplanques1-2/+2
This patch does not change the behavior of the compiler and is intended as a readability improvement. gcc/ada/ * sem_ch3.adb (Replace_Type): Use existing constant wherever possible.
2023-05-25ada: Reduce span of variableRonan Desplanques1-1/+1
This patch does not change the behavior of the compiler, but is intended to improve readability. It seizes an opportunity to move a variable declaration to a smaller scope, so that it's clearer that the variable is not used outside of that scope. gcc/ada/ * sem_ch3.adb (Replace_Type): Reduce span of variable.
2023-05-25ada: Set Is_Not_Self_Hidden flag in more casesBob Duff3-3/+11
More work-in-progress for changing E_Void checks to the flag. gcc/ada/ * sem_ch9.adb (Analyze_Protected_Type_Declaration): Set the flag for protected types. (Analyze_Single_Protected_Declaration): Likewise, for singleton protected objects. (Analyze_Task_Type_Declaration): Set the flag for task types. (Analyze_Single_Task_Declaration): Likewise, for singleton task objects. * sem_ch10.adb (Decorate_Type): Set the flag for types treated as incomplete. (Build_Shadow_Entity): Set the flag for shadow entities. (Decorate_State): Set the flag for an abstract state. (Build_Limited_Views): Set the flag for limited view of package. * sem_attr.adb (Check_Not_Incomplete_Type): Disable the check when this is a current instance.
2023-05-25ada: Handle controlling access parameters in DTWsRonan Desplanques2-7/+7
This patch improves the way controlling access parameters are handled in dispatch table wrappers. The constructions of both the specifications and the bodies of wrappers are modified. gcc/ada/ * freeze.adb (Build_DTW_Body): Add appropriate type conversions for controlling access parameters. * sem_util.adb (Build_Overriding_Spec): Fix designated types in controlling access parameters.
2023-05-25ada: Add Entry_Cancel_Parameter to E_LabelBob Duff4-3/+9
...and other (minor) changes. gcc/ada/ * gen_il-gen-gen_entities.adb (E_Label): Add Entry_Cancel_Parameter. This is necessary because Analyze_Implicit_Label_Declaration set the Ekind to E_Label. Without this change, this field would fail the vanishing-fields check in Atree (which is currently commented out). * einfo.ads (Entry_Cancel_Parameter): Document for E_Label. * sem_eval.adb (Why_Not_Static): Protect against previous errors (no need to explain why something is not static if it's already illegal for other reasons). * sem_util.ads (Enter_Name): Fix misleading comment.
2023-05-25ada: Minor fixes in description of scope depthEric Botcazou1-3/+3
In particular, the scope depth of library units is 1 instead of 0. gcc/ada/ * einfo.ads (Scope_Depth): Fix circular definition. (Scope_Depth_Value): Fix value for library units.
2023-05-25ada: Tune warning about assignment just before a raise statementPiotr Trojanek3-6/+5
Tune warning about a possibly ineffective assignment to a formal parameter that happens just before a raise statement. The warning is now emitted for parameters of all by-copy types and not just of scalar types (this gives more warnings), but is suppressed for aliased parameters (this removes some spurious warnings). gcc/ada/ * sem_ch11.adb (Analyze_Raise_Expression): Tune warning condition. * libgnat/g-dirope.ads (Open): Remove a potentially inaccurate comment. * libgnat/g-dirope.adb (Open): Remove a potentially useless assignment; the Dir output parameter should be assigned a null value anyway by the preceding call to Free.
2023-05-25ada: Accept aliased parameters in Exceptional_CasesPiotr Trojanek1-1/+2
Aliased parameters, just like parameters by-reference types, can safely appear in consequences of Exceptional_Cases aspect. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Allow aliased parameters; tune error message.
2023-05-25ada: Fix incorrect handling of Aggregate aspectMarc Poulhiès1-2/+8
This change fixes 2 incorrect handlings of the aspect. The arguments are now correctly resolved and the aspect is rejected on non array types. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Mark Aggregate aspect as needing delayed resolution and reject the aspect on non-array type.
2023-05-25ada: Fix obsolete comment in Sinfo.UtilsBob Duff1-1/+1
...caused by moving code here from Atree. gcc/ada/ * sinfo-utils.adb: Update comment to refer to New_Node_Debugging_Output.
2023-05-25ada: Fix SPARK context not restored when Load_Unit is failingMarc Poulhiès2-12/+31
When Load_Unit fails to find the unit or encounters an error, the Load_Fail procedure is called and an exception is raised, skipping the restoration of the SPARK/Ghost context stored on procedure entry. gcc/ada/ * rtsfind.adb (Load_RTU.Restore_SPARK_Context): New. (Load_RTU): Use Restore_SPARK_Context on all exit paths. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Initialize local variable to Empty.
2023-05-25ada: Restrict use of formal parameters within exceptional casesPiotr Trojanek2-0/+69
Restrict references to formal parameters within the new SPARK aspect Exceptional_Cases and allow occurrences of 'Old in this aspect. gcc/ada/ * sem_attr.adb (Analyze_Attribute_Old_Result): Allow uses of 'Old and 'Result within the new aspect. * sem_res.adb (Within_Exceptional_Cases_Consequence): New utility routine. (Resolve_Entity_Name): Restrict use of formal parameters within the new aspect.
2023-05-24Daily bump.GCC Administrator1-0/+393
2023-05-23Minor tweakEric Botcazou1-1/+1
2023-05-23ada: Accept and analyze new aspect Exceptional_CasesPiotr Trojanek17-13/+538
Add new aspect Exceptional_Cases, which is intended for SPARK and describes in which cases an exception will be raised, and optionally supply a postcondition that shall be verified in this case. The implementation is heavily modeled after Subprogram_Variant, which in turn was heavily modeled after Contract_Cases. Currently the aspect is only analysed; the code infrastructure required to expand it is prepared but empty. This is enough for the aspect to be verified by GNATprove. gcc/ada/ * aspects.ads (Aspect_Id): Add aspect identifier. (Aspect_Argument): New aspect accepts an expression. (Is_Representation_Aspect): New aspect is not a representation aspect. (Aspect_Names): Associate name with the new aspect identifier. (Aspect_Delay): New aspect is never delayed. * contracts.adb (Add_Contract_Item): Store new aspect among contract items. (Analyze_Entry_Or_Subprogram_Contract): Likewise. (Analyze_Subprogram_Body_Stub_Contract): Likewise. (Process_Contract_Cases): Expand new aspect, if present. * contracts.ads (Analyze_Entry_Or_Subprogram_Body_Contract): Mention new aspect in spec. (Analyze_Entry_Or_Subprogram_Contract): Likewise. * einfo-utils.adb (Get_Pragma): Allow new aspect to be picked by the backend. * einfo-utils.ads (Get_Pragma): Mention new aspect in spec. * exp_prag.adb (Expand_Pragma_Exceptional_Cases): Dummy expansion routine. * exp_prag.ads (Expand_Pragma_Exceptional_Cases): Add spec for expansion routine. * inline.adb (Remove_Aspects_And_Pragmas): Remove aspect from bodies to inline. * par-prag.adb (Par.Prag): Accept pragma in the parser, so it will be checked later. * sem_ch12.adb (Implementation of Generic Contracts): Mention new aspect in comment. * sem_ch13.adb (Analyze_Aspect_Specifications): Transform new aspect info a corresponding pragma. * sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Analyze aspect expression; heavily inspired by the existing code for analysis of Subprogram_Variant and exception handlers. (Analyze_Pragma): Analyze pragma corresponding to the new aspect. (Is_Non_Significant_Pragma_Reference): Add new pragma to the table. * sem_prag.ads (Assertion_Expression_Pragma): New pragma acts as an assertion expression, even though it is not currently expanded. (Analyze_Exceptional_Cases_In_Decl_Part): Add spec. * sem_util.adb (Is_Subprogram_Contract_Annotation): Mark new annotation is a subprogram contract, so the subprogram with it won't be inlined. * sem_util.ads (Is_Subprogram_Contract_Annotation): Mention new aspect in comment. * sinfo.ads (Contract_Test_Cases): Mention new aspect in comment. * snames.ads-tmpl: Add entries for the new name and pragma.
2023-05-23ada: Rework fix for internal error on quantified expression with predicated typeEric Botcazou3-35/+21
It turns out that skipping compiler-generated block scopes is problematic when computing the public status of a subprogram, because this subprogram may end up being nested in the elaboration procedure of a package spec or body, in which case it may not be public. This replaces the original fix with a pair of Push_Scope/Pop_Scope in the Build_Predicate_Function procedure, as done elsewhere in similar cases. gcc/ada/ * sem_ch13.adb (Build_Predicate_Functions): If the current scope is not that of the type, push this scope and pop it at the end. * sem_util.ads (Current_Scope_No_Loops_No_Blocks): Delete. * sem_util.adb (Current_Scope_No_Loops_No_Blocks): Likewise. (Set_Public_Status): Call again Current_Scope.
2023-05-23ada: ICE on BIP call in class-wide function return within instanceGary Dismukes2-2/+1
The compiler blows up (such as with a Storage_Error or Assert_Failure) on a call to a limited build-in-place function occurring in the return for a function with a limited class-wide result. Such a function should include extra formals for a task master and activation chain (because it's possible for a limited class-wide type to have values with task parts), but when the enclosing function occurs within an instantiation and the result subtype comes from a formal type, the extra formals were missing for the enclosing function. As a result, the attempt to retrieve the task master formal for passing along to a BIP call in the return failed when calling Build_In_Place_Formal to loop through the formals. When determining the need for the formals in Create_Extra_Formals, Needs_BIP_Actual_Task_Actuals was returning False, because Might_Have_Tasks incorrectly returned False due to the test of Is_Limited_Record flag on the class-wide generic actual subtype's Etype being False. Is_Limited_Record was not being properly inherited by the class-wide type in the case of private extensions, because Make_Class_Wide_Type was called in Analyze_Private_Extension_Declaration before certain flags (such as Is_Limited_Record and Is_Controlled_Active) are inherited later in Build_Derived_Record_Type (which will also call Make_Class_Wide_Type). This is corrected by removing the early call to Make_Class_Wide_Type. gcc/ada/ * exp_ch6.adb (Might_Have_Tasks): Remove unneeded Etype call from call to Is_Limited_Record, since that flag is now properly inherited by class-wide types. * sem_ch3.adb (Analyze_Private_Extension_Declaration): Remove call to Make_Class_Wide_Type, which is done too early, and will later be done in Build_Derived_Record_Type after flags such as Is_Limited_Record and Is_Controlled_Active have been set on the derived type.
2023-05-23ada: Remove redundant parentheses from System.Stack_Checking.OperationsPatrick Bernardi1-3/+2
gcc/ada/ * libgnat/s-stchop.adb (Stack_Check): Remove redundant parentheses.
2023-05-23ada: Add tags to warnings controlled by Warn_On_Redundant_ConstructsPiotr Trojanek3-8/+8
Some of the calls to Error_Msg_N controlled by the flag Warn_On_Redundant_Constructs missed the "?r?" tag in their message string. This caused a misleading "[enabled by default]" label to appear next to the error message. Spotted while adding a warning about duplicated choices in exception handlers. gcc/ada/ * freeze.adb (Freeze_Record_Type): Add tag for redundant pragma Pack. * sem_aggr.adb (Resolve_Record_Aggregate): Add tag for redundant OTHERS choice. * sem_ch8.adb (Use_One_Type): Add tag for redundant USE clauses.
2023-05-23ada: Cleanup inconsistent iteration over exception handlersPiotr Trojanek1-7/+5
When detecting duplicate choices in exception handlers we had inconsistent pairs of First/Next_Non_Pragma and First_Non_Pragma/Next. This was harmless, because exception choices don't allow pragmas at all, e.g.: when Program_Error | Constraint_Error | ...; -- pragma not allowed and exception handlers only allow pragmas to appear as the first item on the list, e.g.: exception pragma Inspection_Point; -- first item on the list of handlers when Program_Error => <statements> pragma Inspection_Point; -- last item on the list of statements when Constraint_Error => ... However, it still seems cleaner to have consistent pairs of First/Next and First_Non_Pragma/Next_Non_Pragma. gcc/ada/ * sem_ch11.adb (Check_Duplication): Fix inconsistent iteration. (Others_Present): Iterate over handlers using First_Non_Pragma and Next_Non_Pragma just like in Check_Duplication.
2023-05-23ada: Fix latent issue in support for protected entriesEric Botcazou12-91/+48
The problem is that, unlike for protected subprograms, the expansion of cleanups for protected entries is not delayed when they contain package instances with a body, so the cleanups are generated twice and this may yield two finalizers if the secondary stack is used in the entry body. This restores the delaying, which uncovers the missing propagation of the Uses_Sec_Stack flag as is done for protected subprograms, which in turn requires using a Corresponding_Spec field as for protected subprograms. This also gets rid of the Delay_Subprogram_Descriptors flag on entities, whose only remaining use in Expand_Cleanup_Actions was unreachable. The last change is to unconditionally reset the scopes in the case of protected subprograms when they are expanded, as is done in the case of protected entries. This makes it possible to remove the code adjusting the scope on the fly in Cleanup_Scopes but requires a few adjustments. gcc/ada/ * einfo.ads (Delay_Subprogram_Descriptors): Delete. * gen_il-fields.ads (Opt_Field_Enum): Remove Delay_Subprogram_Descriptors. * gen_il-gen-gen_entities.adb (Gen_Entities): Likewise. * gen_il-gen-gen_nodes.adb (N_Entry_Body): Add Corresponding_Spec. * sinfo.ads (Corresponding_Spec): Document new use. (N_Entry_Body): Likewise. * exp_ch6.adb (Expand_Protected_Object_Reference): Be prepared for protected subprograms that have been expanded. * exp_ch7.adb (Expand_Cleanup_Actions): Remove unreachable code. * exp_ch9.adb (Build_Protected_Entry): Add a local variable for the new block and propagate Uses_Sec_Stack from the corresponding spec. (Expand_N_Protected_Body) <N_Subprogram_Body>: Unconditionally reset the scopes of top-level entities in the new body. * inline.adb (Cleanup_Scopes): Do not adjust the scope on the fly. * sem_ch9.adb (Analyze_Entry_Body): Set Corresponding_Spec. * sem_ch12.adb (Analyze_Package_Instantiation): Remove obsolete code setting Delay_Subprogram_Descriptors and tidy up. * sem_util.adb (Scope_Within): Deal with protected subprograms that have been expanded. (Scope_Within_Or_Same): Likewise.
2023-05-23ada: Fix address manipulation issue in the tasking runtimeEric Botcazou4-33/+33
The implementation of task attributes in the runtime defines an atomic clone of System.Address, which is awkward for targets where addresses and pointers have a specific representation, so this change replaces that with a pragma Atomic_Components on the Attribute_Array type. gcc/ada/ * libgnarl/s-taskin.ads (Atomic_Address): Delete. (Attribute_Array): Add pragma Atomic_Components. (Ada_Task_Control_Block): Adjust default value of Attributes. * libgnarl/s-tasini.adb (Finalize_Attributes): Adjust type of local variable. * libgnarl/s-tataat.ads (Deallocator): Adjust type of parameter. (To_Attribute): Adjust source type. * libgnarl/a-tasatt.adb: Add clauses for System.Storage_Elements. (New_Attribute): Adjust return type. (Deallocate): Adjust type of parameter. (To_Real_Attribute): Adjust source type. (To_Address): Add target type. (To_Attribute): Adjust source type. (Fast_Path): Adjust tested type. (Finalize): Compare with Null_Address. (Reference): Likewise. (Reinitialize): Likewise. (Set_Value): Likewise. Add conversion to Integer_Address. (Value): Likewise.
2023-05-23ada: Make string interpolation part of the core extensionsRaphael Amiard1-6/+6
gcc/ada/ * scng.adb (Scan): Replace occurrences of All_Extensions_Allowed by Core_Extensions_Allowed.
2023-05-23ada: Update ghost code for proof of integer input functionsClaire Dross2-32/+41
Introduce new ghost helper functions to facilitate proof. gcc/ada/ * libgnat/s-valueu.adb (Scan_Raw_Unsigned): Use new helpers. * libgnat/s-vauspe.ads (Raw_Unsigned_Starts_As_Based_Ghost, Raw_Unsigned_Is_Based_Ghost): New ghost helper functions. (Is_Raw_Unsigned_Format_Ghost, Scan_Split_No_Overflow_Ghost, Scan_Split_Value_Ghost, Raw_Unsigned_Last_Ghost): Use new helpers.
2023-05-23ada: Add new switch -gnatyzArnaud Charlet15-108/+180
Improve -gnatyx to check additional complete conditions, and introduce a new switch -gnatyz to check for unnecessary parentheses according to operator precedence rules. Enable -gnatyz as part of -gnatyg. gcc/ada/ * par-ch5.adb, style.ads, styleg.adb, styleg.ads (Check_Xtra_Parens): Remove extra parameter Enable. (Check_Xtra_Parens_Precedence): New. (P_Case_Statement): Add -gnatyx style check. * sem_ch4.adb: Replace calls to Check_Xtra_Parens by Check_Xtra_Parens_Precedence. * stylesw.ads, stylesw.adb, usage.adb: Add support for -gnatyz. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update -gnatyxzg doc. * sem_prag.adb, libgnat/s-regpat.adb, libgnarl/s-interr__hwint.adb, libgnarl/s-interr__vxworks.adb: Remove extra parens. * par-ch3.adb (P_Discrete_Range): Do not emit a style check if the expression is not a simple expression. * gnat_ugn.texi: Regenerate.
2023-05-23ada: Fix minor address arithmetic issues in System.Dwarf_LinesEric Botcazou1-6/+6
Offset calculations should use the operator of System.Storage_Elements. gcc/ada/ * libgnat/s-dwalin.adb (Enable_Cache): Use the subtract operator of System.Storage_Elements to compute the offset. (Symbolic_Address): Likewise.
2023-05-23ada: Fix oversight in latest changeEric Botcazou1-1/+3
The resolution must be identical inside and outside the System hierarchy. gcc/ada/ * sem_res.adb (Resolve_Intrinsic_Operator): Always perform the same resolution for the special mod operator of System.Storage_Elements.
2023-05-23ada: Reorganize documentation of GNAT experimental featuresRaphael Amiard4-1499/+1937
gcc/ada/ * doc/gnat_rm.rst, doc/gnat_rm/gnat_language_extensions.rst, doc/gnat_rm/implementation_defined_pragmas.rst: * gnat_rm.texi: Regenerate.
2023-05-23ada: Fix resolution of mod operator of System.Storage_ElementsEric Botcazou2-8/+26
This operator is special because the left operand is of Address type while the right operand and the result are of Storage_Offset type (but we raise Constraint_Error if the right operand is not positive) and it needs to be resolved to the type of the left operand to implement the correct semantics. gcc/ada/ * exp_ch4.adb (Expand_N_Op_Mod): Adjust the detection of the special operator of System.Storage_Elements. Do not rewrite it into a rem. * sem_res.adb (Resolve_Intrinsic_Operator): Use the base type of the left operand for the special mod operator of System.Storage_Elements
2023-05-23ada: Remove unnecessary call to Detach.Vadim Godunko1-4/+0
Holder object is constant and protected from modification by tampering rules. gcc/ada/ * libgnat/a-coinho__shared.adb (Constant_Reference): Remove call of Detach (Query_Element): Likewise.