aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2025-06-06ada: Add new aspect Program_Exit for SPARKPiotr Trojanek22-753/+1097
A new aspect Program_Exit is added for SPARK to specify that a subprogram can exit the entire program, e.g. GNAT.System.OS_Exit. The implementation is based on the existing machinery for similar aspects, in particular, for aspects Subprogram_Variant and Always_Terminates. gcc/ada/ChangeLog: * aspects.ads (Aspect_Id): Add new aspect identifier. (Aspect_Argument): Specify argument for the new aspect. (Is_Representation_Aspect): New aspect is not a representation aspect. (Aspect_Names): Map new aspect to name. (Aspect_Delay): New aspect is always delayed. * contracts.adb (Expand_Subprogram_Contract) (Add_Pre_Post_Condition, Add_Contract_Item) (Analyze_Entry_Or_Subprogram_Contract) (Analyze_Entry_Or_Subprogram_Body_Contract) (Analyze_Subprogram_Body_Stub_Contract): Support new aspect. * contracts.ads (Add_Contract_Item, Analyze_Entry_Or_Subprogram_Contract, Analyze_Entry_Or_Subprogram_Body_Contract, Analyze_Subprogram_Body_Stub_Contract): Mention new contract in comment. * doc/gnat_rm/implementation_defined_aspects.rst (Aspect Program_Exit): Document new aspect. * doc/gnat_rm/implementation_defined_pragmas.rst (Pragma Program_Exit): Document new pragma. * einfo-utils.adb (Get_Pragma): Support new pragma. * einfo-utils.ads (Get_Pragma): Mention new pragma in comment. * exp_prag.adb (Expand_Pragma_Program_Exit): Expand new pragma; body. * exp_prag.ads (Expand_Pragma_Program_Exit): Expand new pragma; spec. * inline.adb (Remove_Aspects_And_Pragmas): Support new pragma. * par-prag.adb (Prag): Support new pragma. * sem_attr.adb (Analyze_Attribute_Old_Result): Accept attribute Old in new pragma. * sem_ch12.adb (Implementation of Generic Contracts): Mention new aspect in comment. * sem_ch13.adb (Insert_Pragma, Analyze_Aspect_Specifications): Convert new new aspect to pragma. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Renumber subsequent rule in comment. * sem_prag.adb (Check_Postcondition_Use_In_Inlined_Subprogram) (Contract_Freeze_Error): Mention new pragma in comment. (Analyze_Pragma): Support new pragma; renumber subsequent rule in comment. (Analyze_Program_Exit_In_Decl_Part): Analyze new pragma; body. (Sig_Flags): References in new pragma are significant when detecting unreferenced objects. * sem_prag.ads (Aspect_Specifying_Pragma) (Assertion_Expression_Pragma, Pragma_Significant_To_Subprograms): Support new aspect and pragma. (Analyze_Program_Exit_In_Decl_Part): Analyze new pragma; spec. (Find_Related_Package_Or_Body): Mention new pragma in comment. * sem_util.adb (Is_Subprogram_Contract_Annotation): Support new pragma. * sem_util.ads (Is_Subprogram_Contract_Annotation): Mention new pragma in comment. * sinfo.ads (Is_Generic_Contract_Pragma): Mention new pragma in comment. * snames.ads-tmpl (Preset Names, Pragma_Id): Add name and pragma identifiers. * gnat_rm.texi: Regenerate.
2025-06-06ada: Deconstruct C header for the SCOs unitPiotr Trojanek3-94/+3
The C version of SCOs unit provided a gigi interface to source code obligations that at some point were generated by the frontend. This functionality has been deconstructed long ago. gcc/ada/ChangeLog: * libgnat/g-dyntab.ads (Instance): Update and extend comment. * scos.ads: Remove comment about the corresponding C header. * scos.h: Remove.
2025-06-06ada: Child unit subprograms are not primitive subprogramsSteve Baird1-0/+1
If a package declares a type and a child unit of that package is a subprogram with a parameter (or function result) of that type, then that subprogram is not a primitive subprogram of that type. Previously this was handled incorrectly in some cases, leading to incorrect analysis of overriding indicators. gcc/ada/ChangeLog: * sem_util.adb (Collect_Primitive_Operations): When collecting primitive operations, do not include child unit subprograms.
2025-06-06ada: Constant_Indexing used when context requires a variableJavier Miranda1-219/+667
In the case of an assignment where the type of its left hand side is an indexable container that has indexable container components (for example a container vector of container vectors), and both indexable containers have Constant_Indexing and Variable_Indexing aspects, the left hand side of the assignment is erroneously interpreted as constant indexing. The error results in spurious compile-time error messages saying that the left hand side of the assignment must be a variable. gcc/ada/ChangeLog: * sem_ch4.adb (Constant_Indexing_OK): Add missing support for RM 4.1.6(13/3), and improve performance to avoid climbing more than needed. Add documentation. (Try_Indexing_Function): New subprogram. (Expr_Matches_In_Formal): Added new formals. (Handle_Selected_Component): New subprogram. (Has_IN_Mode): New subprogram. (Try_Container_Indexing): Add documentation, code reorganization and extend its functionality to improve its support for prefixed notation calls.
2025-06-06ada: Refactor the implementation of gnat diagnosticsViljar Indus35-4011/+1969
The goal of this patch is to remove the implementation from the Diagnostic objects and port the new features over to the Error_Msg_Objects. gcc/ada/ChangeLog: * debug.adb: Mark -gnatd_D as unused. * diagnostics-repository.adb: Move to... * errid.adb: ...here. * diagnostics-repository.ads: Move to... * errid.ads: ...here. * errout.adb (Error_Msg_Internal): Add new arguments for the new attributes of Error_Msg_Objects. (Error_Msg): Likewise. (Error_Msg_N): Likewise. (Labeled_Span): New method for creating Labeled_Span-s (Primary_Label_Span): New method for creating primary Labeled_Spans. (Secondary_Labeled_Span): New method for creating secondary Labeled_Spans. (Edit): New method for creating Edit elements. (Fix): New method for creating Fix elements. (Error_Msg_F): Simplify code for evaluating the span. (Error_Msg_FE): Likewise. (Error_Msg_NE): Likewise. (Error_Msg_NEL): Likewise. (Error_Msg_N_Gigi): New method that is used as a wrapper for the Error_Msg_xxx methods that have the new arguments. This function is later mapped to the Error_Msg method used inside gigi. (Error_Msg_NE_Gigi): Likewise. (Write_JSON_Span): Ensure that the Style prefix is included that is removed when parsing the message is reinserted to the JSON report. (Output_Messages): Use the new Pretty_Printer and Sarif_Printer packages to print the messages and remove the old implementation for the pretty printer. (Set_Msg_Text): Remove message kind insertion characters from the final message text to avoid some message kinds being duplicated. (To_Full_Span_First): New method for creating a span for a node. (To_Full_Span): Likewise. * errout.ads: Add the specs for all of the newly added functions. * diagnostics-pretty_emitter.adb: Move to... * erroutc-pretty_emitter.adb: ...here. * diagnostics-pretty_emitter.ads: Move to... * erroutc-pretty_emitter.ads: ...here. * diagnostics-sarif_emitter.adb: Move to... * erroutc-sarif_emitter.adb: ...here. * diagnostics-sarif_emitter.ads: Move to... * erroutc-sarif_emitter.ads: ...here. * erroutc.adb (Next_Error_Msg): New method for iterating to the next error message. (Next_Continuation_Msg): New method for iterating to the next continuation message. (Primary_Location): New method for returning the first primary location for the error message. (Get_Human_Id): New method for returning the human readable name for the switch associated with this error message. (Get_Doc_Switch): New method for creating the tag for the switch used in the error message. (Output_Text_Within): Change the method to operating on Strings instead of String pointers. (Output_Msg_Text): Simplify implementation for generating the error message. (Prescan_Message): Make the String handling more error proof. * erroutc.ads (Error_Msg_Object): Add new attributes that were added to Diagnostic objects to Error_Msg_Objects. Add new methods for handling the new error objects. * diagnostics-switch_repository.adb: Move to... * errsw.adb: ...here. * errutil.adb (Error_Msg): Initialize all of the new attributes added to Error_Msg_Object-s. * fe.h (Error_Msg_N): Update the binding. (Error_Msg_NE): Update the binding. For now the error_msg methods in gigi will use the old simplified interface for those methods. * diagnostics-json_utils.adb: Move to... * json_utils.adb: ...here. * diagnostics-json_utils.ads: Move to... * json_utils.ads: ...here. * par-endh.adb: Replace the old error_msg calls with the updated interface. * sem_aggr.adb: Likewise. * sem_ch13.adb: Likewise. * sem_ch4.adb: Likewise. * sem_ch9.adb: Likewise. * diagnostics-brief_emitter.adb: Removed. * diagnostics-brief_emitter.ads: Removed. * diagnostics-constructors.adb: Removed. * diagnostics-constructors.ads: Removed. * diagnostics-converter.adb: Removed. * diagnostics-converter.ads: Removed. * diagnostics-switch_repository.ads: Removed. * diagnostics-utils.adb: Removed. * diagnostics-utils.ads: Removed. * diagnostics.adb: Removed. * diagnostics.ads: Removed. * errsw.ads: New file. Based on diagnostics-switch_repository.ads. It additionally contains all the switch enumerations. * gcc-interface/Make-lang.in: Update compilation dependencies. * gcc-interface/Makefile.in: Likewise.
2025-06-06ada: Set Ekind early for entities created in expansionRonan Desplanques5-0/+19
This patch adds early Ekind assignments to entities created for the expansion of a few constructs. The only effect is to enable more dynamic checks for the uses of those entities that used to happen before the Ekind had been set. gcc/ada/ChangeLog: * contracts.adb (Add_Invariant_And_Predicate_Checks): Assign Ekind. * inline.adb (Expand_Inlined_Call): Likewise. * exp_ch9.adb (Build_Simple_Entry_Call): Likewise. * exp_dist.adb (Append_Array_Traversal): Likewise. * exp_fixd.adb (Build_Double_Divide_Code, Build_Scaled_Divide_Code): Likewise.
2025-06-06ada: Rework Android struct sigaction bindingsOlivier Hainque3-38/+40
A previous change arranged for the common definition of struct_sigaction in s-osinte__android.ads to work both for ARM and aarch64 by way of representation clauses with field offsets taken from specialized versions of s-linux (one for ARM, one for aarch64). The aarch64 variant had the offsets wrong, placing the sa_handler pointer at offset 4, following the sa_flags int at offset 0. The pointer is 8 bytes wide so should be placed at an offset multiple of 8. This caused a discrepancy between the Ada runtime actions and the expectations of the underlying libc functions called. This change refactors the struct_sigaction definition to instanciate an entire type provided by s-linux instead, parametrized by sigset_t which needs to remain provided by the common System.OS_Interface spec. gcc/ada/ChangeLog: * libgnarl/s-linux__android-aarch64.ads: Provide an Android_Sigaction generic package to expose an aarch64 version of struct_sigation, using a provided sigset_t for sa_flags. * libgnarl/s-linux__android-arm.ads: Likewise, for ARM rather than aarch64. * libgnarl/s-osinte__android.ads: Move sigset_t definition to the visible part and use it to instantiate the Android_Sigation generic provided by System.Linux, which is specialized for ARM vs aarch64. Define struct_sigaction out of the Android_Sigaction instance, remove the local representation clauses.
2025-06-06ada: Adjust the Android RTS config to match linuxOlivier Hainque4-12/+79
Android has many traits of Linux, reflected by the gcc port triplets composition (<cpu>-android-linux). The Android Ada RTS was so far configured as a mostly "posix" port, which happens to be very little tested, if at all. This change reworks the Android Ada RTS to map a lot more closely to that of a regular Linux target, a natural fit and much more toroughly exercized. This expects support of pthread rwlocks in the bionic libc, which is there in the not-so-old-but-not-so-recent versions we tested (Android 11 at least). gcc/ada/ChangeLog: * Makefile.rtl: Rework the Android pairs to match those of a regular Linux port rather than a generic posix one. * libgnarl/s-osinte__android.ads: Import pcrtl and add bindings for the pthread_rwlock entry points, used by the Linux units now in the libgnat target pairs. * sysdep.c (__gnat_has_cap_sys_nice): Define for Android, conservative return 0. * adaint.c (__gnat_cpu_alloc): Define for Android as for Linux.
2025-06-06ada: Document representation clauses previously required by ASISPiotr Trojanek1-1/+3
A record type used for name identifiers had representation clause to make sure that table with identifiers is written to an ASIS file without holes. Now ASIS mode has been deconstructed, but we still want this representation clause to ensure efficient implementation. Comment update; behavior is unaffected. gcc/ada/ChangeLog: * namet.ads (Name_Entry): Update comments to explain the current needs.
2025-06-06ada: Deconstruct representation clauses required by ASISPiotr Trojanek7-137/+3
When GNAT was operating in ASIS mode, it was writing internal tables to files, so we annotated record types for elements stored in these tables with representation clauses to avoid holes with potentially uninitialized data. Since ASIS mode has been now deconstructed and we no longer write internal tables to files, we can remove explicit representation clauses and rely on the data layout chosen by the compiler. Code cleanup; behavior is unaffected. gcc/ada/ChangeLog: * lib.ads (Unit_Record): Remove representation clauses and filler components * lib-load.adb, lib-writ.adb: Remove initialization of data fillers. * nlists.adb (Allocate_List_Tables): Remove explicit initialization. * repinfo.adb (Exp_Node): Remove representation clauses. * sinput.ads (Source_File_Record): Likewise. * urealp.adb (Ureal_Entry): Likewise.
2025-06-06ada: Fix typo in documentation about convention and representationPiotr Trojanek3-3/+3
Currently there are only three exceptions to the general rule; the fourth exception applied to OpenVMS, whose support has been deconstructed. gcc/ada/ChangeLog: * doc/gnat_rm/representation_clauses_and_pragmas.rst (Effect of Convention on Representation): Fix number of list items. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2025-06-06ada: Fix libgpr2 build failure with compiler built with assertionsEric Botcazou1-0/+2
The problem is that the Entity field is accessed for a node without one. gcc/ada/ChangeLog: * sem_ch10.adb (Install_Siblings.In_Context): Add missing guard.
2025-06-06ada: Tweak condition for name resolution failureRonan Desplanques1-2/+3
It is sometimes used as a convention across GNAT's code to set the Etype field of a node to Any_Type to signal a name resolution error. This has the potential to be confusing, which is why this patch replaces one such use of the convention by a less convoluted check. This only affects error recovery paths, and possibly doesn't change the behavior of the compiler at all. gcc/ada/ChangeLog: * sem_ch4.adb (Analyze_Selected_Component): Tweak condition.
2025-06-06ada: Fix wrong initialization of library-level object by conditional expressionEric Botcazou1-1/+8
At library level the object must be allocated statically and with its bounds when its nominal subtype is an unconstrained array type. gcc/ada/ChangeLog: * exp_ch4.adb (Insert_Conditional_Object_Declaration): Make sure the object is allocated properly by the code generator at library level.
2025-06-06ada: Convert floating-point zero to machine representationPiotr Trojanek1-5/+3
When statically evaluating floating-point expressions we convert the final result to machine number. However, we skipped this conversion if the result was zero. This inconsistency was introduced when adding a warning for compile-time evaluation that gives different result from a run-time evaluation, but left when this warning was deconstructed. It causes a crash in GNATprove, which expects all floating-point numbers in the GNAT AST to be in a machine representation form. gcc/ada/ChangeLog: * sem_eval.adb (Check_Non_Static_Context): Remove special handling of floating-point zero.
2025-06-06ada: Move Incomplete_View from node to entity fieldPiotr Trojanek9-22/+16
The Incomplete_View property of a type was attached to its full type declaration as a semantic field, but retrieving it from there required low-level tree navigation and caused code duplication. In one case we relied on internal class-wide type being attached to the corresponding full type declaration, which is an undocumented assumption. It seems better to attach this field to entities, just like we do with Full_View and many other type properties. Ideally, this field should be present just in type entities, but currently we set it before setting the proper entity kind. Behavior is unaffected. This is rather a code cleanup, originating from the need to use Incomplete_View in GNATprove. gcc/ada/ChangeLog: * einfo.ads (Incomplete_View): Move from Sinfo; adapt wording. * exp_ch3.adb (Build_Record_Init_Proc): Adapt retrieval of Incomplete_View. * gen_il-fields.ads (Opt_Field_Enum): Move Incomplete_View from node to entity field. * gen_il-gen-gen_entities.adb (Gen_Entities): Add field. * gen_il-gen-gen_nodes.adb (Gen_Nodes): Remove field. * sem_ch3.adb (Analyze_Full_Type_Declaration, Check_Anonymous_Access_Component): Adapt setting of Incomplete_View. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Adapt retrieval of Incomplete_View for class-wide types; no longer rely on class-wide type being attached to non-classwide type declaration. * sem_util.adb (Collect_Primitive_Operations): Adapt retrieval of Incomplete_View. * sinfo.ads (Incomplete_View): Move to Einfo.
2025-06-06ada: Initial prototype of constructorssquirek21-49/+805
The patch implements the experimental constructors RFC. Currently a WIP. gcc/ada/ChangeLog: * aspects.ads: Add support for constructors. * exp_aggr.adb: Likewise. * exp_attr.adb: Likewise. * exp_ch3.adb: Likewise. * exp_ch4.adb: Likewise. * exp_util.adb: Likewise. * gen_il-fields.ads: Likewise. * gen_il-gen-gen_entities.adb: Likewise. * gen_il-gen-gen_nodes.adb: Likewise. * par-ch4.adb: Likewise. * sem_aggr.adb: Likewise. * sem_attr.adb, sem_attr.ads: Likewise. * sem_ch13.adb: Likewise. * sem_ch3.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch6.adb: Likewise. * sem_res.adb: Likewise. * sem_util.adb, sem_util.ads: Likewise. * snames.ads-tmpl: Likewise.
2025-06-06ada: Implement use implies with experimental extensionsquirek2-57/+92
The patch implements the experimental feature to allow use package clauses within the context area to imply with. gcc/ada/ChangeLog: * doc/gnat_rm/gnat_language_extensions.rst: Add documentation. * gnat_rm.texi: Regenerate.
2025-06-06ada: Tweak definition of Modulus field of entitiesEric Botcazou2-2/+2
The compiler may build modular integer subtypes whose base type is private in the context of instantiations, but we want to be able to get the Modulus. gcc/ada/ChangeLog: * einfo.ads (Modulus): Change to implementation base type only. * gen_il-gen-gen_entities.adb (Modular_Integer_Kind): Change type of Modulus field to Impl_Base_Type_Only.
2025-06-06ada: Restore Original_Access_Type field in E_Access_Subprogram_Type entitiesEric Botcazou4-1/+16
It is used by CodePeer to recognize the special access pattern. gcc/ada/ChangeLog: * einfo.ads (Original_Access_Type): Restore. * gen_il-fields.ads (Opt_Field_Enum): Restore Original_Access_Type. * gen_il-gen-gen_entities.adb: Adjust accordingly. * exp_ch9.adb (Expand_Access_Protected_Subprogram_Type): Restore the call to Set_Original_Access_Type.
2025-06-06ada: Remove more unused fields from entitiesEric Botcazou9-105/+2
This removes 5 more unused fields from entities, as well as 1 flag. gcc/ada/ChangeLog: * einfo.ads (Default_Expr_Function): Delete. (Dependent_Instances): Likewise. (Handler_Records): Likewise. (Needs_Activation_Record): Likewise. (Original_Access_Type): Likewise. (Register_Exception_Call): Likewise. * sinfo.ads (Accept_Handler_Records): Likewise. * gen_il-fields.ads (Opt_Field_Enum): Remove Accept_Handler_Records, Default_Expr_Function, Dependent_Instances, Handler_Records, Needs_Activation_Record, Original_Access_Type and Register_Exception_Call. * gen_il-gen-gen_entities.adb: Adjust accordingly. * gen_il-gen-gen_nodes.adb: Likewise. * exp_ch9.adb (Expand_Access_Protected_Subprogram_Type): Remove call to Set_Original_Access_Type. (Expand_N_Selective_Accept): Remove call to Set_Handler_Records. * exp_ch11.adb (Expand_N_Exception_Declaration): Remove call to Set_Register_Exception_Call. * sem_ch3.adb (Access_Subprogram_Declaration): Remove call to Set_Needs_Activation_Record. * sem_ch12.adb (Instantiate_Package_Body): Remove call to Set_Handler_Records.
2025-06-06ada: Incorrect unresolved operator name in an instantiationSteve Baird1-23/+2
In some cases, a generic containing a use of a unary operator successfully compiles but the compiler incorrectly rejects the corresponding use in an instantiation. gcc/ada/ChangeLog: * sem_ch4.adb (Find_Unary_Types): Because we reanalyze names in an instance, we sometimes have to take steps to filter out extraneous name resolution candidates that happen to be visible at the point of the instance declaration. Remove some code that appears to have been written with this in mind. This is done for two reasons. First, the code sometimes doesn't work (possibly because the In_Instance test is not specific enough - it probably should be testing to see whether we are in an instance of the particular generic in which the result of calling Corresponding_Generic_Type was declared) and causes correct code to be rejected. Second, the code seems to no longer be necessary (possibly because of subsequent fixes in this area which are not specific to unary operators).
2025-06-06ada: Remove dead codeRonan Desplanques1-20/+0
The code this patch removes is never executed on any of the available test suites. The patch that introduced it mentions that it fixes a test in particular, but that test passes anyway today. gcc/ada/ChangeLog: * sem_ch8.adb (Premature_Usage): Remove dead code.
2025-06-06ada: Remove Size_Check_Code field from entitiesEric Botcazou7-37/+0
It has been unused for a very long time. gcc/ada/ChangeLog: * einfo.ads (Size_Check_Code): Delete. * gen_il-fields.ads (Opt_Field_Enum): Remove Size_Check_Code. * gen_il-gen-gen_entities.adb (Constant_Or_Variable_Kind): Likewise. * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Remove call to Kill_Size_Check_Code. * sem_prag.adb (Analyze_Pragma): Likewise. * sem_util.ads (Kill_Size_Check_Code): Delete. * sem_util.adb (Kill_Size_Check_Code): Likewise.
2025-06-06ada: Allow IN OUT parameters for first parameter of traversal functionsClaire Dross1-0/+17
In general, functions in SPARK cannot have parameters of mode IN OUT unless they are annotated with the Side_Effects aspect. Borrowing traversal functions are special functions which can return a part of their first parameter as an access-to-variable type. This might not be allowed in Ada if the parameter is a constant. Allow the first parameter of borrowing traversal functions to have mode IN OUT. gcc/ada/ChangeLog: * sem_ch6.adb (Analyze_SPARK_Subprogram_Specification): Allow the first parameter of functions whose return type is an anonymous access-to-variable type to have mode IN OUT.
2025-06-06ada: Improve large unconstrained-but-definite warningRonan Desplanques5-14/+18
Before this patch, Check_Discriminant_Use called Is_Limited type on entities before they were fully analyzed. That caused Is_Limited_Type to incorrectly return False for records that are limited because they have a limited component. This patch pushes back the emissions of the Check_Discriminant_Use warning after analysis of record declarations. A new field to E_Record_Type entity is added to take relevant discriminant uses into account. gcc/ada/ChangeLog: * gen_il-fields.ads: New field. * gen_il-gen-gen_entities.adb: New field. * einfo.ads: Document new field. * sem_res.adb (Check_Discriminant_Use): Record relevant uses in new field. Move warning emission to... * sem_ch3.adb (Analyze_Full_Type_Declaration): ... Here.
2025-06-06ada: Do not generate warning about missing overriding indicatorSteve Baird1-15/+5
We were previously generating a warning about a missing overriding indicator in some cases when a dispatching subprogram is declared. In at least some (and perhaps all) cases where this warning was generated, it was incorrect. It was also generated very infrequently. The simple solution is to stop generating the warning. gcc/ada/ChangeLog: * sem_disp.adb (Check_Dispatching_Operation): Delete code to generate "missing overriding indicator" warning. Update comments.
2025-06-06ada: Move standard subtype declarations generationRonan Desplanques1-15/+20
Before this patch, the subtype declarations for Standard.Natural and Standard.Positive were created before the entity for Standard.Integer was complete. In preparation of a future change that will make it impossible to call Etype on an incomplete node, this patch delays the creation of these subtype declarations. It doesn't affect the behavior of the compiler. gcc/ada/ChangeLog: * cstand.adb (Create_Standard): Delay declaration generation for Natural and Positive.
2025-06-06ada: Remove useless callsRonan Desplanques1-2/+0
The subprogram calls this patch removes were useless because they were already made in New_Standard_Entity. gcc/ada/ChangeLog: * cstand.adb (Create_Standard): Remove useless calls.
2025-06-06ada: Fix internal error on allocator involving interface typeEric Botcazou5-33/+51
The problem is that an itype duplicated through Duplicate_Subexpr_No_Checks ends up in a different scope than its source. It is fixed by adding a new formal parameter New_Scope to the function and forwarding it in the call to the New_Copy_Tree function. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Record_Aggregate): Use the named form for the second actual parameter in the call to Duplicate_Subexpr. * exp_attr.adb (Expand_Size_Attribute): Likewise. * exp_ch5.adb (Expand_Assign_Array): Likewise. (Expand_Assign_Array_Bitfield): Likewise. (Expand_Assign_Array_Bitfield_Fast): Likewise. * exp_util.ads (Duplicate_Subexpr): Add New_Scope formal parameter. (Duplicate_Subexpr_No_Checks): Likewise. (Duplicate_Subexpr_Move_Checks): Likewise. * exp_util.adb (Build_Allocate_Deallocate_Proc): Pass Proc_Id as the actual for New_Scope in the calls to Duplicate_Subexpr_No_Checks. (Duplicate_Subexpr): Add New_Scope formal parameter and forward it in the call to New_Copy_Tree. (Duplicate_Subexpr_No_Checks): Likewise. (Duplicate_Subexpr_Move_Checks): Likewise.
2025-06-06ada: Fix for validity checking of limited scalar typesPiotr Trojanek1-3/+12
With a recent change we are now validity checking objects of private scalar types, but need to handle private scalar types whose public view is limited. gcc/ada/ChangeLog: * checks.adb (Insert_Valid_Check): Set flag Assignment_OK in the object declaration inserted for the validity checks.
2025-06-06Daily bump.GCC Administrator1-0/+371
2025-06-05ada: Confusing "modified by call, but value overwritten" warningsquirek1-3/+5
The patch fixes an issue in the compiler whereby not referencing a local variable used in multiple procedure calls as an "out" actual in between calls would lead to a warning despite "-gnatw.o" not being present. Additionally, this meant that using pragma Unreferenced on such variables would not be able to silence such warnings. gcc/ada/ChangeLog: * sem_warn.adb (Warn_On_Useless_Assignment): Disable out value "overwritten" warning when we are not warning on unread out parameters (e.g. "-gnatw.o").
2025-06-05ada: Add explicit null pointer check in C.Strings.UpdateTonu Naks1-0/+5
gcc/ada/ChangeLog: * libgnat/i-cstrin.adb: null pointer check in Update
2025-06-05ada: Remove ghost code and SPARK annotations from runtime unitsArnaud Charlet102-10758/+248
This is a clean up to facilitate maintenance now that these units have been proven. gcc/ada/ChangeLog: * exp_util.adb, rtsfind.adb, rtsfind.ads, sem_prag.adb: Remove references to RO_GH_Big_Integer and Ada_Numerics_Big_Numbers_Big_Integers_Ghost. * libgnat/a-strfix.adb, libgnat/a-strmap.adb, libgnat/a-strsea.adb, libgnat/a-strsup.adb, libgnat/i-c.ads, libgnat/i-c.adb, libgnat/s-aridou.adb, libgnat/s-aridou.ads, libgnat/s-arit128.adb, libgnat/s-arit128.ads, libgnat/s-arit32.adb, libgnat/s-arit32.ads, libgnat/s-arit64.adb, libgnat/s-arit64.ads, libgnat/s-casuti.adb, libgnat/s-exnint.ads, libgnat/s-exnlli.ads, libgnat/s-exnllli.ads, libgnat/s-expint.ads, libgnat/s-explli.ads, libgnat/s-expllli.ads, libgnat/s-explllu.ads, libgnat/s-expllu.ads, libgnat/s-expmod.adb, libgnat/s-expmod.ads, libgnat/s-exponn.adb, libgnat/s-exponn.ads, libgnat/s-expont.adb, libgnat/s-expont.ads, libgnat/s-exponu.adb, libgnat/s-exponu.ads, libgnat/s-imaged.ads, libgnat/s-imaged.adb, libgnat/s-expuns.ads, libgnat/s-imagef.ads, libgnat/s-imagef.adb, libgnat/s-imagei.adb, libgnat/s-imagei.ads, libgnat/s-imageu.adb, libgnat/s-imageu.ads, libgnat/s-imgboo.adb, libgnat/s-imde128.ads, libgnat/s-imde32.ads, libgnat/s-imde64.ads, libgnat/s-imfi128.ads, libgnat/s-imfi32.ads, libgnat/s-imfi64.ads, libgnat/s-imgboo.ads, libgnat/s-imgint.ads, libgnat/s-imglli.ads, libgnat/s-imgllli.ads, libgnat/s-imglllu.ads, libgnat/s-imgllu.ads, libgnat/s-imguns.ads, libgnat/s-valboo.adb, libgnat/s-valboo.ads, libgnat/s-valint.ads, libgnat/s-vallli.ads, libgnat/s-valllli.ads, libgnat/s-vallllu.ads, libgnat/s-valllu.ads, libgnat/s-valuns.ads, libgnat/s-valuti.adb, libgnat/s-valuti.ads, libgnat/s-valuei.adb, libgnat/s-valuei.ads, libgnat/s-valueu.ads, libgnat/s-valueu.adb, libgnat/s-veboop.adb, libgnat/s-veboop.ads, libgnat/s-widint.ads, libgnat/s-widlli.ads, libgnat/s-widllli.ads, libgnat/s-widlllu.ads, libgnat/s-widllu.ads, libgnat/s-widthi.adb, libgnat/s-widthu.adb, libgnat/s-widthu.ads, libgnat/s-widuns.ads: Remove ghost code and SPARK annotations. * libgnat/a-nbnbig.ads, libgnat/a-nbnbig.adb, libgnat/s-spark.ads, libgnat/s-spcuop.adb, libgnat/s-spcuop.ads, libgnat/s-vaispe.adb, libgnat/s-vaispe.ads, libgnat/s-vauspe.adb, libgnat/s-vauspe.ads, libgnat/s-vs_int.ads, libgnat/s-vs_lli.ads, libgnat/s-vs_llu.ads, libgnat/s-vs_uns.ads, libgnat/s-valspe.adb, libgnat/s-valspe.ads, libgnat/s-vsllli.ads, libgnat/s-vslllu.ads: Removed. * Makefile.rtl: Update list of runtime units. * gcc-interface/Make-lang.in: Remove object files.
2025-06-05ada: Fix SFN_Patterns documentation commentRonan Desplanques1-4/+7
The documentation comment under SFN_Patterns was misleading. This patch fixes it and also fixes Get_Default_File_Name which assumed the comment was correct. gcc/ada/ChangeLog: * fname-uf.adb: Fix documentation comment. (Get_Default_File_Name): Fix indices of default patterns.
2025-06-05ada: Tweak wording of documentation comments in AtreeRonan Desplanques1-8/+7
This patch removes an outdated reference to the concept of node extensions in comments. It also slightly clarifies the documentation of Atree.Relocate_Node. gcc/ada/ChangeLog: * atree.ads (New_Copy, Relocate_Node): Tweak documentation comments.
2025-06-05ada: Activate SPARK_Mode in Ada.Numerics.*_Random specsAndres Toom2-19/+57
gcc/ada/ChangeLog: * libgnat/a-nudira.ads: Activate SPARK mode and add missing basic contracts. Mark the unit as always terminating. * libgnat/a-nuflra.ads: Idem.
2025-06-05ada: Spurious compilation error with repeated loop indexJavier Miranda1-0/+15
When multiple for-loop statements in the same scope use the same index name to iterate through container elements, the compiler reports a spurious error indicating a conflict between index names. gcc/ada/ChangeLog: * exp_ch7.adb (Process_Object_Declaration): Avoid generating duplicate names for master nodes.
2025-06-05ada: Remove useless global variableRonan Desplanques2-41/+0
This patch removes a global variable that was made useless by a previous change and mistakenly hadn't been removed then. gcc/ada/ChangeLog: * opt.ads: Remove useless variable. * sem_ch9.adb (Analyze_Abort_Statement, Analyze_Accept_Alternative, Analyze_Accept_Statement, Analyze_Asynchronous_Select, Analyze_Conditional_Entry_Call, Analyze_Delay_Alternative, Analyze_Delay_Relative, Analyze_Delay_Until, Analyze_Entry_Body, Analyze_Entry_Body_Formal_Part, Analyze_Entry_Call_Alternative, Analyze_Entry_Declaration, Analyze_Entry_Index_Specification, Analyze_Protected_Body, Analyze_Protected_Definition, Analyze_Protected_Type_Declaration, Analyze_Requeue, Analyze_Selective_Accept, Analyze_Single_Protected_Declaration, Analyze_Single_Task_Declaration, Analyze_Task_Body, Analyze_Task_Definition, Analyze_Task_Type_Declaration, Analyze_Terminate_Alternative, Analyze_Timed_Entry_Call, Analyze_Triggering_Alternative): Remove useless assignments.
2025-06-05ada: Exception-raising loop incorrectly eliminatedSteve Baird1-1/+6
If the body of a loop includes a raise statement then the loop should not be considered to be free of side-effects and therefore eligible for elimination by the compiler. gcc/ada/ChangeLog: * sem_util.adb (Side_Effect_Free_Statements): Return False if the statement list includes an explicit (i.e. Comes_From_Source) raise statement.
2025-06-05ada: Missing error on expression function returning incomplete typeJavier Miranda1-0/+5
When the type of the expression of an expression function is an incomplete type, the frontend does not report the expected error. gcc/ada/ChangeLog: * sem_ch6.adb (Analyze_Expression_Function): Add missing check on premature use of incomplete type.
2025-06-05ada: Add Ghost aspect to Lo in s-arit32.adbAleksandra Pasek1-1/+2
gcc/ada/ChangeLog: * libgnat/s-arit32.adb: Add Ghost aspect to Lo.
2025-06-05ada: Fix crash on access to protected returnRonan Desplanques1-2/+3
The generation of the check mandated by Ada issue AI05-0073 was not done handled properly for protected types when used through subtypes. This patch fixes the issue. gcc/ada/ChangeLog: * exp_ch4.adb (Tagged_Membership): Fix for protected types.
2025-06-05ada: Improve efficiency of very large shift countsBob Duff2-81/+51
For a call to an intrinsic shift function with a large Amount, for example Shift_Right(..., Amount => Natural'Last), and a compile-time-known value, the compiler would take an absurdly long time to compute the value. This patch fixes that by special-casing shift counts that are larger than the size of the thing being shifted. gcc/ada/ChangeLog: * sem_eval.adb (Fold_Shift): If the Amount parameter is greater than the size in bits, use the size. For example, if we are shifting an Unsigned_8 value, then Amount => 1_000_001 gives the same result as Amount => 8. This change avoids computing the value of 2**1_000_000, which takes too long and uses too much memory. Note that the computation we're talking about is a compile-time computation. Minor cleanup. DRY. * sem_eval.ads (Fold_Str, Fold_Uint, Fold_Ureal): Fold the comments into one comment, because DRY. Remove useless verbiage.
2025-06-05ada: Tweak caching of streaming subprogramsRonan Desplanques1-2/+2
gcc/ada/ChangeLog: * exp_attr.adb (Interunit_Ref_OK): Tweak categorization of compilation units.
2025-06-05ada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx64 in s-aridou.adbAleksandra Pasek1-0/+1
gcc/ada/ChangeLog: * libgnat/s-aridou.adb: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx64.
2025-06-05ada: Mitigate issue with tracebacksRonan Desplanques1-0/+18
The way we fetch the path to shared objects for traceback generation is not perfectly precise. This patch adds a sanity check to mitigate the consequences of incorrect shared object paths. It's motivated by a real world failure in a GNATSAS test. gcc/ada/ChangeLog: * libgnat/s-trasym__dwarf.adb (Init_Module): Add mitigation.
2025-06-05ada: Implement built-in-place expansion of two-pass array aggregatesEric Botcazou5-216/+324
These are array aggregates containing only component associations that are iterated with iterator specifications, as per RM 4.3.3(20.2/5-20.4/5). It is implemented for the array aggregates that are used to initialize an object, as specified by RM 7.6(17.2/3-17.3/3) for immutably limited types and types that need finalization, but for all types like other aggregates. gcc/ada/ChangeLog: * exp_aggr.adb (Build_Two_Pass_Aggr_Code): New function containing most of the code initially present in Two_Pass_Aggregate_Expansion. (Two_Pass_Aggregate_Expansion): Remove redundant N parameter. Implement built-in-place expansion for (static) object declarations and allocators, using Build_Two_Pass_Aggr_Code for the main work. (Expand_Array_Aggregate): Adjust Two_Pass_Aggregate_Expansion call. Replace Etype (N) by Typ in a couple of places. * exp_ch3.adb (Expand_Freeze_Array_Type): Remove special case for two-pass array aggregates. (Expand_N_Object_Declaration): Do not adjust the object when it is initialized by a two-pass array aggregate. * exp_ch4.adb (Expand_Allocator_Expression): Apply the processing used for container aggregates to two-pass array aggregates. * exp_ch6.adb (Validate_Subprogram_Calls): Skip calls present in initialization expressions of N_Object_Declaration nodes that have No_Initialization set. * sem_ch3.adb (Analyze_Object_Declaration): Detect the cases of an array originally initialized by an aggregate consistently.
2025-06-05ada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx32 in s-arit32.adbJohannes Kliemann1-0/+1
gcc/ada/ChangeLog: * libgnat/s-arit32.adb (Lemma_Not_In_Range_Big2xx32): Add missing Ghost aspect.