aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2025-06-12ada: Fix wrong visibility over discriminantsRonan Desplanques1-4/+12
This patch fixes an issue where the compiler was incorrectly allowing references to discriminants of the ancestor type in private type extensions. gcc/ada/ChangeLog: * sem_ch3.adb (Build_Derived_Private_Type): Fix test. (Build_Derived_Record_Type): Adjust error recovery paths.
2025-06-12ada: Assorted minor cleanups and tweaksEric Botcazou5-248/+270
There should be no functional changes. gcc/ada/ChangeLog: * einfo.ads (Has_Homonym): Fix inaccuracy in description. * sem_ch8.ads (Find_Direct_Name): Remove obsolete description. * sem_ch12.adb (Analyze_Associations): Rename I_Node parameter into N and adjust description. (Analyze_Subprogram_Instantiation): Add missing description. (Contains_Instance_Of): Fix description. (Associations): Rename Generic_Actual_Rec into Actual_Rec and Gen_Assocs_Rec into Match_Rec. (Analyze_One_Association): Rename I_Node parameter into N. (Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into Match. (Body of Associations): Minor cleanups and tweaks. (Analyze_Associations): Rename I_Node parameter into N and adjust implementation. (Analyze_One_Association): Likewise. (Analyze_Package_Instantiation): Remove obsolete code and clean up. (Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into Match and adjust implementation. (Freeze_Package_Instance): Simplify condition. (Get_Unit_Instantiation_Node): Add support for instantiations of subprograms and stop the loop properly in case of errors. * sem_util.ads (Add_Global_Declaration): Rename N parameter into Decl and fix description. * sem_util.adb (Add_Global_Declaration): Rename N parameter into Decl and adjust implementation.
2025-06-12ada: Add Ada RM clause reference in commentRonan Desplanques1-1/+2
gcc/ada/ChangeLog: * libgnat/s-valuer.adb (Scan_Raw_Real): Add RM reference.
2025-06-12ada: Remove subexpression that's always FalseRonan Desplanques1-4/+4
Also improve a few comments in the enclosing subprogram body. gcc/ada/ChangeLog: * libgnat/s-valuer.adb (Scan_Raw_Real): Remove subexpression. Improve surrounding comments.
2025-06-12ada: VAST: Check basic tree propertiesBob Duff3-84/+439
Check that the tree is really a tree, that parent pointers make sense, that every node has been analyzed, and so on. Most of these checks are disabled, because they fail in many cases, including the compiler and run-time library. Improve the debugging support in VAST. Walk subtrees "by hand", rather than calling Atree.Traverse routines, because that makes debugging printouts more convenient, and because we want to keep a node stack for checking parents. gcc/ada/ChangeLog: * vast.adb: Check basic tree properties. * atree.adb (Traverse_Field): Minor. * treepr.adb (Destroy): Minor comment.
2025-06-12ada: Fix rounding test with odd basesEric Botcazou1-1/+3
The test as currently written is incorrect for odd bases. gcc/ada/ChangeLog: * libgnat/s-valuer.adb (Round_Extra): Use multiplicative test.
2025-06-12ada: Remove obsolete testRonan Desplanques1-8/+1
A previous change cleaned up the Ekind field of record component entities. That made a particular test obsolete, so this patch removes that test. gcc/ada/ChangeLog: * einfo-utils.adb (Set_Convention): Remove obsolete test.
2025-06-12ada: Set Ekinds of discriminants earlierRonan Desplanques2-6/+11
Some error processing paths in Enter_Name are adjusted so that error messages are not affected. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Discriminants): Set Ekind earlier. * sem_util.adb (Enter_Name): Adjust error processing.
2025-06-12ada: Fix various issues in System.Value_F.Integer_To_Fixed functionEric Botcazou1-10/+27
The first issue is that the function would wrongly raise Constraint_Error on the edge case where Val = 2**(Int'Size - 1) and Minus is not set. The second issue is that some runtimes are compiled with -gnatp and would fail to raise Constraint_Error when the sum of the terms overflows an Int. The third issue is that the function takes a long time to deal with huge negative exponents. gcc/ada/ChangeLog: * libgnat/s-valuef.adb (Integer_To_Fixed): Enable overflow checks. Deal specifically with Val = 2**(Int'Size - 1) if Minus is not set. Exit the loop when V saturates to 0 in the case of (huge) negative exponents.
2025-06-12ada: Tweak special handling of synchronized type scopesRonan Desplanques1-8/+20
Exp_Util.Insert_Actions handles scopes of synchronized types specially, but the condition it tested before this patch was not quite correct in some cases, for example during some expansion operations made under Expand_N_Task_Type_Declaration. This patch refines the test. gcc/ada/ChangeLog: * exp_util.adb (Insert_Actions): Refine test.
2025-06-12ada: Small tweak to latest changeEric Botcazou2-5/+3
gcc/ada/ChangeLog: * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler switches) <-O>: Fix long line. * gnat_ugn.texi: Regenerate.
2025-06-12ada: Implement -gnatRh switch to display holes in record layoutEric Botcazou6-90/+279
This implements the new (sub)switch -gnatRh to display holes in the layout of record types, which are mostly present to fulfill alignment requirements. gcc/ada/ChangeLog: * doc/gnat_ugn/building_executable_programs_with_gnat.rst (List of all switches): Add -gnatRh subswitch. (Debugging Control): Document -gnatRh subswitch. * opt.ads (List_Representation_Info_Holes): New boolean variable. * repinfo.adb: Add with clause for GNAT.Heap_Sort_G. (List_Common_Type_Info): Relax assertion. (List_Object_Info): Replace assertion with additional test. (List_Record_Layout): If -gnatRh is specified, make sure that the components are ordered by increasing offsets. Output a comment line giving the number of unused bits if there is a hole between consecutive components. Streamline the control flow of the loop. (List_Record_Info): Use the original record type giving the layout of components, if any, to display the layout of the record. * switch-c.adb (Scan_Front_End_Switches) <-gnatR>: Add support for -gnatRh subswitch. * usage.adb (Usage): Document -gnatRh subswitch. * gnat_ugn.texi: Regenerate.
2025-06-12ada: Adjust alignment calculation for secondary stackJohannes Kliemann2-0/+18
The secondary stack allocator needs to take alignment constraints into account when doing allocations. In the full runtime the secondary stack is allocated in chunks on the heap and can grow dynamically. As it does not grow contiguously the "top" of the stack depends on the size of the allocation. Therefore the alignment of the stack top is not known at allocation time and the padding needed for a particular alignment needs to be calculated conservatively to ensure the allocation fits the requested size after the base address has been aligned. On more restricted platforms the secondary stack is a contiguous block of statically allocated memory. Here the conservative mechanism is not required since the allocations base address is known and the required padding can be calculated right away. The conservative approach also sometimes causes an allocation to be slightly larger than it needs to be. This can be a problem on platforms with limited RAM availability. To avoid this problem modify the calculation of the required padding on these platforms to always exactly fit the required size. gcc/ada/ChangeLog: * libgnat/s-secsta.adb (SS_Allocate): Add comment about conservative alignment padding calculation. * libgnat/s-secsta__cheri.adb (SS_Allocate): Add comment about conservative alignment padding calculation.
2025-06-12ada: Rewrite boolean expressionRonan Desplanques1-10/+4
This patch rewrites a boolean expression to make it easier to understand in its context. It also tweaks the surrounding comments. gcc/ada/ChangeLog: * sem_warn.adb (Check_References): Rewrite expression
2025-06-12ada: Remove uses of E_VoidRonan Desplanques1-25/+24
This patch removes various calls on entities that have their entity kinds set to E_Void, by giving those entities their proper kinds earlier. This is to prepare for potential new future invariant checks on entities. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index, Make_Index, Array_Type_Declaration, Analyze_Number_Declaration): Remove uses of E_Void.
2025-06-12ada: Document supported GCC optimization switchesEric Botcazou4-67/+119
In particular the most recently added ones, namely -Og and -Oz. But -Ofast is not documented because it disregards strict compliance with standards. gcc/ada/ChangeLog: * usage.adb (Usage): Justify the documentation of common switches like that of other switches. Rework that of the -O switch. * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler switches) <-O>: Rework and document 'z' and 'g' operands. * doc/gnat_ugn/gnat_and_program_execution.rst (Optimization Levels): Rework and document -Oz and -Og switches. * gnat_ugn.texi: Regenerate.
2025-06-12ada: Remove creation of some unused itypesRonan Desplanques1-9/+13
Before this patch, Constrain_Index always started by creating an itype but then sometimes not using it for anything. This patch makes it so an itype is only created when needed. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index): Avoid unused itypes.
2025-06-12ada: Factorize return statementRonan Desplanques1-3/+2
Code cleanup; behavior is unaffected. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index): Factorize return statement.
2025-06-12ada: Remove duplicate setter callRonan Desplanques1-3/+0
gcc/ada/ChangeLog: * sem_ch3.adb (Build_Derived_Numeric_Type): Remove duplicate call.
2025-06-11Daily bump.GCC Administrator1-0/+171
2025-06-10ada: Generic formal objects have no entry componentsPiotr Trojanek1-3/+2
AST field Entry_Component doesn't make sense for generic formal objects and was never used there. Code cleanup; behavior is unaffected. gcc/ada/ChangeLog: * gen_il-gen-gen_entities.adb (Formal_Object_Kind): Remove Entry_Component field.
2025-06-10ada: Remove redundant guard against attribute with no expressionsPiotr Trojanek1-1/+0
We intentionally allow First to work on No_List, so there is no need to guard against a No_List. Code cleanup; semantics is unaffected. gcc/ada/ChangeLog: * sem_attr.adb (Resolve_Attribute): Remove redundant guard.
2025-06-10ada: Minor comment tweakEric Botcazou1-3/+3
This replaces a couple of occurrences of "function" by "subprogram". gcc/ada/ChangeLog: * inline.adb (Analyze_Inlined_Bodies): Minor comment tweak.
2025-06-10ada: Small cleanup in instantiation of generic bodiesEric Botcazou2-20/+14
This removes the code dealing with generic main units from the body of the instantiation routine, namely Instantiate_Bodies, and replaces it by tests done earlier in the processing. The test added to Need_Subprogram_Instance_Body is already present in the twin predicate Needs_Body_Instantiated. gcc/ada/ChangeLog: * inline.adb (Instantiate_Body): Do not call Add_Scope_To_Clean if the main unit is generic. (Instantiate_Bodies): Do not deal with generic main units here. * sem_ch12.adb (Need_Subprogram_Instance_Body): Return false if the main unit is generic.
2025-06-10ada: Do not install the support files of 128-bit types on 32-bit targetsEric Botcazou1-1/+85
The files are not compiled into libgnat.a but are nevertheless installed in the adainclude directory, which is unwanted. gcc/ada/ChangeLog: * Makefile.rtl (ADA_EXCLUDE_SRCS): Add the 128-bit support files.
2025-06-10ada: Factorize some duplicate codeRonan Desplanques1-16/+19
Process_Subtype can be passed either a subtype indication or a subtype mark. Before this patch, it branched directly depending on the kind of the argument, but there actually was processing common to the two branches like resolving the subtype mark. This patch factorizes this common processing out of the if statement. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Factorize code.
2025-06-10ada: VAST found bug: Itypes with ParentBob Duff2-12/+14
Fix the comment about Itypes, so the Parent field is no longer required. Change VAST to no longer require it. Remove Check_Itype_Parents from Check_Enum; it can no longer fail, so there's no point in making it switchable. gcc/ada/ChangeLog: * einfo.ads (Associated_Node_For_Itype): Document that Parent field may be empty. * vast.adb: Allow empty Parent in Itypes.
2025-06-10ada: Error on subtype with static predicate used in case_expressionGary Dismukes2-4/+6
The compiler improperly flags an error on the use of a subtype with a static predicate as a choice in a case expression alternative, complaining that the subtype has a nonstatic predicate. The fix for this is to add a test for the subtype not having a static predicate. gcc/ada/ChangeLog: * einfo.ads: Revise comment about Dynamic_Predicate flag to make it more accurate. * sem_case.adb (Check_Choices): Test "not Has_Static_Predicate_Aspect" as additional guard for error about use of subtype with nonstatic predicate as a case choice. Improve related error message.
2025-06-10ada: Special case for inconsistent pointer in Scan_Raw_UnsignedTonu Naks2-5/+12
gcc/ada/ChangeLog: * libgnat/s-valueu.adb: add explict raise * libgnat/s-valueu.ads: update annotation
2025-06-10ada: Move Check_Discriminant_Conformance to Sem_Ch3Ronan Desplanques3-252/+252
Check_Discriminant_Conformance is really only about concepts defined in chapter 3 of the Ada reference manual, so it fits better in Sem_Ch3 than in Sem_Ch6. gcc/ada/ChangeLog: * sem_ch6.adb, sem_ch6.ads (Check_Discriminant_Conformance): Move to … * sem_ch3.adb (Check_Discriminant_Conformance): … here.
2025-06-10ada: Fix fallout of latest changeEric Botcazou1-1/+7
Freeze_Static_Object needs to deal with the objects that have been created by Insert_Conditional_Object_Declaration. gcc/ada/ChangeLog: * freeze.adb (Freeze_Static_Object): Do not issue any error message for compiler-generated entities.
2025-06-10ada: VAST: treewalker improvementsBob Duff1-12/+124
Implement two basic checks: Check that N_Error nodes cannot appear in the tree (because VAST is not called when the source is illegal). Check that every node has a parent, except for certain nodes where we check the opposite. (We do not yet check that the parent pointers actually point to the right node.) Minor improvements. Flags for controlling debugging outputs and the like. Capability to enable/disable individual checks. The intent is to implement that only when needed -- i.e. when VAST finds a bug, and we have not yet fixed the bug. gcc/ada/ChangeLog: * vast.adb: Implement two checks. Improve debugging outputs.
2025-06-10ada: Fix wrong initialization of library-level object by conditional expressionEric Botcazou2-4/+15
The previous fix was not robust enough in the presence of transient scopes. gcc/ada/ChangeLog: * exp_ch4.adb (Insert_Conditional_Object_Declaration): Deal with a transient scope being created around the declaration. * freeze.adb (Freeze_Entity): Do not call Freeze_Static_Object for a renaming declaration.
2025-06-10ada: Fix inconsistent comment for fixed-point Value attribute implementationEric Botcazou3-9/+9
The comment incorrectly mentions decimal fixed point. gcc/ada/ChangeLog: * libgnat/s-vafi32.ads: Fix head description. * libgnat/s-vafi64.ads: Likewise. * libgnat/s-vafi128.ads: Likewise.
2025-06-10ada: VAST: create treewalkerBob Duff10-71/+139
Walks all trees (not just the main unit), deals with switches and flags. Doesn't check much of anything yet (asserts that "unused" nodes are not present). Move decisions (what tree(s) to check, what switches enable checking) from the caller to the body of VAST. gcc/ada/ChangeLog: * vast.adb: Initial implementation. * vast.ads: Rename procedure. Remove parameter; body should decide what to do. * lib.ads (ipu): Minor: Rewrite comment for brevity, and because of an inconvenient misspelling. (Num_Units): Not used; remove. (Remove_Unit): Minor: Remove "Currently" (which was current a decade ago from) comment. * lib.adb (Num_Units): Not used; remove. * debug_a.adb (Debug_A_Entry): Fix bug: Use Write_Name_For_Debug, so this won't crash on the Error node. * debug.adb: Document -gnatd_V and -gnatd_W compiler switches. * exp_ch6.adb (Validate_Subprogram_Calls): Remove redundant check for Serious_Errors_Detected. (We turn off code gen when errors are detected.) * frontend.adb: Move decisions into VAST body. * namet.ads (Present): Remove unnecessary overriding; these are inherited by the derived types. * namet.adb (Present): Likewise.
2025-06-10ada: Storage_Error on Ordered_Maps container aggregate with enumeration Key_TypeGary Dismukes1-1/+1
The compiler fails with a Storage_Error when compiling a container aggregate for a Map type coming from an instantiation of Ada.Containers.Ordered_Maps that specifies an enumeration type for the Key_Type formal. gcc/ada/ChangeLog: * exp_aggr.adb (Build_Container_Aggr_Code.To_Int): Apply Enumeration_Pos to Entity (Expr) rather than Expr.
2025-06-10ada: Fix omission in commentRonan Desplanques1-1/+2
gcc/ada/ChangeLog: * sem_ch3.adb (Find_Type_Of_Object): Fix comment.
2025-06-10ada: Rename constant in Analyze_Component_DeclarationRonan Desplanques1-2/+2
"Typ" is typically used to name constants that are entity IDs for types. Before this patch, a constant local to Analyze_Component_Declaration designating a syntactic subtype indication had that name. This patch renames it to "Ind". Code cleanup; behavior is unaffected. gcc/ada/ChangeLog: * sem_ch3.adb (Analyze_Component_Declaration): Rename constant.
2025-06-10ada: Simplify Constrain_ArrayRonan Desplanques1-12/+4
Before this patch, Constrain_Array had a feature where it could be passed Empty for the first actual and would then create an Itype itself. There was only one use of this feature and it was unnecessary, so this patch removes it. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Array): Simplify. (Process_Subtype): Adjust.
2025-06-10ada: Fix infinite loop with aggregate in generic unitEric Botcazou1-4/+1
Root_Type does not return the same type for the private and the full view of a derived private tagged type when both derive from an interface type. gcc/ada/ChangeLog: * sem_ch12.adb (Copy_Generic_Node): Do not call Root_Type to find the root type of an aggregate of a derived tagged type.
2025-06-10ada: Fix use-after-free in Compute_All_TasksRonan Desplanques1-1/+4
This patch fixes a bug in System.Stack_Usage.Tasking.Compute_All_Tasks where it would attempt to read the stack of threads that had already completed. gcc/ada/ChangeLog: * libgnarl/s-stusta.adb (Compute_All_Tasks): Skip terminated tasks.
2025-06-10ada: Fix the detection of configuration pragmasViljar Indus1-1/+17
Some pragma nodes like the ones for Assertion_Policy are replaced by a Null_Statement. This is not taken into account when analyzing if the pragma is a configuration pragma. gcc/ada/ChangeLog: * sem_prag.adb (Is_Configuration_Pragma): Check that nodes preceding the pragma are pragma nodes or originally were pragma nodes.
2025-06-10ada: Fix Value_Decimal to raise Constraint_Error on boundary valuesEric Botcazou1-8/+19
Even though the issue is not user-visible, it's a (minor) departure from the specification of the procedure. gcc/ada/ChangeLog: * libgnat/s-valued.adb (Integer_to_Decimal): Add Extra parameter and use its value to call Bad_Value on boundary values. (Scan_Decimal): Adjust call to Integer_to_Decimal. (Value_Decimal): Likewise.
2025-06-10ada: Add Incomplete_Type_OK formal to Process_SubtypeRonan Desplanques2-27/+26
Before this patch, Process_Subtype looked at the parent of its argument to determine whether it was called in a context where it was OK for the subtype mark to refer to the incomplete view of a type. This patch adds a new formal so that it becomes the responsibility of the caller in order to make the code simpler overall. The only change in the behavior of the compiler is that the messages emitted in some error situations with the -gnatf switch are slightly different. gcc/ada/ChangeLog: * sem_ch3.ads (Process_Subtype): New formal. * sem_ch3.adb (Process_Subtype): Likewise. (Analyze_Subtype_Declaration, Access_Type_Declaration): Use new formal.
2025-06-10ada: Fix recursive call in Process_SubtypeRonan Desplanques1-1/+3
Process_Subtype calls itself in some error situations. This recursive call was not updated together with the recent addition of the Excludes_Null formal. This does not matter in practice because there can never be both a null exclusion and another constraint at the same time, but this patch updates the call anyway to make the situation clearer. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Fix recursive call.
2025-06-10ada: Rename a couple of local variablesEric Botcazou1-19/+19
Block_Node is the name of an entity field, so the change renames local variables with this name for the sake of clarity. gcc/ada/ChangeLog: * par-ch5.adb (P_Declare_Statement): Rename local variable. (P_Begin_Statement): Likewise.
2025-06-10ada: Remove outdated comment about reused entity fieldsPiotr Trojanek1-8/+2
With the current representation of GNAT AST the entity fields are not reused. gcc/ada/ChangeLog: * einfo.ads (Overridden_Operation, Static_Initialization): Remove comments about a reused entity field.
2025-06-10ada: Tweak formatting in Process_SubtypeRonan Desplanques1-2/+2
This patch removes parentheses and vertical alignment that misleadingly suggested the presence of function calls where there weren't any. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Tweak formatting.
2025-06-10ada: Add assertion on expanded code in particular caseRonan Desplanques1-0/+2
This patch adds an assertion that checks that expanded code does not contain erroneous access subtype definitions. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Add assertion.
2025-06-10ada: Factorize initialization of local variableRonan Desplanques1-3/+1
gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Factorize initialization of variable.