ada: Rework fix for wrong finalization of qualified aggregate in allocator The problem is that there is no easy method to insert an action after an arbitrary node in the tree, so the original fix does not correctly work when the allocator is nested in another expression. Therefore this moves the burden of the insertion from Apply_Predicate_Check to Expand_Allocator_Expression and restricts the new processing to the case where it is really required. gcc/ada/ * checks.ads (Apply_Predicate_Check): Add Deref boolean parameter. * checks.adb (Apply_Predicate_Check): Revert latest change. Use Loc local variable to hold the source location. Use a common code path for the generic processing and make a dereference if Deref is True. * exp_ch4.adb (Expand_Allocator_Expression): Compute Aggr_In_Place earlier. If it is true, do not call Apply_Predicate_Check on the expression on entry but on the temporary on exit with a dereference. * sem_res.adb (Resolve_Actuals): Add explicit parameter association in call to Apply_Predicate_Check.
ada: Remove GNATcheck violations Remove GNATcheck violations by refactoring code and also using pragma Annotate to exempt them. gcc/ada/ * libgnat/i-cstrin.adb (Free): Rewrite code so there is only one return, to remove Improper_Returns violation. (Position_Of_Nul): Add pragma to exempt Improper_Returns violation. (To_Chars_Ptr): Likewise. (Value): Likewise
ada: Crash initializing component of private record type The compiler may crash processing the full type declaration of a private record type that initializes a component with a call to a function instantiated in the private part of the package. gcc/ada/ * freeze.adb (Declared_In_Expanded_Body): New subprogram. (In_Expanded_Body): Minor code cleanup. (Freeze_Expression): Code cleanup plus factorize in a new function the code that identifies entities declared in the body of expander generated subprograms, since such case must be checked also for other node kinds when climbing the tree to locate the place to insert the freezing node.
ada: Fix predicate check failure in Expand_Allocator_Expression The For_Special_Return_Object flag needs to be accessed on entry of the procedure in case the allocator is rewritten during the processing. gcc/ada/ * exp_ch4.adb (Expand_Allocator_Expression): Add Special_Return boolean constant to hold the value of For_Special_Return_Object for the allocator and use it throughout the procedure.
ada: Add comment describing Partition_Elaboration_Policy dependency. Add a comment in the spec for the default (as opposed to hie) version of Ada.Real_Time.Timing_Events indicating that it is incompatible with a a Partition_Elaboration_Policy specification specifying a policy other than Concurrent. gcc/ada/ * libgnarl/a-rttiev.ads: add a comment
ada: Fix wrong finalization for qualified aggregate of limited type in allocator This happens with -gnata when the limited type has controlled components and a predicate, because the predicate check generated for the aggregate causes the creation of a temporary that is used as the expression of the allocator. Now this combination is illegal for a limited type, so the compiler does not generate the deep adjustment that would be necessary for the access value, which ultimately results in a wrong finalization. gcc/ada/ * checks.adb (Apply_Predicate_Check): Also deal specifically with an expression that is a qualified aggregate in an allocator.
ada: Ignore defered compile time errors without backend We defer some compile time warnings and errors until the backend has added the extra information needed. However it is not guaranteed that the backend has run by this point. Avoid checking these errors if the backend has not been activated and no code has been generated. gcc/ada/ * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Avoid checking compile time warnings and errors if backend has not been activated.
ada: Too-strict conformance checking for formal discriminated type The discriminant subtype conformance check for an actual parameter corresponding to a generic formal discriminated type was too strict and could incorrectly reject legal instantiations. gcc/ada/ * sem_ch12.adb (Validate_Discriminated_Formal_Type): Replace Entity_Id equality test with a call to Subtypes_Match. Distinct subtypes which are statically matching should pass this test. (Check_Discriminated_Formal): Replace Entity_Id equality test with a call to Subtypes_Statically_Match (preceded by a check that the preconditions for the call are satisfied).
ada: Fix spelling of functions with(out) "side effects" Correct spelling does not include an hyphen. Fix comments and one error message. Also fix other mispellings of "side-effect" or "side effect" depending on the case (adjective should have hyphen), and "side-effect-free" with double hyphen as an adjective. gcc/ada/ * checks.adb, exp_aggr.adb, exp_ch4.ads, exp_ch5.adb, exp_util.adb, exp_util.ads, inline.adb, sem_ch13.adb, sem_ch6.adb, sem_ch8.adb, sem_prag.adb, sem_util.ads: Fix comments and typos.
- [DBH] gcc/ada/checks.adb
- [DBH] gcc/ada/exp_aggr.adb
- [DBH] gcc/ada/exp_ch4.ads
- [DBH] gcc/ada/exp_ch5.adb
- [DBH] gcc/ada/exp_util.adb
- [DBH] gcc/ada/exp_util.ads
- [DBH] gcc/ada/inline.adb
- [DBH] gcc/ada/sem_ch13.adb
- [DBH] gcc/ada/sem_ch6.adb
- [DBH] gcc/ada/sem_ch8.adb
- [DBH] gcc/ada/sem_prag.adb
- [DBH] gcc/ada/sem_util.ads
ada: Support Put_Image for types in user-defined instances of predefined generics. Predefined units do not generally support the Put_Image attribute. There are good reasons for this in most cases. But if a user-defined instantiation of a predefined generic occurs in Ada 2022 code, then Put_Image can be supported for types declared therein. Add this support. gcc/ada/ * exp_put_image.adb (Put_Image_Enabled): Return True in more cases. In particular, when testing to see if a type occurs in a predefined unit, test the type's code unit (obtained by calling Get_Code_Unit). In the case of type within a user-defined instance of a predefined generic, Is_Predefined_Unit will return True for the type and False for the type's code unit.
ada: Constant_Indexing used when context requires a variable In the case of a call with a formal parameter of mode other than "IN" where the corresponding actual parameter is a generalized indexing and the indexable container has both Constant_Indexing and Variable_Indexing aspects specified, the generalized indexing must be interpreted as a variable indexing, not as a constant indexing. In some cases involving a call to a prefixed view of a subprogram, this was not handled correctly. This error results in spurious compile-time error messages saying that the actual parameter in the call "must be a variable". gcc/ada/ * sem_ch4.adb (Constant_Indexing_OK): As a temporary stopgap, return False in the case of an unanalyzed prefixed-view call.
ada: Name resolution in expanded instances In building the tree for an instance of a generic, expansion sets entity fields on names that refer to things declared outside of the instance, but leaves the entity field unset on names that should end up referring to things declared within the instance. These will instead be set by analysis - the idea is that if a name resolves a certain way in the generic, then we should get corresponding results if we resolve the corresponding name in an instance. For this to work, we have to prevent unrelated declarations that happen to be visible at the point of the instantiation from participating in resolution. Add code to filter out such unwanted name resolution candidates. gcc/ada/ * sem_ch8.adb (Find_Direct_Name): In the case of a resolving a name that occurs within an instantiation, add code to detect and filter out unwanted candidate resolutions. The filtering is performed via a call to Remove_Interp.
ada: Remove SPARK legality checks SPARK legality checks apply only to code with SPARK_Mode On, and are performed again in GNATprove for detecting SPARK-compatible declarations in code with SPARK_Mode Auto. Remove this duplication, to only perform SPARK legality checking in GNATprove. After this patch, only a few special SPARK legality checks are performed in the frontend, which could be moved to GNATprove later. gcc/ada/ * contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract): Remove checking on volatility. Remove handling of SPARK_Mode, not needed anymore. (Analyze_Entry_Or_Subprogram_Contract): Remove checking on volatility. (Check_Type_Or_Object_External_Properties): Same. (Analyze_Object_Contract): Same. * freeze.adb (Freeze_Record_Type): Same. Also remove checking on synchronized types and ghost types. * sem_ch12.adb (Instantiate_Object): Remove checking on volatility. (Instantiate_Type): Same. * sem_ch3.adb (Access_Type_Declaration): Same. (Derived_Type_Declaration): Remove checking related to untagged partial view. (Process_Discriminants): Remove checking on volatility. * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Same. * sem_ch6.adb (Analyze_Procedure_Call): Fix use of SPARK_Mode where GNATprove_Mode was intended. * sem_disp.adb (Inherited_Subprograms): Protect against Empty node. * sem_prag.adb (Analyze_Global_In_Decl_Part): Remove checking on volatility. (Analyze_Pragma): Same. * sem_res.adb (Flag_Effectively_Volatile_Objects): Remove. (Resolve_Actuals): Remove checking on volatility. (Resolve_Entity_Name): Same. * sem_util.adb (Check_Nonvolatile_Function_Profile): Remove. (Check_Volatility_Compatibility): Remove. * sem_util.ads: Same.
Fix PR ada/111909 On Darwin, determine filesystem case sensitivity at runtime In gcc/ada/adaint.c(__gnat_get_file_names_case_sensitive), the current assumption for __APPLE__ is that file names are case-insensitive unless __arm__ or __arm64__ are defined, in which case file names are declared case-sensitive. The associated comment is "By default, we suppose filesystems aren't case sensitive on Windows and Darwin (but they are on arm-darwin)." This means that on aarch64-apple-darwin, file names are treated as case-sensitive, which is not the default case. The true default position is that macOS file systems are case-insensitive, iOS file systems are case-sensitive. Apple provide a header file <TargetConditionals.h> which permits a compile-time check for the compiler target (e.g. OSX vs IOS); if TARGET_OS_IOS is defined as 1, this is a build for iOS. 2023-11-22 Simon Wright <[email protected]> gcc/ada/ PR ada/111909 * adaint.c (__gnat_get_file_names_case_sensitive): Split out the __APPLE__ check and remove the checks for __arm__, __arm64__. For Apple, file names are by default case-insensitive unless TARGET_OS_IOS is set. Signed-off-by: Simon Wright <[email protected]>
ada: Errors on instance of Multiway_Trees with discriminated type The compiler may report various type conflicts on an instantiation of the generic package Ada.Containers.Multiway_Trees with an actual for Element_Type that is a nonprivate actual type with discriminants that has a discriminant-dependent component of a private type (such as a Bounded_Vector type). The type errors occur on an aggregate of the implementation type Tree_Node_Type within the body of Multiway_Trees, where the aggregate has a box-defaulted association for the Element component. (Such type errors could of course arise in other cases of generic instantiations that follow a similar type model.) In the case where the discriminant-dependent component type has a default-initialization procedure (init proc), the compiler was handling box associations for such components by expanding the topmost box association into subaggregates that themselves have box associations, and didn't properly account for discriminant-dependent subcomponents of private types. This could be fixed internally in Propagate_Discriminants, but it seems that the entire machinery for dealing with such subcomponent associations is unnecessary, and the topmost component association can be handled directly as a default-initialized box association. gcc/ada/ * sem_aggr.adb (Add_Discriminant_Values): Remove this procedure. (Propagate_Discriminants): Remove this procedure. (Resolve_Record_Aggregate): Remove code (the Capture_Discriminants block statement) related to propagating discriminants and generating initializations for subcomponents of a discriminant-dependent box-defaulted subcomponent of a nonprivate record type with discriminants, and handle all top-level components that have a non-null base init proc directly, by calling Add_Association with "Is_Box_Present => True". Also, combine that elsif clause with the immediately preceding elsif clause, since they now both contain the same statement (calls to Add_Association with the same actuals).