aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2024-08-02ada: Type conversion in instance incorrectly rejected.Steve Baird1-1/+1
In some cases, a legal type conversion in a generic package is correctly accepted but the corresponding type conversion in an instance of the generic is incorrectly rejected. gcc/ada/ * sem_res.adb (Valid_Conversion): Test In_Instance instead of In_Instance_Body.
2024-08-02ada: Implement No_Raise aspect & pragma on subprogramsEric Botcazou20-758/+1039
The new aspect is automatically set on the Adjust and Finalize primitives of finalizable types, unless Relaxed_Finalization is explicitly set to False, but it can also be specified directly on subprograms. It is also available in earlier versions of the language by means of the associated pragma. gcc/ada/ * aspects.ads (Aspect_Id): Add Aspect_No_Raise identifier. (Implementation_Defined_Aspect): Add True for Aspect_No_Raise. (Is_Representation_Aspect): Add False for Aspect_No_Raise. (Aspect_Names): Add Name_No_Raise for Aspect_No_Raise. (Aspect_Delay): Add Always_Delay for Aspect_No_Raise. * checks.ads (Raise_Checks_Suppressed): New function. (Apply_Raise_Check): New procedure. * checks.adb (Apply_Raise_Check): New procedure. (Raise_Checks_Suppressed): New function. * doc/gnat_rm/gnat_language_extensions.rst (Generalized Finalization): Update. * doc/gnat_rm/implementation_defined_aspects.rst (No_Raise): New. * doc/gnat_rm/implementation_defined_characteristics.rst (Check names): Document Raise_Check and alphabetize others. * doc/gnat_rm/implementation_defined_pragmas.rst (No_Raise): New. * einfo.ads (No_Raise): New flag defined in subprograms and generic subprograms. * exp_ch6.adb (Expand_N_Subprogram_Body): Call Apply_Raise_Check at the end of the processing. * exp_ch11.adb (Get_RT_Exception_Name): Add alternative for PE_Raise_Check_Failed to case statement. * gen_il-fields.ads (Opt_Field_Enum): Add No_Raise identifier. * gen_il-gen-gen_entities.adb (Subprogram_Kind): Add No_Raise as semantical flag. (Generic_Subprogram_Kind): Likewise. * par-prag.adb (Prag): Add alternative for Pragma_No_Raise to case statement. * sem_ch13.adb (Validate_Finalizable_Aspect): Set No_Raise on the Adjust and Finalize primitives if Relaxed_Finalization is set. * sem_prag.adb (Analyze_Pragma): Add alternative for Pragma_No_Raise to case statement. (Sig_Flag): Add 0 for Pragma_No_Raise. * snames.ads-tmpl (Remaining pragma names): Add Name_No_Raise. (Names of recognized checks): Add Name_Raise_Check. (Pragma_Id): Add Pragma_No_Raise identifier. * types.ads (Raise_Check): New named number. (All_Checks): Adjust. (RT_Exception_Code): Add PE_Raise_Check_Failed identifier. (Rkind): Add PE_Reason for PE_Raise_Check_Failed and alphabetize. * types.h (RT_Exception_Code): Add PE_Raise_Check_Failed as 38. (LAST_REASON_CODE): Adjust. * libgnat/a-except.adb (Rcheck_PE_Raise_Check): New procedure with pragmas Export, No_Return and Machine_Attributes. (Rmsg_38): New string constant. * gnat_rm.texi: Regenerate.
2024-08-02ada: Improve documenation about security of PRGNsJohannes Kliemann5-7/+17
The pseudo random number generators used in GNAT are not suitable for applications that require cryptographic security. While this was mentioned in some places others did not have a corresponding note, leading to these generators being used in a non-suitable context. gcc/ada/ * doc/gnat_rm/standard_library_routines.rst: Add note to section of Ada.Numerics.Discrete_Random and Ada.Numerics.Float_Random. * doc/gnat_rm/the_gnat_library.rst: Add note to section about GNAT.Random_Numbers. * libgnat/a-nudira.ads: Add note about cryptographic properties. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-08-02ada: Fix layout of GNAT reference manual sectionRonan Desplanques3-5/+7
gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst: Fix layout of section. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-08-02ada: Fix crash on expression function returning tagged type in nested packageEric Botcazou4-79/+130
This happens when the expression is a reference to a formal parameter of the function, or a conditional expression with such a reference as one of its dependent expressions, because the RM 6.5(8/5) subclause prescribes a tag reassignment in this case, which requires freezing the tagged type in the GNAT freezing model, although the language says there is no freezing. In other words, it's another occurrence of the discrepancy between this model tailored to Ada 95 and the freezing rules introduced in Ada 2012, that is papered over by Should_Freeze_Type and the associated processing. gcc/ada/ * exp_util.ads (Is_Conversion_Or_Reference_To_Formal): New function declaration. * exp_util.adb (Is_Conversion_Or_Reference_To_Formal): New function body. * exp_ch6.adb (Expand_Simple_Function_Return): Call the predicate Is_Conversion_Or_Reference_To_Formal in order to decide whether a tag check or reassignment is needed. * freeze.adb (Should_Freeze_Type): Move declaration and body to the appropriate places. Also return True for tagged results subject to the expansion done in Expand_Simple_Function_Return that is guarded by the predicate Is_Conversion_Or_Reference_To_Formal.
2024-08-02ada: Fix detection of suspicious loop patternsRonan Desplanques1-1/+5
This patch fixes an assertion failure in some cases in the code to warn about possible misuse of range attributes in loop. The root of the problem is that this code failed to consider the case where the outer loop is a while loop. Also fix a typo in a nearby comment. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Statement): Fix loop pattern detection code. Fix typo.
2024-08-02Daily bump.GCC Administrator1-0/+298
2024-08-01ada: Fix computation of new size when reallocating unbounded stringYannick Moy1-1/+1
The procedure Realloc_For_Chunk which is used to reallocate an unbounded string when needed may lead in theory to an overflow, due to the use of variable S_Length denoting the current allocated length instead of Source.Last denoting the current string length. Now fixed. This has no effect in practice since the only targets that use this version of Ada.Strings.Unbounded do not have enough memory to make it possible to have an overflow here. gcc/ada/ * libgnat/a-strunb.adb (Realloc_For_Chunk): Fix computation of new size.
2024-08-01ada: Update contracts on Strings librariesYannick Moy3-29/+27
The contracts of Ada.Strings.Bounded.To_String and Ada.Strings.Fixed.Delete are updated to reflect the standard spec and to allow proof of callers. gcc/ada/ * libgnat/a-strbou.ads (To_String): Add a postcondition to state the value of bounds of the returned string, which helps with proof of callers. * libgnat/a-strfix.adb (Delete): Fix implementation to produce correct result in all cases. For example, returned string should always have a lower bound of 1, which was not respected in one case. This was not detected by proof, since this code was dead according to the too strict precondition. * libgnat/a-strfix.ads (Delete): State the correct precondition from standard which allows a value of Through beyond the last valid index, and also restricts values of From from below. Update the Contract_Cases accordingly to allow new values of parameters.
2024-08-01ada: Accept duplicate SPARK_Mode pragmas in configuration filesPiotr Trojanek1-8/+0
For consistency, we now accept duplicate SPARK_Mode pragmas in configuration files just like we accept other duplicate pragas there. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Don't check for duplicate SPARK_Mode pragmas in configuration files.
2024-08-01ada: Crash on access attribute with overloaded prefix denoting reference objectGary Dismukes1-1/+36
The compiler fails to accept an access attribute where the prefix is the name of an object of a user-defined reference type, and is not prepared to deal with the possibility of overloaded prefixes other than subprogram cases. Such a prefix can either represent the reference object directly, or it can be interpreted as an implicit dereferencing of the object's reference value, depending on the expected type. Special handling for this kind of prefix is added alongside the normal handling for overloaded prefixes of access attributes. gcc/ada/ * sem_attr.adb (Resolve_Attribute, Attribute_*Access): Resolve overloaded prefixes that denote objects of reference types, determining whether to use the prefix object directly, or expand it as an explicit dereference.
2024-08-01ada: Fix oversight in documentation of At_End_ProcEric Botcazou1-6/+6
It is documented for N_Subprogram_Body_Stub instead of N_Subprogram_Body. gcc/ada/ * sinfo.ads (N_Block_Statement): Move At_End_Proc to the end of slot list and alphabetize flag list. (N_Subprogram_Body): Add At_End_Proc. (N_Package_Body): Move At_End_Proc to the end of slot list. (N_Subprogram_Body_Stub): Remove At_End_Proc.
2024-08-01ada: Deconstruct workarounds for quantified expressions in contractsPiotr Trojanek1-44/+2
Apparently we can always safely set the type of a loop parameter from its discrete subtype definition. It looks like the conditional setting was only necessary when preconditions were expanded into dedicated procedures, but we no longer use this expansion. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Unconditionally set the type of loop parameter.
2024-08-01ada: Style fixes: remove blank lines following 'begin' keywordsGhjuvan Lacambre24-30/+0
The GNAT style guide specifies that there must not be blank lines after 'begin' keywords. gcc/ada/ * backend_utils.adb (Scan_Common_Back_End_Switch): Remove blank line. * errout.adb (Output_JSON_Message): Likewise. * erroutc.adb (Set_Msg_Char): Likewise. * exp_aggr.adb (Two_Dim_Packed_Array_Handled): Likewise. * exp_pakd.adb (Expand_Packed_Address_Reference): Likewise. (Expand_Packed_Bit_Reference): Likewise. (Expand_Packed_Boolean_Operator): Likewise. (Expand_Packed_Element_Reference): Likewise. (Expand_Packed_Eq): Likewise. (Expand_Packed_Not): Likewise. * exp_prag.adb (Build_Dim3_Declaration): Likewise. * exp_strm.adb (Build_Elementary_Input_Call): Likewise. * freeze.adb (Find_Aspect_No_Parts): Likewise. (Get_Aspect_No_Parts_Value): Likewise. * gen_il-gen.adb (Compile): Likewise. * gnat1drv.adb (Adjust_Global_Switches): Likewise. * gnat_cuda.adb (Expand_CUDA_Package): Likewise. * gnatchop.adb (Read_File): Likewise. * gnatls.adb (Get_Runtime_Path): Likewise. * make.adb (Binding_Phase): Likewise. * par-ch11.adb (P_Exception_Choice): Likewise. * par-ch5.adb (P_Loop_Parameter_Specification): Likewise. * par-ch6.adb (Is_Extended): Likewise. * sem_attr.adb (Check_Dereference): Likewise. * sem_ch12.adb (Build_Subprogram_Decl_Wrapper): Likewise. * sem_ch3.adb (Build_Itype_Reference): Likewise. * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Likewise. * sem_res.adb (Resolve_Declare_Expression): Likewise. * sem_util.adb (Build_Default_Subtype): Likewise. * sprint.adb (Sprint_Paren_Comma_List): Likewise.
2024-08-01ada: Restrict string interpolation to single string literalJavier Miranda3-38/+6
gcc/ada/ * par-ch2.adb (P_Interpolated_String_Literal): remove support of multi-line string literals. * doc/gnat_rm/gnat_language_extensions.rst: Update documentation. * gnat_rm.texi: Regenerate.
2024-08-01ada: Use ?j? in Output_Obsolescent_Entity_Warnings messagesViljar Indus1-9/+10
These messages are conditionally activated only when -gnatwj (Warn_On_Obsolescent_Feature) is activated. They should use the switch specific insertion character instead. gcc/ada/ * sem_warn.adb (Output_Obsolescent_Entity_Warnings): use the ?j? in warning messages.
2024-08-01ada: Fix crash in quantified expression expansionRonan Desplanques1-4/+24
Before this patch, the compiler failed to handle the case where the for loop created by expansion of a quantified expression required cleanup handlers. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Fix test for expanded quantified expression context. (Is_Expanded_Quantified_Expr): New function.
2024-08-01ada: Fix bug in resolution of Ghost_PredicateBob Duff3-6/+9
This patch fixes a failure of name resolution when a range attribute reference appears in a Ghost_Predicate and the ghost policy is Ignore. gcc/ada/ * sem_ch13.adb (Add_Predicate): Remove the premature "return;". Ghost code needs to be processed by later code in this procedure even when ignored; otherwise the second pass of name resolution fails much later. However, protect Set_SCO_Pragma_Enabled and Add_Condition with "if not Is_Ignored_Ghost_Pragma"; these parts should not happen if the ghost code is Ignored. * libgnat/interfac__2020.ads (Unsigned_8): Minor reformatting. * libgnat/interfac.ads (IEEE_Extended_Float): Minor comment improvement.
2024-08-01ada: Define No_Return flag only for subprogramsEric Botcazou3-6/+7
...instead of defining it for all entities. gcc/ada/ * einfo.ads (No_Return): Change description and adjust accordingly. * gen_il-gen-gen_entities.adb (Entity_Kind): Remove No_Return. (Subprogram_Kind): Add No_Return. (Generic_Subprogram_Kind): Likewise. * sem_ch6.adb (Analyze_Return_Statement): Adjust No_Return test.
2024-08-01ada: Implement full relaxed finalization semantics for controlled objectsEric Botcazou11-95/+287
These semantics state that the compiler is permitted to enforce none of the guarantees specified by the RM 7.6.1(14/1) and following subclauses, and to instead just let the exception be propagated upward. The guarantees impose a significant overhead in terms of complexity and run-time performance compared to similar constructs in other languages, and the goal is to reduce it significantly, if not eliminate it totally: for example, untagged record types declared with the Finalizable aspect, the relaxed finalization semantics and inline Initialize/Adjust/Finalize primitives, and used with abort disabled: pragma Restrictions (No_Abort_Statements); pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); pragma Restrictions (No_Asynchronous_Control); should behave like simple C++ classes. The implementation morally boils down to undoing the changes made a few months ago to the support of finalization for controlled objects, i.e. to getting rid of the added linked list and the associated indirection for controlled objects with relaxed finalization semantics. But, in order to keep a unified processing for both kinds of controlled objects and not to bring back the issues addressed by the aforementioned changes, the work is split between the front-end and the code generator: the front-end drops the linked list and the code generator is in charge of eliminating the indirection with the help of the optimizer. gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst (Generalized Finalization): Update status. * einfo.ads (Has_Relaxed_Finalization): Add more details. * exp_ch4.adb (Process_Transients_In_Expression): Invoke Make_Finalize_Call_For_Node instead of building the call. * exp_ch5.adb (Expand_N_Assignment_Statement): Do not set up an exception handler around the assignment for a controlled type with relaxed finalization semantics. Streamline the code implementing the protection against aborts and do not use an At_End handler for a controlled type with relaxed finalization semantics. * exp_ch7.ads (Make_Finalize_Call_For_Node): New function. * exp_ch7.adb (Finalize_Address_For_Node): New function renaming. (Set_Finalize_Address_For_Node): New procedure renaming. (Attach_Object_To_Master_Node): Also attach the Finalize_Address primitive to the Master_Node statically. (Build_Finalizer): Add Has_Strict_Ctrl_Objs local variable. Insert back the body of the finalizer at the end of the statement list in the non-package case and restore the associated support code to that effect. When all the controlled objects have the relaxed finalization semantics, do not create a Finalization_Master and finalize the objects directly instead. (Processing_Actions): Add Strict parameter and use it to set the Has_Strict_Ctrl_Objs variable. (Process_Declarations): Make main loop more robust and adjust calls to Processing_Actions. (Make_Finalize_Address_Body): Mark the primitive as inlined if the type has relaxed finalization semantics. (Make_Finalize_Call_For_Node): New function. * sem_ch6.adb (Check_Statement_Sequence): Skip subprogram bodies. * libgnat/s-finpri.ads (Finalize_Object): Add Finalize_Address parameter. (Master_Node): Remove superfluous qualification. * libgnat/s-finpri.adb (Attach_Object_To_Node): Likewise. (Finalize_Master): Adjust calls to Finalize_Object. (Finalize_Object): Add Finalize_Address parameter and assert that it is equal to the component of the node. Use the Object_Address component as guard. (Suppress_Object_Finalize_At_End): Clear Object_Address component. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-08-01ada: Put back -G for binderArnaud Charlet4-1/+15
gcc/ada/ * bindgen.adb (Gen_Main): Put back support for -G * bindusg.adb (Display): Put back line for -G * opt.ads (CCG_Mode): Update doc * switch-b.adb (Scan_Binder_Switches): Put back support for -G
2024-08-01ada: exp_pakd.adb: disable packed expansions in CodePeer_ModeGhjuvan Lacambre1-0/+34
A previous commit disabled the removal of the Component_Size aspect from GNAT's tree when in CodePeer_Mode. This effectively resulted in CodePeer not ignoring Component_Size anymore. As a side effect, GNAT started expanding packed operations on array types from their high-level representations to operations operating on bits. It wasn't caught during the original testing, but this actually confuses CodePeer. We thus need to disable expansion of packed operations while in CodePeer_Mode. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Disable expansion in CodePeerMode. (Expand_Packed_Address_Reference): Likewise. (Expand_Packed_Bit_Reference): Likewise. (Expand_Packed_Boolean_Operator): Likewise. (Expand_Packed_Element_Reference): Likewise. (Expand_Packed_Eq): Likewise. (Expand_Packed_Not): Likewise.
2024-08-01ada: Check default value aspects before resolving their expressionsPiotr Trojanek1-112/+117
Check expressions of aspects Default_Value and Default_Component_Value for references to the annotated types just before resolving these expressions. This patch fixes both an asymmetry in processing of those aspects and adds a missing check in GNATprove on aspect Default_Component_Value. gcc/ada/ * sem_ch13.adb (Check_Aspect_Too_Late): Move routine to top-level. (Resolve_Aspect_Expressions): Check aspects Default_Value and Default_Component_Value before resolving their expressions.
2024-08-01ada: Fix freezing of Default_Value expressionsPiotr Trojanek1-2/+6
This patch fixes an infinite loop in freezing that occurred when expression of the Default_Value aspect includes a declare expression with an object of the annotated type. gcc/ada/ * sem_ch13.adb (Check_Aspect_Too_Late): Prevent freezing during preanalysis.
2024-08-01ada: Remove Must_Not_Freeze flags from default value expressionsPiotr Trojanek1-2/+0
This is a code cleanup and apparently has no impact on the behavior. The Must_Not_Freeze is saved/set/restored by Preanalyze_Spec_Expression, so it doesn't need to be set before calling that routine and apparently doesn't need to be set after that calling that routine either. gcc/ada/ * sem_ch13.adb (Resolve_Aspect_Expression): Don't set Must_Not_Freeze before preanalyzing spec expressions.
2024-08-01ada: Change "missing overriding indicator" message from error to warningSteve Baird1-2/+3
There is no RM rule requiring an overriding indicator in the case where this message is generated; such a rule was discussed many years ago in an AI, but that AI was never approved. So generate a warning message instead of an error message. And don't even do that if we are in an instance (warning a user they should change the source of an instance seems unlikely to be helpful, at least in this case). gcc/ada/ * sem_disp.adb (Check_Dispatching_Operation): When calling Error_Msg_NE to generate a "missing overriding indicator" message, generate a warning message instead of an error message (and update comment to describe this new behavior).
2024-08-01ada: Miscomputed bounds for inner null array aggregatesJavier Miranda1-4/+2
gcc/ada/ * sem_aggr.adb (Collect_Aggr_Bounds): Adjust previous patch to store the bounds of inner null aggregates in the itype; required generate the runtime check of ARM 4.3.3(30).
2024-08-01ada: Followup on previous change for -gnatcegArnaud Charlet3-198/+55
gcc/ada/ * osint-c.ads, osint-c.adb (Create_C_File, Close_C_File, Delete_C_File): Put back, needed by LLVM based CCG. * exp_unst.adb (Unnest_Subprogram): Complete previous change by removing now dead code and corresponding ??? comment.
2024-08-01ada: Missing adjust of controlled component initialized from container aggregateGary Dismukes1-2/+4
In the case of controlled components initialized by a container aggregate, the compiler was suppressing the call to the needed Adjust operation, because it was suppressed for all aggregates. But container aggregates aren't built in place, so target adjustment should still be done in that case. gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do the component adjustment in the case of initialization by a container aggregate.
2024-08-01ada: Fix internal error on limited aggregate in nested conditional expressionEric Botcazou2-35/+66
This is a fallout of an earlier fix to Is_Build_In_Place_Aggregate_Return that made it take into account intermediate conditional expressions, but turned out to work only for a single nesting level of them. The fix reuses the delayed expansion mechanism recently extended to deal with conditional expressions in a straightforward way. gcc/ada/ * exp_aggr.adb (Convert_To_Assignments): Set Expansion_Delayed on intermediate conditional expressions for BIP aggregate returns too. * exp_ch4.adb (Expand_N_Case_Expression): Also deal with delayed expansion in the return case. (Expand_N_If_Expression): Likewise.
2024-08-01ada: Operator visibility bug in static expression functionsSteve Baird1-0/+1
In some cases, an expanded name refering to a predefined operator (such as Some_Package."+") occurring in a static expression function would be incorrectly rejected with a message saying that the operator is not directly visible (which, while True, does not make the reference illegal). gcc/ada/ * sem_ch4.adb (Is_Effectively_Visible_Opertor): Return True if Checking_Potentially_Static_Expression is True. The accompanying comment says True is returned "if there is a reason it is ok for Is_Visible_Operator to return False"; if Checking_Potentially_Static_Expression is true, that is such a reason.
2024-08-01ada: Stop ignoring Component_Size attribute in CodePeer_ModeGhjuvan Lacambre1-18/+0
This piece of code was introduced in 2011 in order to prevent spurious false positives from appearing on specific code patterns making use of Component_Size. It seems that now this piece of code is causing small false positives instead of preventing them, so let's remove it. gcc/ada/ * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Stop ignoring Component_Size attribute in CodePeer_Mode.
2024-08-01ada: Fix test for wrapping loop parameter specRonan Desplanques1-10/+6
This patches fixes a problem where cleanup statements would be missing for some cases of loop parameter specifications that allocate on the secondary stack. gcc/ada/ * sem_ch5.adb (Prepare_Param_Spec_Loop): Fix criterion for wrapping loop statements into blocks.
2024-08-01ada: Remove support for bodies in -gnatcegArnaud Charlet37-2230/+267
The support for generating C for Ada code is moved to GNAT LLVM. Keep support for generating header files from Ada spec files which is the remaining usage of -gnatceg. gcc/ada/ * bindgen.adb, bindusg.adb, debug.adb, einfo.ads, exp_aggr.adb, exp_attr.adb, exp_ch11.adb, exp_ch3.adb, exp_ch4.adb, exp_ch6.adb, exp_ch7.adb, exp_ch8.adb, exp_dbug.adb, exp_dbug.ads, exp_intr.adb, exp_unst.adb, exp_util.adb, exp_util.ads, freeze.adb, gen_il-fields.ads, gen_il-gen-gen_entities.adb, gnat1drv.adb, inline.adb, opt.ads, osint-c.adb, osint-c.ads, sem_attr.adb, sem_ch12.adb, sem_ch3.adb, sem_ch4.adb, sem_ch6.adb, sem_elab.adb, sem_res.adb, sinfo.ads, snames.ads-tmpl, switch-b.adb, switch-c.adb: Major clean up to remove C code generation for bodies.
2024-08-01ada: Allow making empty aggregates positionalRonan Desplanques4-19/+57
This patch makes Exp_Aggr.Convert_To_Positional accepts appropriate empty aggregates. The end goal is to remove violations of the No_Elaboration_Code restriction in some cases of library-level array objects. gcc/ada/ * exp_aggr.adb (Flatten): Do not reject empty aggregates. Adjust criterion for emitting warning about ineffective others clause. * sem_aggr.adb (Array_Aggr_Subtype): Fix typo. Add handling of aggregates that were converted to positional form. (Resolve_Aggregate): Tweak criterion for transforming into a string literal. (Resolve_Array_Aggregate): Tweak criterion for reusing existing bounds of aggregate. (Retrieve_Aggregate_Bounds): New procedure. * sem_util.adb (Has_Static_Empty_Array_Bounds): New function. * sem_util.ads (Has_Static_Empty_Array_Bounds): Likewise.
2024-08-01ada: Couple of cleanups in finalization machineryEric Botcazou3-41/+25
This removes a parameter and a variable that are entirely determined by another parameter and another variable respectively. gcc/ada/ * exp_ch7.ads (Build_Finalizer): Remove Top_Decls parameter. * exp_ch7.adb (Build_Finalizer): Likewise. Rename Counter_Val into Count, replace Has_Ctrl_Objs local variable by expression function, remove Spec_Decls local variable and do not reset Finalizer_Decls. (Expand_Cleanup_Actions): Adjust call to Build_Finalizer. (Expand_N_Package_Body): Likewise. (Expand_N_Package_Declaration): Likewise. * inline.adb (Cleanup_Scopes): Likewise.
2024-08-01ada: Remove obsolete workaroundEric Botcazou4-37/+21
It is possible to call the "+" operator of System.Storage_Elements directly as done for example in Expand_Interface_Thunk. gcc/ada/ * exp_ch7.adb (Make_Address_For_Finalize): Generate a direct call to the "+" operator of System.Storage_Elements. (Make_Finalize_Address_Stmts): Likewise. * rtsfind.ads (RE_Id): Remove RE_Add_Offset_To_Address. (RE_Unit_Table): Remove entry for RE_Add_Offset_To_Address. * libgnat/s-finpri.ads (Add_Offset_To_Address): Delete. * libgnat/s-finpri.adb (Add_Offset_To_Address): Likewise.
2024-07-08Daily bump.GCC Administrator1-0/+7
2024-07-07ada: Make the names of uninstalled cross-gnattools consistent across buildsMaciej W. Rozycki1-7/+12
We suffer from an inconsistency in the names of uninstalled gnattools executables in cross-compiler configurations. The cause is a recipe we have: ada.all.cross: for tool in $(ADA_TOOLS) ; do \ if [ -f $$tool$(exeext) ] ; \ then \ $(MV) $$tool$(exeext) $$tool-cross$(exeext); \ fi; \ done the intent of which is to give the names of gnattools executables the '-cross' suffix, consistently with the compiler drivers: 'gcc-cross', 'g++-cross', etc. A problem with the recipe is that this 'make' target is called too early in the build process, before gnattools have been made. Consequently no renames happen and owing to that they are conditional on the presence of the individual executables the recipe succeeds doing nothing. However if a target is requested later on such as 'make pdf' that does not cause gnattools executables to be rebuilt, then 'ada.all.cross' does succeed in renaming the executables already present in the build tree. Then if the 'gnat' testsuite is run later on which expects non-suffixed 'gnatmake' executable, it does not find the 'gnatmake-cross' executable in the build tree and may either catastrophically fail or incorrectly use a system-installed copy of 'gnatmake'. Of course if a target is requested such as `make all' that does cause gnattools executables to be rebuilt, then both suffixed and non-suffixed uninstalled executables result. Fix the problem by moving the renaming of gnattools to a separate 'make' recipe, pasted into a new 'gnattools-cross-mv' target and the existing legacy 'cross-gnattools' target. Then invoke the new target explicitly from the 'gnattools-cross' recipe in gnattools/. Update the test harness accordingly, so that suffixed gnattools are used in cross-compilation testsuite runs. gcc/ada/ * gcc-interface/Make-lang.in (ada.all.cross): Move recipe to... (GNATTOOLS_CROSS_MV): ... this new variable. (cross-gnattools): Paste it here. (gnattools-cross-mv): New target. gnattools/ * Makefile.in (gnattools-cross): Also build 'gnattools-cross-mv' in GCC_DIR. gcc/testsuite/ * lib/gnat.exp (local_find_gnatmake, find_gnatclean): Use '-cross' suffix where testing a cross-compiler.
2024-07-04Daily bump.GCC Administrator1-0/+25
2024-07-03Deduplicate explicitly-sized typesAlexandre Oliva2-6/+113
When make_type_from_size is called with a biased type, for an entity that isn't explicitly biased, we may refrain from reusing the given type because it doesn't seem to match, and then proceed to create an exact copy of that type. Compute earlier the biased status of the expected type, early enough for the suitability check of the given type. Modify for_biased instead of biased_p, so that biased_p remains with the given type's status for the comparison. Avoid creating unnecessary copies of types in make_type_from_size, by caching and reusing previously-created identical types, similarly to the caching of packable types. While at that, fix two vaguely related issues: - TYPE_DEBUG_TYPE's storage is shared with other sorts of references to types, so it shouldn't be accessed unless TYPE_CAN_HAVE_DEBUG_TYPE_P holds. - When we choose the narrower/packed variant of a type as the main debug info type, we fail to output its name if we fail to follow debug type for the TYPE_NAME decl type in modified_type_die. for gcc/ada/ChangeLog * gcc-interface/misc.cc (gnat_get_array_descr_info): Only follow TYPE_DEBUG_TYPE if TYPE_CAN_HAVE_DEBUG_TYPE_P. * gcc-interface/utils.cc (sized_type_hash): New struct. (sized_type_hasher): New struct. (sized_type_hash_table): New variable. (init_gnat_utils): Allocate it. (destroy_gnat_utils): Release it. (sized_type_hasher::equal): New. (hash_sized_type): New. (canonicalize_sized_type): New. (make_type_from_size): Use it to cache packed variants. Fix type reuse by combining biased_p and for_biased earlier. Hold the combination in for_biased, adjusting later uses. for gcc/ChangeLog * dwarf2out.cc (modified_type_die): Follow name's debug type. for gcc/testsuite/ChangeLog * gnat.dg/bias1.adb: Count occurrences of -7.*DW_AT_GNU_bias.
2024-07-03[debug] Avoid dropping bits from num/den in fixed-point typesAlexandre Oliva2-21/+64
We used to use an unsigned 128-bit type to hold the numerator and denominator used to represent the delta of a fixed-point type in debug information, but there are cases in which that was not enough, and more significant bits silently overflowed and got omitted from debug information. Introduce a mode in which UI_to_gnu selects a wide-enough unsigned type, and use that to convert numerator and denominator. While at that, avoid exceeding the maximum precision for wide ints, and for available int modes, when selecting a type to represent very wide constants, falling back to 0/0 for unrepresentable fractions. for gcc/ada/ChangeLog * gcc-interface/cuintp.cc (UI_To_gnu): Add mode that selects a wide enough unsigned type. Fail if the constant exceeds the representable numbers. * gcc-interface/decl.cc (gnat_to_gnu_entity): Use it for numerator and denominator of fixed-point types. In case of failure, fall back to an indeterminate fraction.
2024-07-03Daily bump.GCC Administrator1-0/+109
2024-07-02ada: Use static allocation for small dynamic string concatenations in more casesEric Botcazou1-24/+67
This lifts the limitation of the original implementation whereby the first operand of the concatenation needs to have a length known at compiled time in order for the static allocation to be used. gcc/ada/ * exp_ch4.adb (Expand_Concatenate): In the case where an operand does not have both bounds known at compile time, use nevertheless the low bound directly if it is known at compile time. Fold the conditional expression giving the low bound of the result in the general case if the low bound of all the operands are equal.
2024-07-02ada: Fix generic renaming table low bound on resetRonan Desplanques1-1/+1
gcc/ada/ * sem_ch12.adb (Save_And_Reset): Fix value of low bound used to reset table.
2024-07-02ada: Compiler accepts an illegal Unchecked_Access attribute referenceSteve Baird1-0/+7
The compiler incorrectly accepts Some_Object'Unchecked_Access'Image. gcc/ada/ * sem_attr.adb (Analyze_Image_Attribute.Check_Image_Type): Check for E_Access_Attribute_Type prefix type.
2024-07-02ada: Use clause (or use type clause) in a protected operation sometimes ignored.Steve Baird1-0/+41
In some cases, a use clause (or a use type clause) occurring within a protected operation is incorrectly ignored. gcc/ada/ * exp_ch9.adb (Expand_N_Protected_Body): Declare new procedure Unanalyze_Use_Clauses and call it before analyzing the newly constructed subprogram body.
2024-07-02ada: Put_Image aspect spec ignored for null extension.Steve Baird1-1/+16
If type T1 is is a tagged null record with a Put_Image aspect specification and type T2 is a null extension of T1 (with no aspect specifications), then evaluation of a T2'Image call should include a call to the specified procedure (as opposed to yielding "(NULL RECORD)"). gcc/ada/ * exp_put_image.adb (Build_Record_Put_Image_Procedure): Declare new Boolean-valued function Null_Record_Default_Implementation_OK; call it as part of deciding whether to generate "(NULL RECORD)" text.
2024-07-02ada: Allow mutably tagged types to work with qualified expressionsJustin Squirek1-0/+14
This patch modifies the experimental 'Size'Class feature such that objects of mutably tagged types can be assigned qualified expressions featuring a definite type (e.g. Mutable_Obj := Root_Child_T'(Root_T with others => <>)). gcc/ada/ * sem_ch5.adb: (Analyze_Assignment): Add special expansion for qualified expressions in certain cases dealing with mutably tagged types.
2024-07-02ada: Bug box for expression function with list comprehensionBob Duff1-0/+1
GNAT crashes on an iterator with a filter inside an expression function that is the completion of an earlier spec. gcc/ada/ * freeze.adb (Freeze_Type_Refs): If Node is in N_Has_Etype, check that it has had its Etype set, because this can be called early for expression functions that are completions.