aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat
AgeCommit message (Collapse)AuthorFilesLines
2024-06-27ada: Remove last uses of System.Address_Operations in runtime libraryEric Botcazou11-49/+64
This completes the switch from using System.Address_Operations to using only System.Storage_Elements in the runtime library. The remaining uses were for simple optimizations that can be done by the optimizer alone. gcc/ada/ * libgnat/s-carsi8.adb: Remove clauses for System.Address_Operations and use only operations of System.Storage_Elements for addresses. * libgnat/s-casi16.adb: Likewise. * libgnat/s-casi32.adb: Likewise. * libgnat/s-casi64.adb: Likewise. * libgnat/s-casi128.adb: Likewise. * libgnat/s-carun8.adb: Likewise. * libgnat/s-caun16.adb: Likewise. * libgnat/s-caun32.adb: Likewise. * libgnat/s-caun64.adb: Likewise. * libgnat/s-caun128.adb: Likewise. * libgnat/s-geveop.adb: Likewise.
2024-06-27ada: Implement first half of Generalized FinalizationEric Botcazou1-3/+7
This implements the first half of the Generalized Finalization proposal, namely the Finalizable aspect as well as its optional relaxed semantics for the finalization operations, but the latter part is only implemented for dynamically allocated objects. In accordance with the spirit, if not the letter, of the proposal, this implements the finalizable types declared with strict semantics for the finalization operations as a direct generalization of controlled types, which in turn makes it possible to reimplement the latter types in terms of the former types and ensures full interoperability between them. The relaxed semantics for the finalization operations is also a direct generalization of the GNAT pragma No_Heap_Finalization for dynamically allocated objects, in that it extends the effects of the pragma to all access types designating the finalizable type, instead of just applying them to library-level named access types. gcc/ada/ * aspects.ads (Aspect_Id): Add Aspect_Finalizable. (Implementation_Defined_Aspect): Add True for Aspect_Finalizable. (Operational_Aspect): Add True for Aspect_Finalizable. (Aspect_Argument): Add Expression for Aspect_Finalizable. (Is_Representation_Aspect): Add False for Aspect_Finalizable. (Aspect_Names): Add Name_Finalizable for Aspect_Finalizable. (Aspect_Delay): Add Always_Delay for Aspect_Finalizable. * checks.adb: Add with and use clauses for Sem_Elab. (Install_Primitive_Elaboration_Check): Call Is_Controlled_Procedure. * einfo.ads (Has_Relaxed_Finalization): Document new flag. (Is_Controlled_Active): Update documentation. * exp_aggr.adb (Generate_Finalization_Actions): Replace Find_Prim_Op with Find_Controlled_Prim_Op for Name_Finalize. * exp_attr.adb (Expand_N_Attribute_Reference) <Finalization_Size>: Return 0 if the prefix type has relaxed finalization. * exp_ch3.adb (Build_Equivalent_Record_Aggregate): Return Empty if the type needs finalization. (Expand_Freeze_Record_Type): Call Find_Controlled_Prim_Op instead of Find_Prim_Op for Name_{Adjust,Initialize,Finalize}. Call Make_Finalize_Address_Body for all controlled types. * exp_ch4.adb (Insert_Dereference_Action): Do not generate a call to Adjust_Controlled_Dereference if the designated type has relaxed finalization. * exp_ch6.adb (Needs_BIP_Collection): Return false for an untagged type that has relaxed finalization. * exp_ch7.adb (Allows_Finalization_Collection): Return false if the designated type has relaxed finalization. (Check_Visibly_Controlled): Call Find_Controlled_Prim_Op instead of Find_Prim_Op. (Make_Adjust_Call): Likewise. (Make_Deep_Record_Body): Likewise. (Make_Final_Call): Likewise. (Make_Init_Call): Likewise. * exp_disp.adb (Set_All_DT_Position): Remove obsolete warning. * exp_util.ads: Add with and use clauses for Snames. (Find_Prim_Op): Add precondition. (Find_Controlled_Prim_Op): New function declaration. (Name_Of_Controlled_Prim_Op): Likewise. * exp_util.adb: Remove with and use clauses for Snames. (Build_Allocate_Deallocate_Proc): Do not build finalization actions if the designated type has relaxed finalization. (Find_Controlled_Prim_Op): New function. (Find_Last_Init): Call Find_Controlled_Prim_Op instead of Find_Prim_Op. (Name_Of_Controlled_Prim_Op): New function. * freeze.adb (Freeze_Entity.Freeze_Record_Type): Propagate the Has_Relaxed_Finalization flag from components. * gen_il-fields.ads (Opt_Field_Enum): Add Has_Relaxed_Finalization. * gen_il-gen-gen_entities.adb (Entity_Kind): Likewise. * sem_aux.adb (Is_By_Reference_Type): Return true for all controlled types. * sem_ch3.adb (Build_Derived_Record_Type): Do not special case types declared in Ada.Finalization. (Record_Type_Definition): Propagate the Has_Relaxed_Finalization flag from components. * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Also process the Finalizable aspect. (Analyze_Aspect_Specifications): Likewise. Call Flag_Non_Static_Expr in more cases. (Check_Aspect_At_Freeze_Point): Likewise. (Inherit_Aspects_At_Freeze_Point): Likewise. (Resolve_Aspect_Expressions): Likewise. (Resolve_Finalizable_Argument): New procedure. (Validate_Finalizable_Aspect): Likewise. * sem_elab.ads: Add with and use clauses for Snames. (Is_Controlled_Procedure): New function declaration. * sem_elab.adb: Remove with and use clauses for Snames. (Is_Controlled_Proc): Move to... (Is_Controlled_Procedure): ...here and rename. (Check_A_Call): Call Find_Controlled_Prim_Op instead of Find_Prim_Op. (Is_Finalization_Procedure): Likewise. * sem_util.ads (Propagate_Controlled_Flags): Update documentation. * sem_util.adb (Is_Fully_Initialized_Type): Replace call to Find_Optional_Prim_Op with Find_Controlled_Prim_Op. Call Has_Null_Extension only for derived tagged types. (Propagate_Controlled_Flags): Propagate Has_Relaxed_Finalization. * snames.ads-tmpl (Name_Finalizable): New name. (Name_Relaxed_Finalization): Likewise. * libgnat/s-finroo.ads (Root_Controlled): Add Finalizable aspect. * doc/gnat_rm/gnat_language_extensions.rst: Document implementation of Generalized Finalization. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-06-13ada: Minor cleanups in generic formal matchingBob Duff3-3/+3
Minor rewording of a warning. Disallow positional notation for <> (but disable this check), and fix resulting errors. Copy use clauses. gcc/ada/ * sem_ch12.adb (Check_Fixed_Point_Actual): Minor rewording; it seems more proper to say "operator" rather than "operation". (Matching_Actual): Give an error for <> in positional notation. This is a syntax error. Disable this for now. (Analyze_Associations): Copy the use clause in all cases. The "mustn't recopy" comment seems wrong, because New_Copy_Tree preserves Slocs. * libgnat/a-ticoau.ads: Fix violation of new postion-box error. * libgnat/a-wtcoau.ads: Likewise. * libgnat/a-ztcoau.ads: Likewise.
2024-06-13ada: Streamline elaboration of local tagged typesEric Botcazou6-37/+223
This set of changes is aimed at streamlining the code generated for the elaboration of local tagged types. The dispatch tables and other related data structures are built dynamically on the stack for them and a few of the patterns used for this turn out to be problematic for the optimizer: 1. the array of primitives in the dispatch table is default-initialized to null values by calling the initialization routine of an unconstrained array type, and then immediately assigned an aggregate made up of the same null values. 2. the external tag is initialized by means of a dynamic concatenation involving the secondary stack, but all the elements have a fixed size. 3. the _size primitive is saved in the TSD by means of the dereference of the address of the TSD that was previously saved in the dispatch table. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imad32$(objext), s-imad64$(objext) and s-imagea$(objext). * exp_atag.ads (Build_Set_Size_Function): Replace Tag_Node parameter with Typ parameter. * exp_atag.adb: Add clauses for Sinfo.Utils. (Build_Set_Size_Function): Retrieve the TSD object statically. * exp_disp.adb: Add clauses for Ttypes. (Make_DT): Call Address_Image{32,64] instead of Address_Image. (Register_Primitive): Pass Tag_Typ to Build_Set_Size_Function. * rtsfind.ads (RTU_Id): Remove System_Address_Image and add System_Img_Address_{32;64}. (RE_Id): Remove entry for RE_Address_Image and add entries for RE_Address_Image{32,64}. * rtsfind.adb (System_Descendant): Adjust to above changes. * libgnat/a-tags.ads (Address_Array): Suppress initialization. * libgnat/s-addima.adb (System.Address_Image): Call the appropriate routine based on the address size. * libgnat/s-imad32.ads: New file. * libgnat/s-imad64.ads: Likewise. * libgnat/s-imagea.ads: Likewise. * libgnat/s-imagea.adb: Likewise. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS) [$(STAGE1)=False]: Add ada/libgnat/s-imad32.o and ada/libgnat/s-imad64.o.
2024-06-13ada: Add support for symbolic backtraces with DLLs on WindowsEric Botcazou3-28/+29
This puts Windows on par with Linux as far as backtraces are concerned. gcc/ada/ * libgnat/s-tsmona__linux.adb (Get): Move down descriptive comment. * libgnat/s-tsmona__mingw.adb: Add with clause and use clause for System.Storage_Elements. (Get): Pass GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT in the call to GetModuleHandleEx and remove the subsequent call to FreeLibrary. Upon success, set Load_Addr to the base address of the module. * libgnat/s-win32.ads (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS): Use shorter literal. (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT): New constant.
2024-06-10ada: Fix references to Ada RM in commentsPiotr Trojanek1-1/+1
We seem to have a convention of using "RM" in the GNAT comments, not "Ada RM". Also, the paragraph references by convention should appear in parentheses, e.g. "8.3(12.3/2)", not "8.3 12.3/2". gcc/ada/ * einfo.ads, exp_attr.adb, exp_ch4.adb, exp_ch7.adb, lib-writ.adb, libgnat/a-stbuut.ads, sem_ch13.adb, sem_ch3.adb, sem_ch7.adb: Use "RM" in comments.
2024-06-10ada: Remove streaming facilities from generics for formal containersYannick Moy2-92/+0
The dependency on Ada.Streams is problematic for light runtimes. As these streaming facilities are in fact not used in formal containers, remove the corresponding dead code. gcc/ada/ * libgnat/a-chtgfo.adb (Generic_Read, Generic_Write): Remove. * libgnat/a-chtgfo.ads: Same. Remove dependency on Ada.Streams.
2024-06-10ada: Fix usage of SetThreadAffinityMaskRonan Desplanques1-1/+1
This patches fixes the signature of the binding to SetThreadAffinityMask in the run-time library. It also fixes the error checking after calls to SetThreadAffinityMask. The previous code behaved as if SetThreadAffinityMask returned 1 on success, but it in fact returns a pointer value on success and 0 on failure. gcc/ada/ * libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage of SetThreadAffinityMask. * libgnat/s-winext.ads (SetThreadAffinityMask): Fix binding signature.
2024-06-10ada: Remove incorrect assertion in run-timeRonan Desplanques1-11/+11
There is a special case of file paths on Windows that are absolute but don't start with a drive letter: UNC paths. This patch removes an assertion in System.OS_Lib.Normalize_Pathname that failed to take this case into account. It also renames a local subprogram of Normalize_Pathname to make its purpose clearer. gcc/ada/ * libgnat/s-os_lib.adb (Normalize_Pathname): Remove incorrect assert statement. (Missed_Drive_Letter): Rename into... (Drive_Letter_Omitted): This.
2024-05-21Fix Ada runtime library breakage on Solaris (bis)Eric Botcazou1-4/+1
Recent changes made to the runtime library broke again its build on Solaris because it uses Solaris threads instead of POSIX threads on this platform. gcc/ada/ PR ada/115168 * libgnarl/s-taprop__solaris.adb (Initialize): Fix pasto. * libgnat/s-oslock__solaris.ads (Owner_Int): Delete. (Owner_ID): Change the designated type to Integer.
2024-05-21ada: Add new Mingw task priority mappingJustin Squirek1-3/+24
This patch adds a new mapping (Non_FIFO_Underlying_Priorities) for dynamically setting task priorities in Windows when pragma Task_Dispatching_Policy (FIFO_Within_Priorities) is not present. Additionally, it documents the requirement to specify the pragma in order to use Set_Priority in the general case. gcc/ada/ * doc/gnat_ugn/platform_specific_information.rst: Add note about different priority level granularities under different policies in Windows and move POSIX related info into new section. * libgnarl/s-taprop.ads: Add note about Task_Dispatching_Policy. * libgnarl/s-taprop__mingw.adb: (Set_Priority): Add use of Non_FIFO_Underlying_Priorities. * libgnat/system-mingw.ads: Add documentation for modifying priority mappings and add alternative mapping Non_FIFO_Underlying_Priorities. * gnat_ugn.texi: Regenerate.
2024-05-20ada: Add direct workaround for limitations of RTSfind mechanismEric Botcazou1-8/+11
This adds a direct workaround for the spurious compilation errors caused by the presence of preconditions/postconditions in the Interfaces.C unit, which trip on limitations of the RTSfind mechanism when it comes to visibility, as well as removes an indirect workaround that was added very recently. These errors were first triggered in the context of finalization and worked around by preloading the System.Finalization_Primitives unit. Now they also appear in the context of tasking, and it turns out that the preloading trick does not work for separate compilation units. gcc/ada/ * exp_ch7.ads (Preload_Finalization_Collection): Delete. * exp_ch7.adb (Allows_Finalization_Collection): Revert change. (Preload_Finalization_Collection): Delete. * opt.ads (Interface_Seen): Likewise. * scng.adb (Scan): Revert latest change. * sem_ch10.adb: Remove clause for Exp_Ch7. (Analyze_Compilation_Unit): Revert latest change. * libgnat/i-c.ads: Use a fully qualified name for the standard "+" operator in the preconditons/postconditions of subprograms.
2024-05-20ada: Use System.Address for address computation in System.Pool_GlobalSebastian Poeplau1-3/+4
Some architectures don't let us convert System.Storage_Elements.Integer_Address back to a valid System.Address. Using the arithmetic operations on System.Address from System.Storage_Elements prevents the problem while leaving semantics unchanged. gcc/ada/ * libgnat/s-pooglo.adb (Allocate): Use arithmetic on System.Address to compute the aligned address.
2024-05-20ada: One more adjustment coming from aliasing considerationsEric Botcazou1-2/+5
It is needed on PowerPC platforms because of specific calling conventions. gcc/ada/ * libgnat/g-sothco.ads (In_Addr): Add aspect Universal_Aliasing.
2024-05-20ada: Small cleanup in System.Finalization_Primitives unitEric Botcazou2-24/+28
It has been made possible by recent changes. gcc/ada/ * libgnat/s-finpri.ads (Collection_Node): Move to private part. (Collection_Node_Ptr): Likewise. (Header_Alignment): Change to declaration and move completion to private part. (Header_Size): Likewise. (Lock_Type): Delete. (Finalization_Collection): Move Lock component and remove default value for Finalization_Started component. * libgnat/s-finpri.adb (Initialize): Reorder statements.
2024-05-18Fix Ada runtime library breakage on SolarisEric Botcazou1-3/+4
The recent changes made to the runtime library broke its build on Solaris because it uses Solaris threads instead of POSIX threads on this platform. gcc/ada/ PR ada/115133 * libgnarl/s-osinte__solaris.ads (mutex_t): Fix typo. * libgnarl/s-taprop__solaris.adb (Record_Lock): Add conversion. (Check_Sleep): Likewise. (Record_Wakeup): Likewise. (Check_Unlock): Likewise. * libgnarl/s-tasini.adb (Initialize_RTS_Lock): Add pragma Import on the overlaid variable. (Finalize_RTS_Lock): Likewise. (Acquire_RTS_Lock): Likewise. (Release_RTS_Lock): Likewise. * libgnarl/s-taspri__solaris.ads (To_RTS_Lock_Ptr): New instance of Ada.Unchecked_Conversion. * libgnat/s-oslock__solaris.ads: Add with clause for Ada.Unchecked_Conversion. (array_type_9): Add missing name qualification. (record_type_3): Likewise. (mutex_t): Fix formatting.
2024-05-17ada: Start the initialization of the tasking runtime earlierEric Botcazou1-1/+3
This installs the tasking versions of the RTS_Lock manipulation routines very early, before the elaboration of all the Ada units of the program, including those of the runtime, because this elaboration may require the initialization of RTS_Lock objects. gcc/ada/ * bindgen.adb (Gen_Adainit): Generate declaration and call to the imported procedure __gnat_tasking_runtime_initialize if need be. * libgnat/s-soflin.ads (Locking Soft-Links): Add commentary. * libgnarl/s-tasini.adb (Tasking_Runtime_Initialize): New procedure exported as __gnat_tasking_runtime_initialize. Initialize RTS_Lock manipulation routines here instead of... (Init_RTS): ...here.
2024-05-17ada: Further adjustments coming from aliasing considerationsEric Botcazou2-0/+14
They are needed on 32-bit platforms because of different calling conventions and again in the units implementing AltiVec and Streams support. gcc/ada/ * libgnat/g-alvevi.ads: Add pragma Universal_Aliasing for all the view types. * libgnat/s-stratt.ads: Likewise for Fat_Pointer type.
2024-05-17ada: Replace spinlocks with fully-fledged locks in finalization collectionsEric Botcazou9-12/+372
This replaces spinlocks with fully-fledged locks in finalization collections because the former are deemed problematic with tasks that can be preempted. Because of the requirement to avoid dragging the tasking runtime when it is not necessary, the implementation goes through the usual soft links, with an additional hurdle that space must be reserved for the lock in any case since it is part of the ABI. This entails the introduction of the System.OS_Locks unit in the non-tasking runtime and the modification of the tasking runtime to also use this unit. This in turn requires a small adjustment: because of the presence of pre- and post-conditions in Interfaces.C and of the limitations of the RTSfind mechanism, the System.Finalization_Primitives unit must be preloaded, as what is done for the Ada.Strings.Text_Buffers unit. This effectively reverts the implementation to using the global task lock on bare board platforms. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-oslock$(objext). (LIBGNAT_TARGET_PAIRS): Use s-oslock__dummy.ads by default. Set specific s-oslock.ads source file for all the platforms. * exp_ch7.ads (Preload_Finalization_Collection): New procedure. * exp_ch7.adb (Allows_Finalization_Collection): Return False if System.Finalization_Primitives has not been preloaded. (Preload_Finalization_Collection): New procedure. * opt.ads (Interface_Seen): New boolean variable. * s-oscons-tmplt.c: Use "N" string for pragma Style_Checks. * scng.adb (Scan): Set Interface_Seen upon seeing "interface". * sem_ch10.adb: Add clause for Exp_Ch7. (Analyze_Compilation_Unit): Call Preload_Finalization_Collection after the context of the unit is analyzed. * libgnarl/a-rttiev.adb: Add with clause for System.OS_Locks and alphabetize others. (Event_Queue_Lock): Adjust qualified name of subtype. * libgnarl/s-osinte__aix.ads: Add with clause for System.OS_Locks and change pthread_mutex_t into a local subtype. * libgnarl/s-osinte__android.ads: Likewise. * libgnarl/s-osinte__darwin.ads: Likewise. * libgnarl/s-osinte__dragonfly.ads: Likewise. * libgnarl/s-osinte__freebsd.ads: Likewise. * libgnarl/s-osinte__gnu.ads: Likewise. * libgnarl/s-osinte__hpux-dce.ads: Likewise. * libgnarl/s-osinte__hpux.ads: Add Likewise. * libgnarl/s-osinte__kfreebsd-gnu.ads: Likewise. * libgnarl/s-osinte__linux.ads: Likewise. * libgnarl/s-osinte__lynxos178e.ads: Likewise. * libgnarl/s-osinte__qnx.ads: Likewise. * libgnarl/s-osinte__rtems.ads: Likewise. * libgnarl/s-osinte__mingw.ads: Add with clause for System.OS_Locks and change CRITICAL_SECTION into a local subtype. Add declarations for imported procedures dealing with CRITICAL_SECTION. * libgnarl/s-osinte__solaris.ads: Add with clause for System.OS_Locks and change mutex_t into a local subtype. * libgnarl/s-osinte__vxworks.ads: Add missing blank line. * libgnarl/s-taprop.ads: Alphabetize clauses and package renamings. Use qualified name for RTS_Lock throughout. * libgnarl/s-taprop__dummy.adb: Add use clause for System.OS_Locks and alphabetize others. * libgnarl/s-taprop__hpux-dce.adb: Likewise. * libgnarl/s-taprop__linux.adb: Likewise. * libgnarl/s-taprop__posix.adb: Likewise. * libgnarl/s-taprop__qnx.adb: Likewise. * libgnarl/s-taprop__rtems.adb: Likewise. * libgnarl/s-taprop__solaris.adb: Likewise. * libgnarl/s-taprop__vxworks.adb: Likewise. * libgnarl/s-taprop__mingw.adb: Likewise. Remove declarations for imported procedures dealing with CRITICAL_SECTION. * libgnarl/s-tarest.adb: Add with clause for System.OS_Locks and alphabetize others. (Global_Task_Lock): Adjust qualified name of subtype. * libgnarl/s-tasini.adb: Add clause for System.OS_Locks. (Initialize_RTS_Lock): New procedure. (Finalize_RTS_Lock): Likewise. (Acquire_RTS_Lock): Likewise. (Release_RTS_Lock): Likewise. (Init_RTS): Add compile-time assertions for RTS_Lock types. Set the soft links for the RTS lock manipulation routines. * libgnarl/s-taspri__dummy.ads: Add with clause for System.OS_Locks. (RTS_Lock): Delete and adjust throughout accordingly. * libgnarl/s-taspri__hpux-dce.ads: Likewise. * libgnarl/s-taspri__lynxos.ads: Likewise. * libgnarl/s-taspri__mingw.ads: Likewise. * libgnarl/s-taspri__posix-noaltstack.ads: Likewise. * libgnarl/s-taspri__posix.ads: Likewise. * libgnarl/s-taspri__solaris.ads: Likewise. * libgnarl/s-taspri__vxworks.ads: Likewise. * libgnat/s-finpri.ads: Add clause for System.OS_Locks. (Finalization_Collection): Change type of Lock. * libgnat/s-finpri.adb (Initialize): Call Initialize_RTS_Lock. (Lock_Collection): Call Acquire_RTS_Lock. (Unlock_Collection): Call Release_RTS_Lock. * libgnat/s-oslock__dummy.ads: New file. * libgnat/s-oslock__hpux-dce.ads: Likewise. * libgnat/s-oslock__mingw.ads: Likewise. * libgnat/s-oslock__posix.ads: Likewise. * libgnat/s-oslock__solaris.ads: Likewise. * libgnat/s-oslock__vxworks.ads: Likewise. * libgnat/s-soflin.ads (Null_Set_Address): New null procedure. (Initialize_RTS_Lock): New soft link. (Finalize_RTS_Lock): Likewise. (Acquire_RTS_Lock): Likewise. (Release_RTS_Lock): Likewise. * exp_ch4.adb (Expand_N_Allocator): In the subtype indication case, call Apply_Predicate_Check on the resulting access value if need be.
2024-05-17ada: Do not query the modification time of a special file.Steve Baird1-2/+16
In Ada.Directories, the function Modification_Time raises Name_Error if it is called for a special file. So don't do that in Start_Search_Internal. gcc/ada/ * libgnat/a-direct.adb (Start_Search_Internal): Do not call Modification_Time for a special file; declare a Calendar.Time constant No_Time and use that instead.
2024-05-17ada: Couple of adjustments coming from aliasing considerationsEric Botcazou3-7/+61
The first adjustment is to the expansion of implementation types for array types with peculiar index types, for which the aliased property set on the component of the original type must be copied; the implicit base type also needs to be properly marked if the implementation type is constrained. The second adjustment is to selected types in the runtime, which need to be marked with pragma Universal_Aliasing because of their special usage. gcc/ada/ * exp_pakd.adb (Create_Packed_Array_Impl_Type): For non-bit-packed array types, propagate the aliased property of the component. (Install_PAT): Set fields on the implicit base type of an array. * libgnat/a-stream.ads (private part): Add pragma Universal_Aliasing for Stream_Element. * libgnat/g-alleve.ads: Add pragma Universal_Aliasing for all the vector types. * libgnat/g-alleve__hard.ads: Likewise.
2024-05-17ada: Fix containers' Reference_Preserving_Key functions' memory leaksSteve Baird6-2/+56
Fix memory leaks in containers' Reference_Preserving_Key functions Make the same change in each of 3 Ada.Containers child units: Ordered_Sets, Indefinite_Ordered_Sets, and Bounded_Ordered_Sets. The function Reference_Preserving_Key evaluates an allocator of type Key_Access whose storage was not being reclaimed. Update the Finalize procedure for type Reference_Control_Type to free that storage. But this change introduces a possible erroneous double-free situation if an object is copied (because the original and the copy will each be finalized at some point). So also introduce an Adjust procedure which allocates a copy of the allocated object. Another possible solution to this problem (which is not being implemented yet) is based on implementing AI22-0082. Also include a fix for a bug in Sem_Util.Has_Some_Controlled_Component that was discovered while working on this. gcc/ada/ * sem_util.adb (Has_Some_Controlled_Component): Fix a bug which causes (in some cases involving a Disable_Controlled aspect specification) Needs_Finalization to return different answers for one type depending on whether the function is called before or after the type is frozen. * libgnat/a-coorse.ads: Type Control_Reference_Type gets an Adjust procedure. * libgnat/a-cborse.ads: Likewise. * libgnat/a-ciorse.ads: Likewise * libgnat/a-coorse.adb: (Finalize): Reclaim allocated Key_Type object. (Adjust): New procedure; prevent sharing of non-null Key_Access values by allocating a copy. * libgnat/a-cborse.adb: Likewise. * libgnat/a-ciorse.adb: Likewise.
2024-05-16ada: Exception on Indefinite_Vector aggregate with loop_parameter_specificationGary Dismukes1-1/+1
Constraint_Error is raised on evaluation of a container aggregate with a loop_parameter_specification for the type Indefinite_Vector. This happens due to the Aggregate aspect for type Indefinite_Vector specifying the Empty_Vector constant for the type's Empty operation rather than using the type's primitive Empty function. This problem shows up as a recent regression relative to earlier compilers, evidently due to recent fixes in the container aggregate area, which uncovered this issue of the wrong specification in Ada.Containers.Indefinite_Vectors. The compiler incorrectly initializes the aggregate object using the Empty_Vector constant rather than invoking the New_Vector function to allocate the vector object with the appropriate number of elements, and subsequent calls to Replace_Element fail because the vector object is empty. In addition to correcting the Indefinite_Vectors generic package, checking is added to give an error for an attempt to specify the Empty operation as a constant rather than a function. (Also note that another AdaCore package that needs a similar correction is the VSS.Vector_Strings package.) gcc/ada/ * libgnat/a-coinve.ads (type Vector): In the Aggregate aspect for this type, the Empty operation is changed to denote the Empty function, rather than the Empty_Vector constant. * exp_aggr.adb (Expand_Container_Aggregate): Remove code for handling the case where the Empty_Subp denotes a constant object, which should never happen (and add an assertion that Empty_Subp must denote a function). * sem_ch13.adb (Valid_Empty): No longer allow the entity to be an E_Constant, and require the (optional) parameter of an Empty function to be of a signed integer type (rather than any integer type).
2024-05-16ada: Propagate Program_Error from failed finalization of collectionEric Botcazou1-6/+6
This aligns finalization collections with finalization masters when it comes to propagating an exception raised by the finalization of a specific object, by always propagating Program_Error instead of the aforementioned exception. gcc/ada/ * libgnat/s-finpri.adb (Raise_From_Controlled_Operation): New declaration of imported procedure moved from... (Finalize_Master): ...there. (Finalize): Call Raise_From_Controlled_Operation instead of Reraise_Occurrence to propagate the exception, if any.
2024-05-16ada: Minor performance improvement for dynamically-allocated controlled objectsEric Botcazou2-22/+6
The values returned by Header_Alignment and Header_Size are known at compile time and powers of two on almost all platforms, so inlining them by means of an expression function improves the object code generated for alignment and size calculations involving them. gcc/ada/ * libgnat/s-finpri.ads: Add use type clause for Storage_Offset. (Header_Alignment): Turn into an expression function. (Header_Size): Likewise. * libgnat/s-finpri.adb: Remove use type clause for Storage_Offset. (Header_Alignment): Delete. (Header_Size): Likewise.
2024-05-16ada: Fix latent alignment issue for dynamically-allocated controlled objectsEric Botcazou4-37/+66
Dynamically-allocated controlled objects are attached to a finalization collection by means of a hidden header placed right before the object, which means that the size effectively allocated must naturally account for the size of this header. But the allocation must also account for the alignment of this header in order to have it properly aligned. gcc/ada/ * libgnat/s-finpri.ads (Header_Alignment): New function. (Header_Size): Adjust description. (Master_Node): Put Finalize_Address as first component. (Collection_Node): Likewise. * libgnat/s-finpri.adb (Header_Alignment): New function. (Header_Size): Return the object size in storage units. * libgnat/s-stposu.ads (Adjust_Controlled_Dereference): Replace collection node with header in description. * libgnat/s-stposu.adb (Adjust_Controlled_Dereference): Likewise. (Allocate_Any_Controlled): Likewise. Pass the maximum of the specified alignment and that of the header to the allocator. (Deallocate_Any_Controlled): Likewise to the deallocator.
2024-05-16ada: Implement per-finalization-collection spinlocksEric Botcazou2-16/+75
This changes the implementation of finalization collections from using the global task lock to using per-collection spinlocks. Spinlocks are a good fit in this context because they are very cheap and therefore can be taken with a fine granularity only around the portions of code implementing the shuffling of pointers required by attachment and detachment actions. gcc/ada/ * libgnat/s-finpri.ads (Lock_Type): New modular type. (Collection_Node): Add Enclosing_Collection component. (Finalization_Collection): Add Lock component. * libgnat/s-finpri.adb: Add clauses for System.Atomic_Primitives. (Attach_Object_To_Collection): Lock and unlock the collection. Save a pointer to the enclosing collection in the node. (Detach_Object_From_Collection): Lock and unlock the collection. (Finalize): Likewise. (Initialize): Initialize the lock. (Lock_Collection): New procedure. (Unlock_Collection): Likewise.
2024-05-14ada: Decouple attachment from dynamic allocation for controlled objectsEric Botcazou4-193/+153
This decouples the attachment to the appropriate finalization collection of dynamically allocated objects that need finalization from their allocation. The current implementation immediately attaches them after allocating them, which means that they will be finalized even if their initialization does not complete successfully. The new implementation instead generates the same sequence as the one generated for (statically) declared objects, that is to say, allocation, initialization and attachment in this order. gcc/ada/ * exp_ch3.adb (Build_Default_Initialization): Do not generate the protection for finalization collections. (Build_Heap_Or_Pool_Allocator): Set the No_Initialization flag on the declaration of the temporary. * exp_ch4.adb (Build_Aggregate_In_Place): Do not build an allocation procedure here. (Expand_Allocator_Expression): Build an allocation procedure, if it is required, only just before rewriting the allocator. (Expand_N_Allocator): Do not build an allocation procedure if the No_Initialization flag is set on the allocator, except for those generated for special return objects. In other cases, build an allocation procedure, if it is required, only before rewriting the allocator. * exp_ch7.ads (Make_Address_For_Finalize): New function declaration. * exp_ch7.adb (Finalization Management): Update description for dynamically allocated objects. (Make_Address_For_Finalize): Remove declaration. (Find_Last_Init): Change to function and move to... (Process_Object_Declaration): Adjust to above change. * exp_util.ads (Build_Allocate_Deallocate_Proc): Add Mark parameter with Empty default and document it. (Find_Last_Init): New function declaration. * exp_util.adb (Build_Allocate_Deallocate_Proc): Add Mark parameter with Empty default and pass it in recursive call. Deal with type conversions created for interface types. Adjust call sequence to Allocate_Any_Controlled by changing Collection to In/Out parameter and removing Finalize_Address parameter. For a controlled object, generate a conditional call to Attach_Object_To_Collection for an allocation and to Detach_Object_From_Collection for a deallocation. (Find_Last_Init): ...here. Compute the initialization type for an allocator whose designating type is class wide specifically and also handle concurrent types. * rtsfind.ads (RE_Id): Add RE_Attach_Object_To_Collection and RE_Detach_Object_From_Collection. (RE_Unit_Table): Add entries for RE_Attach_Object_To_Collection and RE_Detach_Object_From_Collection. * libgnat/s-finpri.ads (Finalization_Started): Delete. (Attach_Node_To_Collection): Likewise. (Detach_Node_From_Collection): Move to... (Attach_Object_To_Collection): New procedure declaration. (Detach_Object_From_Collection): Likewise. (Finalization_Collection): Remove Atomic for Finalization_Started. Add pragma Inline for Initialize. * libgnat/s-finpri.adb: Add clause for Ada.Unchecked_Conversion. (To_Collection_Node_Ptr): New instance of Ada.Unchecked_Conversion. (Detach_Node_From_Collection): ...here. (Attach_Object_To_Collection): New procedure. (Detach_Object_From_Collection): Likewise. (Finalization_Started): Delete. (Finalize): Replace allocation with attachment in comments. * libgnat/s-stposu.ads (Allocate_Any_Controlled): Rename parameter Context_Subpool into Named_Subpool, parameter Context_Collection into Collection and change it to In/Out, and remove Fin_Address. * libgnat/s-stposu.adb: Remove clause for Ada.Unchecked_Conversion and Finalization_Primitives. (To_Collection_Node_Ptr): Delete. (Allocate_Any_Controlled): Rename parameter Context_Subpool into Named_Subpool, parameter Context_Collection into Collection and change it to In/Out, and remove Fin_Address. Do not lock/unlock and do not attach the object, instead only displace its address. (Deallocate_Any_Controlled): Do not lock/unlock and do not detach the object. (Header_Size_With_Padding): Use qualified name for Header_Size.
2024-05-14ada: Correct System.Win32.LocalFileTimeToFileTime wrapper typoPhilippe Gil1-2/+2
The parameters should be swapped to fit Fileapi.h documentation. BOOL LocalFileTimeToFileTime( [in] const FILETIME *lpLocalFileTime, [out] LPFILETIME lpFileTime ); gcc/ada/ * libgnat/s-win32.ads (LocalFileTimeToFileTime): Swap parameters.
2024-05-13ada: Rename finalization scope masters into finalization mastersEric Botcazou2-9/+9
Now that what was previously called "finalization master" has been renamed into "finalization collection" in the front-end, we can also rename what was initially called "finalization scope master" into "finalization master". These entities indeed drive the finalization of all the objects that require it, directly for (statically) declared objects or indirectly for dynamically allocated objects (that is to say, through finalization collections). gcc/ada/ * exp_ch7.adb: Adjust the description of finalization management. (Build_Finalizer): Rename scope master into master throughout. * rtsfind.ads (RE_Id): Replace RE_Finalization_Scope_Master with RE_Finalization_Master. (RE_Unit_Table): Replace entry for RE_Finalization_Scope_Master with entry for RE_Finalization_Master. * libgnat/s-finpri.ads (Finalization_Scope_Master): Rename into... (Finalization_Master): ...this. (Attach_Object_To_Master): Adjust to above renaming. (Chain_Node_To_Master): Likewise. (Finalize_Master): Likewise. * libgnat/s-finpri.adb (Attach_Object_To_Master): Likewise. (Chain_Node_To_Master): Likewise. (Finalize_Master): Likewise.
2024-05-13ada: Remove dynamic frame in System.Image_D and document it in System.Image_FEric Botcazou6-8/+70
The former can easily be removed while the latter cannot. gcc/ada/ * libgnat/s-imaged.ads (System.Image_D): Add Uns formal parameter. * libgnat/s-imaged.adb: Add with clauses for System.Image_I, System.Value_I_Spec and System.Value_U_Spec. (Uns_Spec): New instance of System.Value_U_Spec. (Int_Spec): New instance of System.Value_I_Spec. (Image_I): New instance of System.Image_I. (Set_Image_Integer): New renaming. (Set_Image_Decimal): Replace 'Image with call to Set_Image_Integer. * libgnat/s-imde32.ads (Uns32): New subtype. (Impl): Pass Uns32 as second actual paramter to Image_D. * libgnat/s-imde64.ads (Uns64): New subtype. (Impl): Pass Uns64 as second actual paramter to Image_D. * libgnat/s-imde128.ads (Uns128): New subtype. (Impl): Pass Uns128 as second actual paramter to Image_D. * libgnat/s-imagef.adb (Set_Image_Fixed): Document bounds for the A, D and AF local constants.
2024-05-13ada: Couple of comment tweaks to latest changeEric Botcazou2-13/+16
This replaces a few remaining references to "master" by "collection" and makes a couple of additional tweaks in comments. gcc/ada/ * libgnat/s-finpri.adb (Finalize): Replace "master" by "collection" in comments and add a comment about the form of the loop. * libgnat/s-stposu.adb (Allocate_Any_Controlled): Tweak comment.
2024-05-13ada: Replace finalization masters with finalization collectionsEric Botcazou8-578/+369
This change replaces finalization masters with finalization collections in most cases, that is to say, when they implement a list of objects created by allocators of a given access type; indeed the moniker is overloaded in the front-end, e.g. Sem_Util.Is_Master determines if a node "constitutes a finalization master" but is not affected by the change. This is mostly a renaming at this stage, toward something more in keeping with the terminology used in the RM 7.6.1 clause and no functional changes: although it gets rid of the rest of the System.Finalization_Masters unit, the functionalities are reimplemented in the System.Finalization_Primitives unit in terms of collections with only minor adjustments. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Remove s-finmas$(objext). * einfo.ads (Anonymous_Masters): Rename into Anonymous_Collections. (Finalization_Master): Rename into Finalization_Collection. * gen_il-fields.ads (Opt_Field_Enum): Replace Anonymous_Masters with Anonymous_Collections; and Finalization_Master with Finalization_Collection. * gen_il-gen-gen_entities.adb (Access_Kind): Likewise. (E_Function): Likewise. (E_Procedure): Likewise. (E_Package): Likewise. (E_Subprogram_Body): Likewise. * exp_ch3.adb (Build_Heap_Or_Pool_Allocator): Adjust to renamings. (Freeze_Type): Likewise. (Stream_Operation_OK): Remove obsolete test. * exp_ch4.adb (Expand_Allocator_Expression): Adjust to renamings. (Expand_N_Allocator): Likewise. * exp_ch6.ads (BIP_Formal_Kind): Replace BIP_Finalization_Master with BIP_Collection. (Needs_BIP_Finalization_Master): Rename into... (Needs_BIP_Collection): ...this. * exp_ch6.adb (BIP_Finalization_Master_Suffix): Delete. (BIP_Collection_Suffix): New constant string. (Add_Finalization_Master_Actual_To_Build_In_Place_Call): Rename to (Add_Collection_Actual_To_Build_In_Place_Call): ...this and adjust. (BIP_Formal_Suffix): Replace BIP_Finalization_Master alternative with BIP_Collection alternative. (BIP_Suffix_Kind): Replace test on BIP_Finalization_Master_Suffix with test on BIP_Collection_Suffix. (Is_Build_In_Place_Entity): Likewise. (Make_Build_In_Place_Call_In_Allocator): Call Needs_BIP_Collection and Add_Collection_Actual_To_Build_In_Place_Call. (Make_Build_In_Place_Call_In_Anonymous_Context): Likewise. (Make_Build_In_Place_Call_In_Assignment): Likewise. (Make_Build_In_Place_Call_In_Object_Declaration): Likewise. (Needs_BIP_Finalization_Master): Rename into... (Needs_BIP_Collection): ...this. (Needs_BIP_Alloc_Form): Call Needs_BIP_Collection. * exp_ch7.ads (Build_Anonymous_Master): Rename into... (Build_Anonymous_Collection): ...this. (Build_Finalization_Master): Rename into... (Build_Finalization_Collection): ...this. * exp_ch7.adb (Allows_Finalization_Master): Rename into... (Allows_Finalization_Collection): ...this. (Build_BIP_Cleanup_Stmts): Adjust to renamings. (Build_Anonymous_Master): Rename into... (Build_Anonymous_Collection): ...this. Adjust to renamings. (Build_Finalization_Master): Rename into... (Build_Finalization_Collection): ...this. Adjust to renamings. (Build_Finalizer): Adjust comment to renamings. * exp_ch13.adb (Expand_N_Free_Statement): Adjust to renamings. * exp_util.adb (Build_Allocate_Deallocate_Proc): Likewise. (Requires_Cleanup_Actions): Adjust comment to renamings. * freeze.adb (Freeze_All): Likewise. * rtsfind.ads (RTU_Id): Remove System_Finalization_Masters. (RE_Id): Remove RE_Finalization_Master & RE_Finalization_Master_Ptr add RE_Finalization_Collection & RE_Finalization_Collection_Ptr. Adjust RE_Add_Offset_To_Address and RE_Finalization_Scope_Master. (RE_Unit_Table): Remove entries for RE_Finalization_Master & RE_Finalization_Master_Ptr, add ones for RE_Finalization_Collection & RE_Finalization_Collection_Ptr. Also adjust those of RE_Add_Offset_To_Address and RE_Finalization_Scope_Master. * sem_ch3.adb (Access_Type_Declaration): Adjust to renamings. * sem_ch6.adb (Create_Extra_Formals): Likewise. * sem_util.adb (Designated_Subtype_Mark): Likewise. * libgnat/s-finpri.ads: Add clauses for Ada.Finalization and System.Storage_Elements. (Finalization_Collection): New limited controlled type. (Finalization_Collection_Ptr): Likewise. (Initialize): New overriding procedure. (Finalize): Likewise. (Finalization_Started): Likewise. (Collection_Node): New type. (Collection_Node_Ptr): Likewise. (Attach_Node_To_Collection): New procedure. (Detach_Node_From_Collection): Likewise. (Header_Size): New function. (Add_Offset_To_Address): Likewise. * libgnat/s-finpri.adb (Add_Offset_To_Address): New function. (Attach_Node_To_Collection): New procedure. (Detach_Node_From_Collection): Likewise. (Finalization_Started): Likewise. (Finalize): New overriding procedure. (Header_Size): New function. (Initialize): New overriding procedure. * libgnat/s-spsufi.ads (Finalize_And_Deallocate): Adjust comment. * libgnat/s-spsufi.adb: Remove clause for Finalization_Masters and add clause for Finalization_Primitives. (Finalize_And_Deallocate): Finalize the Collection component. * libgnat/s-stposu.ads: Remove clause for Finalization_Masters and add clause for Finalization_Primitives. (Root_Subpool): Replace Master component with Collection. (Allocate_Any_Controlled): Replace Context_Master parameter with Context_Collection parameter. * libgnat/s-stposu.adb: Remove clauses for Finalization_Masters and add clauses for Finalization_Primitives. (Address_To_FM_Node_Ptr): Delete. (To_Collection_Node_Ptr): New instance of Ada.Unchecked_Conversion. (Adjust_Controlled_Dereference): Adjust comment to renamings. (Allocate_Any_Controlled): Replace Context_Master parameter with Context_Collection parameter. Adjust to renamings. (Deallocate_Any_Controlled): Adjust to renamings. (Print_Subpool): Likewise. * libgnat/s-finmas.ads: Delete. * libgnat/s-finmas.adb: Likewise.
2024-05-13ada: Remove deprecated VxWorks interrupt connection APIAshley Gay2-223/+1
The VxWorks 7 API to use hardware interrupts is the VxBus subsystem. GNAT API still provides bindings for the deprecated (VxWorks 6) routines. A direct consequence of this change is that Attach_Handler cannot be used anymore (the VxBus subsystem should be used instead). This patch removes all the functions that are not supported by VxWorks 7 anymore. To warn for the usage of Attach_Handler, it adds the 'Obsolescent' pragma to to this routine so the comiler will advise the user if this function is called directly or through a pragma. gcc/ada/ * Makefile.rtl: remove i-vxinco.* from the build * doc/gnat_rm/the_gnat_library.rst: Remove i-vxinco.ads from the units documentation. * impunit.adb: Remove i-vxinco from the list of available units in GNATstudio. * libgnarl/i-vxinco.adb: Remove. * libgnarl/i-vxinco.ads: Ditto. * libgnarl/s-interr__vxworks.adb: enrich comment * libgnarl/s-vxwext__kernel.ads: fix comment * libgnat/i-vxwork.ads: Remove deprecated interrupt connections API, as well as an example. * libgnat/i-vxwork__x86.ads: Ditto and add the paragma Obscolescent to Attach_Handler * gnat_rm.texi: Regenerate.
2024-05-13ada: Decouple finalization masters from storage poolsEric Botcazou2-52/+0
The coupling came from the build-in-place protocol but is now unnecessary because the storage pool reference is always passed along with the master reference in this protocol. No functional changes. gcc/ada/ * exp_ch3.adb (Build_Heap_Or_Pool_Allocator): Use the BIPstoragepool formal parameter to retrieve the pool in the presence of a master. * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Always pass a pool reference along with the master reference. (Make_Build_In_Place_Call_In_Object_Declaration): Likewise. * exp_ch7.adb (Build_BIP_Cleanup_Stmts): Use the BIPstoragepool formal parameter to retrieve the pool in the presence of a master. (Create_Anonymous_Master): Do not call Set_Base_Pool. (Build_Finalization_Master): Likewise. * rtsfind.ads (RE_Id): Remove RE_Base_Pool and RE_Set_Base_Pool. (RE_Unit_Table): Remove associated entries. * libgnat/s-finmas.ads: Remove clause for System.Storage_Pools. (Any_Storage_Pool_Ptr): Delete. (Finalization_Master): Remove Base_Pool component. (Base_Pool): Delete. (Set_Base_Pool): Likewise. * libgnat/s-finmas.adb (Base_Pool): Likewise. (Set_Base_Pool): Likewise. (Print_Master): Do not print Base_Pool.
2024-05-13ada: Simplify uses of readdir_gnat with object overlayPiotr Trojanek2-17/+5
Code cleanup; behavior is unaffected. gcc/ada/ * libgnat/a-direct.adb (Start_Search_Internal): Combine subtype and object declaration. * libgnat/g-dirope.adb (Read): Replace convoluted unchecked conversion with an overlay.
2024-05-13ada: Refactor GNAT.Directory_Operations.Read to minimise runtime checksPiotr Trojanek1-8/+8
Array assignments are likely more efficient than element-by-element copying; in particular, they avoid constraints checks in every iteration of a loop (when the runtime is compiled with checks enabled). A cleanup and improvement opportunity spotted while working on improved detection of uninitialised local scalar objects. gcc/ada/ * libgnat/g-dirope.adb (Read): Use null-excluding, access-to-constant type; replace element-by-element copy with array assignments.
2024-05-07ada: Fix bad interaction between homogeneous finalization master and BIP ↵Eric Botcazou3-300/+32
protocol Dynamically-allocated objects that require finalization are attached to a finalization master, which is of a (limited) controlled type declared in the System.Finalization_Masters unit. Now there are two kinds of them: homogeneous and heterogeneous; for the former, all the objects attached to the master share the same Finalize_Address primitive whereas, for the latter, they may have different Finalize_Address primitives. There is a problem in this scheme with the BIP protocol, because this protocol forwards the finalization master from callers to callees and it does so even if the result types are distinct, so it is possible for a homogeneous finalization master to end up containing objects with different Finalize_Address primitives; in that case, the object attached last wins and sets the common Finalize_Address, which is then used to finalize other objects with unpredictable outcome (and very loud valgrind report). Therefore, this change gets rid of homogeneous finalization masters and also streamlines the implementation of heterogeneous ones by storing the Finalize_Address primitive on a per object basis in the FM_Node record. gcc/ada/ * einfo.ads (Pending_Access_Types): Delete. * exp_ch3.adb (Freeze_Type.Process_Pending_Access_Types): Likewise. (Freeze_Type): Do not call Process_Pending_Access_Types. * exp_ch7.ads (Make_Set_Finalize_Address_Call): Delete. * exp_ch7.adb (Build_Finalization_Master.Add_Pending_Access_Type): Delete. (Build_Finalization_Master): Do not set Finalize_Address on the master or call Add_Pending_Access_Type. (Make_Set_Finalize_Address_Call): Delete. * gen_il-fields.ads (Opt_Field_Enum): Remove Pending_Access_Types. * gen_il-gen-gen_entities.adb (Type_Kind): Likewise. * rtsfind.ads (RE_Id): Remove RE_Set_Finalize_Address. (RE_Unit_Table): Likewise. * sem_ch3.adb (Analyze_Full_Type_Declaration): Do not deal with pending access types. * libgnat/s-finmas.ads (Attach_Unprotected): Add Finalize_Address second parameter. (Delete_Finalize_Address_Unprotected): Delete. (Finalize_Address): Likewise. (Finalize_Address_Unprotected): Likewise. (Is_Homogeneous): Likewise. (Set_Finalize_Address): Likewise. (Set_Finalize_Address_Unprotected): Likewise. (Set_Heterogeneous_Finalize_Address_Unprotected): Likewise. (Set_Is_Heterogeneous): Likewise. (FM_Node): Add Finalize_Address component. (Finalization_Master): Remove Is_Homogeneous and Finalize_Address components. * libgnat/s-finmas.adb: Remove with & use clauses for System.HTable. (Finalize_Address_Table): Delete. (Attach_Unprotected): Add Finalize_Address second parameter and save its value in the Finalize_Address field of the node. (Delete_Finalize_Address_Unprotected): Delete. (Finalize): Call Finalize_Address saved in the nodes. (Finalize_Address): Delete. (Finalize_Address_Unprotected): Likewise. (Hash): Likewise. (Is_Homogeneous): Likewise. (Print_Master): Adjust. (Set_Finalize_Address): Delete. (Set_Finalize_Address_Unprotected): Likewise. (Set_Heterogeneous_Finalize_Address_Unprotected): Likewise. (Set_Is_Heterogeneous): Likewise. * libgnat/s-stposu.adb (Finalize_Address_Table_In_Use): Likewise. (Allocate_Any_Controlled): Pass Fin_Address to Attach_Unprotected and remove obsolete processing. (Deallocate_Any_Controlled): Remove obsolete processing. (Set_Pool_Of_Subpool): Do not call Set_Is_Heterogeneous.
2024-05-07ada: Add Global contracts to Ada.Numerics.Generic_Elementary_FunctionsJoffrey Huguet1-46/+74
GNATprove raised warnings about unspecified Global contracts when using functions from an instance of Ada.Numerics.Generic_Elementary_Functions. This patch adds null Global contracts to all subprograms. gcc/ada/ * libgnat/a-ngelfu.ads (Sqrt): Add Global contracts. (Log): Likewise. (Exp): Likewise. ("**"): Likewise. (Sin): Likewise. (Cos): Likewise. (Tan): Likewise. (Cot): Likewise. (Arcsin): Likewise. (Arccos): Likewise. (Arctan): Likewise. (Arccot): Likewise. (Sinh): Likewise. (Cosh): Likewise. (Tanh): Likewise. (Coth): Likewise. (Arcsinh): Likewise. (Arccosh): Likewise. (Arctanh): Likewise. (Arccoth): Likewise.
2024-05-07ada: Fix crash on body postconditionBob Duff1-2/+0
This patch fixes a bug where the compiler could crash on a postcondition on a subprogram body (i.e. a body that "acts as spec"), if the postcondition contains 'Old attributes that use the Ada 2022 feature that allows certain conditionals (see RM-6.1.1). The main bug fix here is in exp_attr.adb to set Ins_Node properly in the Acts_As_Spec case. Otherwise, the initialization of the 'Old temp would occur before the declaration, which gigi does not like. gcc/ada/ * exp_attr.adb (Attribute_Old): The 'Old attribute we are processing here is in a postcondition, which cannot be inside the "Wrapped_Statements" of the subprogram with that postcondition. So remove the loop labeled "Climb the parent chain looking for subprogram _Wrapped_Statements". The only way this loop could find a Subp is if we are nested inside a subprogram that also has a postcondition, and in that case we would find the wrong (outer) one. In any case, Subp is set to Empty after the loop, so all subsequent tests for Present (Subp) are necessarily False; remove them and the corresponding code. Set Ins_Node unconditionally (to the right thing). Remove obsolete comments. * sem_util.adb (Determining_Expressions): Fix assertion; Pragma_Test_Case was missing. (Eligible_For_Conditional_Evaluation): Fix assert that could fail in case of errors. * libgnat/s-valspe.ads: Remove pragma Unevaluated_Use_Of_Old; there are no uses of 'Old in this package.
2024-05-07ada: Adapt proof of runtime unitsYannick Moy4-5/+24
Restore proof of runtime units after changes in SPARK. gcc/ada/ * libgnat/a-strsea.adb (Index): Add assertions. * libgnat/a-strsup.ads ("="): Remove useless precondition. * libgnat/s-aridou.adb (Prove_Rounding_Case): Add assertions. (Lemma_Shift_Right): Add call to lemma. * libgnat/s-arit32.adb (Prove_Rounding_Case): Add assertion. (Prove_ Signs): Add assertions. (Scaled_Divide32): Add assertions.
2024-05-07Update copyright years.Marc Poulhiès2-2/+2
2024-05-07ada: Fix LTO type mismatches in GNAT.Sockets.ThinEric Botcazou2-18/+170
The default implementation of GNAT.Sockets.Thin is mainly used on Linux and the socklen_t type used in various routines of the BSD sockets C API is a typedef for unsigned int there, so importing it as Interface.C.int will be flagged as a type mismatch during LTO compilation. gcc/ada/ * libgnat/g-socthi.ads (C_Bind): Turn into inline function. (C_Getpeername): Likewise. (C_Getsockname): Likewise. (C_Getsockopt): Likewise. (C_Setsockopt): Likewise. (Nonreentrant_Gethostbyaddr): Likewise. * libgnat/g-socthi.adb (Syscall_Accept): Adjust profile. (Syscall_Connect): Likewise. (Syscall_Recvfrom): Likewise. (Syscall_Sendto): Likewise. (C_Bind): New function. (C_Accept): Adjust to above change for profiles. (C_Connect): Likewise. (C_Getpeername): New function. (C_Getsockname): Likewise. (C_Getsockopt): Likewise. (C_Recvfrom): Adjust to above change for profiles. (C_Setsockopt): New function. (Nonreentrant_Gethostbyaddr): Likewise.
2024-05-06ada: Make a couple of comment tweaksEric Botcazou1-5/+4
This removes a reference to a mechanism that didn't make it into the final implementation and completes the description of another. gcc/ada/ * libgnat/s-finpri.ads (Finalize_Master): Remove obsolete reference in the description. (Finalize_Object): Document the effects of repeated calls.
2024-05-06ada: Rework processing of special objects needing finalizationEric Botcazou2-16/+28
This reworks the processing of special objects needing finalization in the new implementation. These special objects, i.e. return object in extended return statements and transient objects, cannot be automatically handled by the post-processing phase because they have additional requirements, either conditional finalization for the former or immediate finalization for the latter and, therefore, a specific processing during expansion is needed for them before the post-processing phase can complete the work. The previous scheme used to do minimal processing during expansion, leaving the bulk of the work to the post-processing phase. Unfortunately this scheme turned out not to be stable for Expression_With_Actions nodes under copying by means of New_Copy_Tree or equivalent devices. The new scheme moves a bit more processing to the expansion, namely the generation of the attachment to the master node, whose result can then be naturally copied by New_Copy_Tree. A side effect is to further simplify the implementation of Build_Finalizer in Exp_Ch7, which has one fewer special case to deal with. gcc/ada/ * einfo.ads (Finalization_Master_Node_Or_Object): Rename into... (Finalization_Master_Node): ...this and adjust description. * exp_ch4.adb (Process_Transient_In_Expression): Attach the object to its master node here. * exp_ch7.ads (Attach_Object_To_Master_Node): New declaration. * exp_ch7.adb (Attach_Object_To_Master_Node): New procedure. (Build_Finalizer.Process_Declarations): Examine the type of a variable to spot master nodes. (Build_Finalizer.Process_Object_Declaration): Look only at the object and deal specifically with the case of a master node. (Build_Finalizer.Build_BIP_Cleanup_Stmts): Move to child function of Attach_Object_To_Master_Node. (Build_Finalizer.Make_Address_For_Finalize): Move to... (Insert_Actions_In_Scope_Around.Process_Transient_In_Scope): Attach the object to its master node here. (Make_Address_For_Finalize): ...here. (Make_Master_Node_Declaration): Adjust to above renaming and set Finalization_Master_Node only on the object. (Make_Suppress_Object_Finalize_Call): Adjust to above renaming and attach the object to its master node here. * exp_util.adb (Requires_Cleanup_Actions): Examine the type of a variable to spot master nodes. * gen_il-fields.ads (Opt_Field_Enum): Adjust to above renaming. * gen_il-gen-gen_entities.adb (Allocatable_Kind): Likewise. * rtsfind.ads (RE_Id): Add RE_Chain_Node_To_Master. (RE_Unit_Table): Add entry for RE_Chain_Node_To_Master. * libgnat/s-finpri.ads (Chain_Node_To_Master): New declaration. * libgnat/s-finpri.adb (Chain_Node_To_Master): New procedure. (Attach_Object_To_Master): Call it. (Finalize_Master): Do not raise Program_Error on null addresses. (Finalize_Object): Add assertion that the address is not null.
2024-05-06ada: Partial implementation of redesign of support for object finalizationEric Botcazou2-0/+307
This set of changes is a partial reimplemention of the support for Ada finalization in the GNAT compiler and run-time library, based on the redesign done by Hristian Kirtchev in February 2022. It only affects the scope-based finalization of objects and does not touch the support for finalization of dynamically allocated objects. It also does not modify the internal architecture of this support in the front-end but only changes its output, i.e. the expanded code. In other words, the code-based dispatching scheme in finalizers and the hook-based approach for transient objects are replaced by finalization scope masters and master nodes, which maintain a list of objects needing finalization, but the expansion of the code that builds these masters is still performed mainly during a dedicated post-processing phase. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-finpri$(objext). * contracts.adb (Add_Call_Helper): Append freeze actions to the class-wide type rather than the specific tagged type. * einfo.ads (Finalization_Master_Node_Or_Node): Document. (Status_Flag_Or_Transient_Decl): Remove. * exp_attr.adb (Expand_N_Attribute_Reference) <Address>: Do not adjust a return object of a class-wide interface type. * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Add test that Finalize_Address is not already present as a condition for calling Make_Finalize_Address_Body. (Expand_Freeze_Record_Type): Call Make_Finalize_Address_Body for class-wide types of both regular tagged types and interface types. * exp_ch4.adb (Process_Transients_In_Expression): Replace the use of hooks with the use of master nodes. * exp_ch6.adb (Build_Flag_For_Function): Delete. (Expand_N_Extended_Return_Statement): Create a master node for the return object if it does not exist. At the end of the statement, generate a call to Suppress_Object_Finalize. (Expand_Non_Function_Return): Likewise just before the return. * exp_ch7.ads (Make_Master_Node_Declaration): Declare. (Make_Suppress_Object_Finalize_Call): Likewise. * exp_ch7.adb (Build_Finalization_Master): Defer generating the call to Set_Finalize_Address until freezing if the Finalize_Address procedure has not been analyzed yet. (Build_Finalizer): Reimplement the expansion using a finalization scope master per finalizer. (Insert_Actions_In_Scope_Around): Replace finalization hooks by master nodes and calls to the Finalize_Object. (Make_Master_Node_Declaration): New procedure. (Make_Suppress_Object_Finalize_Call): Likewise. * exp_util.ads (Build_Transient_Object_Statements): Delete. * exp_util.adb (Build_Transient_Object_Statements): Likewise. (Requires_Cleanup_Actions): Remove obsolete code and return true for master nodes. * gen_il-fields.ads (Opt_Field_Enum): Add Finalization_Master_Node_Or_Object and remove Status_Flag_Or_Transient_Decl. * gen_il-gen-gen_entities.adb (Allocatable_Kind): Likewise. * rtsfind.ads (RTU_Id): Add System_Finalization_Primitives. (RE_Id): Add entities of System_Finalization_Primitives. (RE_Unit_Table): Add entries for them. * sem_ch3.adb (Analyze_Object_Declaration): For an array whose type has an unconstrained first subtype and a controlled component, set the Is_Constr_Array_Subt_With_Bounds flag. * libgnat/s-finpri.ads: New file. * libgnat/s-finpri.adb: Likewise.
2024-01-22Update copyright years.Marc Poulhiès1475-1475/+1475
2024-01-09ada: Remove unused runtime entityEric Botcazou2-18/+0
The compiler has not generated direct attachments for a long time. gcc/ada/ * rtsfind.ads (RE_Id): Remove RE_Attach. (RE_Unit_Table): Likewise. * libgnat/s-finmas.ads (Attach): Delete. * libgnat/s-finmas.adb (Attach): Likewise.
2024-01-09ada: Add __atomic_store_n binding to System.Atomic_PrimitivesEric Botcazou2-0/+25
This is modeled on the existing binding for __atomic_load_n. gcc/ada/ * libgnat/s-atopri.ads (Atomic_Store): New generic procedure. (Atomic_Store_8): New instantiated procedure. (Atomic_Store_16): Likewise. (Atomic_Store_32): Likewise. (Atomic_Store_64): Likewise. * libgnat/s-atopri__32.ads (Atomic_Store): New generic procedure. (Atomic_Store_8): New instantiated procedure. (Atomic_Store_16): Likewise. (Atomic_Store_32): Likewise. * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Implement the support for __atomic_store_n and __sync_bool_compare_and_swap_n. * gcc-interface/gigi.h (list_second): New inline function.
2024-01-09ada: Fix precondition in Interfaces.C.StringsJoffrey Huguet1-4/+5
The precondition of both Update procedures in Interfaces.C.Strings were incorrect. This patch fixes this. gcc/ada/ * libgnat/i-cstrin.ads (Update): Fix precondition.