aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2023-06-21Daily bump.GCC Administrator1-0/+220
2023-06-20ada: Minor tweaksEric Botcazou1-8/+6
gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Pass the NULL_TREE explicitly and test imported_p in lieu of Is_Imported. <E_Function>: Remove public_flag local variable and make extern_flag local variable a constant.
2023-06-20ada: Fix crash on inlining in GNATproveYannick Moy1-0/+9
After the recent change on detection of non-inlining, calls inside the iterator part of a quantified expression were not considered as preventing inlining anymore, leading to a crash later on inside GNATprove. Now fixed. gcc/ada/ * sem_res.adb (Resolve_Call): Fix change that replaced test for quantified expressions by the test for potentially unevaluated contexts. Both should be performed.
2023-06-20ada: Further fixes to handling of private views in instancesEric Botcazou9-237/+219
This removes more bypasses for private views in instances that are present in type predicates (Conforming_Types, Covers, Specific_Type and Wrong_Type), which in exchange requires additional work in Sem_Ch12 to restore the proper view of types during the instantiation of generic bodies. The main mechanism for this is the Has_Private_View flag, but it comes with the limitations that 1) there must be a direct reference to the global type in the generic construct (either a reference to a global object of this type or the explicit declaration of a local object of this type), which is not always the case e.g. for loop parameters and 2) it can deal with a single type at a time, e.g. it cannot deal with an array type and its component type if their respective views are not the same in the instance. To overcome the second limitation, a new Has_Secondary_Private_View flag is introduced to deal with a secondary type, which as of this writing is either the component type of an array type or the designated type of an access type (together they make up the vast majority of the problematic cases for the Has_Private_View flag alone). This new mechanism subsumes a specific treatment for them that was added in Copy_Generic_Node a few years ago, although a specific treatment still needs to be preserved for comparison and equality operators in a narrower case. Additional handling is also introduced to overcome the first limitation for loop parameters in Copy_Generic_Node, and a relaxed condition is used in Exp_Ch7.Convert_View to generate an unchecked conversion between views. gcc/ada/ * exp_ch7.adb (Convert_View): Detect more cases of mismatches for private types and use Implementation_Base_Type as main criterion. * gen_il-fields.ads (Opt_Field_Enum): Add Has_Secondary_Private_View * gen_il-gen-gen_nodes.adb (N_Expanded_Name): Likewise. (N_Direct_Name): Likewise. (N_Op): Likewise. * sem_ch12.ads (Check_Private_View): Document the usage of second flag Has_Secondary_Private_View. * sem_ch12.adb (Get_Associated_Entity): New function to retrieve the ultimate associated entity, if any. (Check_Private_View): Implement Has_Secondary_Private_View support. (Copy_Generic_Node): Remove specific treatment for Component_Type of an array type and Designated_Type of an access type. Add specific treatment for comparison and equality operators, as well as iterator and loop parameter specifications. (Instantiate_Type): Implement Has_Secondary_Private_View support. (Requires_Delayed_Save): Call Get_Associated_Entity. (Set_Global_Type): Implement Has_Secondary_Private_View support. * sem_ch6.adb (Conforming_Types): Remove bypass for private views in instances. * sem_type.adb (Covers): Return true if Is_Subtype_Of does so. Remove bypass for private views in instances. (Specific_Type): Likewise. * sem_util.adb (Wrong_Type): Likewise. * sinfo.ads (Has_Secondary_Private_View): Document new flag.
2023-06-20ada: Remove outdated commentRonan Desplanques1-4/+0
The Preelaborate pragma the removed comment was referring to was indeed present in AI 167, as well as in clause 5.3 of the rationale for Ada 2012, but it never made it into the 2012 version of the reference manual. gcc/ada/ * libgnarl/s-mudido.ads: Remove outdated comment.
2023-06-20ada: Fix couple of issues in documentation of overflow checkingEric Botcazou2-46/+7
There is still a mention of the defunct CHECKED mode and the Default Settings paragraph is confusing with regard to the -gnato switch. gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst (Overflows in GNAT) <Default Settings>: Remove obsolete paragraph about -gnato. <Implementation Notes>: Replace CHECKED with STRICT. * gnat_ugn.texi: Regenerate.
2023-06-20ada: Do not issue warning on postcondition in some casesYannick Moy1-0/+32
Warning on suspicious postcondition is not relevant if contract Exceptional_Cases is present, or if contract Always_Terminates is present with a non-statically True value, as in those cases the postcondition can be used to indicate constraints on those pre-state for which the subprogram might terminate normally. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Do not warn in cases where the warning could be spurious.
2023-06-20ada: Add the ability to add error codes to error messagesYannick Moy9-21/+134
Add a new character sequence [] for error codes in error messages handled by Error_Msg procedures, to use for SPARK-related errors. Display of additional information on the error or warning based on the error code is delegated to GNATprove. gcc/ada/ * err_vars.ads (Error_Msg_Code): New variable for error codes. * errout.adb (Error_Msg_Internal): Display continuation message when an error code was present. (Set_Msg_Text): Handle character sequence [] for error codes. * errout.ads: Document new insertion sequence []. (Error_Msg_Code): New renaming. * erroutc.adb (Prescan_Message): Detect presence of error code. (Set_Msg_Insertion_Code): Handle new insertion sequence []. * erroutc.ads (Has_Error_Code): New variable for prescan. (Set_Msg_Insertion_Code): Handle new insertion sequence []. * contracts.adb (Check_Type_Or_Object_External_Properties): Replace reference to SPARK RM section by an error code. * sem_elab.adb (SPARK_Processor): Same. * sem_prag.adb (Check_Missing_Part_Of): Same. * sem_res.adb (Resolve_Actuals, Resolve_Entity_Name): Same.
2023-06-20ada: Fix for attribute Range in Exceptional_CasesPiotr Trojanek1-1/+2
Attribute Range is now handled like First and Last when occurring within the consequence of Exceptional_Cases, i.e. attribute Range is not considered to be a read of a formal parameter that would not be allowed in the contract. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Handle Range like First and Last.
2023-06-20ada: Document partition-wide Ada signal handlersJose Ruiz2-305/+414
Indicate the signal handlers that are set by the Ada run time, and explain how to prevent them if needed. gcc/ada/ * doc/gnat_ugn/the_gnat_compilation_model.rst (Partition-Wide Settings): add this subsection to document configuration settings made by the Ada run time. * gnat_ugn.texi: Regenerate.
2023-06-20ada: Fix for quantified expressions in Exceptional_CasesPiotr Trojanek1-1/+1
When detecting illegal uses of formal parameters of the current subprogram in contract of its Exceptional_Cases, we relied on the Current_Scope. However, quantified expressions introduce an implicit scope, which we need to take into account. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Ignore implicit loop scopes introduced by quantified expressions.
2023-06-20ada: Fix bug in predicate checks with address clausesBob Duff2-8/+10
This patch fixes a compiler bug triggered by having a type with some defaulted components, and a predicate, and an object of that type with an address clause. In this case, the compiler was crashing. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Remove predicate-check generation if there is an address clause. These are unnecessary, and cause gigi to crash. * exp_util.ads (Following_Address_Clause): Remove obsolete "???" comments. The suggested changes were done long ago.
2023-06-20ada: Fix fallout of fix to handling of private views in instancesEric Botcazou2-2/+4
Check_Actual_Type incorrectly switches the view of a private type declared in the enclosing scope of a generic unit but that has a private ancestor. gcc/ada/ * einfo.ads (Has_Private_Ancestor): Fix inaccuracy in description. * sem_ch12.adb (Check_Actual_Type): Do not switch the view of the type if it has a private ancestor.
2023-06-20ada: Add CHERI intrinsic bindings and helper functions.Daniel King2-0/+545
The package Interfaces.CHERI provides intrinsic bindings and helper functions to allow software to query, create, and manipulate CHERI capabilities. gcc/ada/ * libgnat/i-cheri.ads: Add CHERI intrinsics and helper functions. * libgnat/i-cheri.adb: Likewise
2023-06-20ada: Small fixes to handling of private views in instancesEric Botcazou4-91/+92
The main change is the removal of the special bypass for private views in Resolve_Implicit_Dereference, which in exchange requires additional work in Check_Generic_Actuals and a couple more calls to Set_Global_Type in Save_References_In_Identifier. This also removes an unused parameter in Convert_View and adds a missing comment in Build_Derived_Record_Type. gcc/ada/ * exp_ch7.adb (Convert_View): Remove Ind parameter and adjust. * sem_ch12.adb (Check_Generic_Actuals): Check the type of both in and in out actual objects, as well as the type of formal parameters of actual subprograms. Extend the condition under which the views are swapped to nested generic constructs. (Save_References_In_Identifier): Call Set_Global_Type on a global identifier rewritten as an explicit dereference, either directly or after having first been rewritten as a function call. (Save_References_In_Operator): Set N2 unconditionally and reuse it. * sem_ch3.adb (Build_Derived_Record_Type): Add missing comment. * sem_res.adb (Resolve_Implicit_Dereference): Remove special bypass for private views in instances.
2023-06-20ada: Fix internal error on aggregate within container aggregateEric Botcazou1-7/+9
This just applies the same fix to Expand_Array_Aggregate as the one that was recently applied to Convert_To_Assignments. gcc/ada/ * exp_aggr.adb (Convert_To_Assignments): Tweak comment. (Expand_Array_Aggregate): Do not delay the expansion if the parent node is a container aggregate.
2023-06-20ada: Fix -fdiagnostics-format=json not printing all messagesGhjuvan Lacambre1-9/+12
The previous version of this code stopped printing messages as soon as it encountered a deleted or continuation message. This was wrong, continuation and deleted messages can be followed by live messages that do need to be printed. gcc/ada/ * errout.adb (Output_Messages): Fix loop termination condition.
2023-06-20ada: Introduce -gnateH switch to force reverse Bit_Order threshold to 64Eric Botcazou6-2/+40
This can be helpful for legacy code that still makes use of an original reverse Bit_Order clause, i.e. without a Scalar_Storage_Order clause. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler Switches): Document -gnateH. * opt.ads (Reverse_Bit_Order_Threshold): New variable. * sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Use its value if it is nonnegative instead of System_Max_Integer_Size. * switch-c.adb (Scan_Front_End_Switches): Deal with -gnateH. * usage.adb (Usage): Print -gnateH. * gnat_ugn.texi: Regenerate.
2023-06-20ada: Update annotations in runtime for proofYannick Moy3-1/+15
With bump of stable SPARK used for proof of the runtime, some annotations need to change. gcc/ada/ * libgnat/s-aridou.adb (Scaled_Divide): Add assertions. * libgnat/s-valuti.adb: Add Loop_Variant. * libgnat/s-valuti.ads: Add Exceptional_Cases on No_Return procedure.
2023-06-20ada: Fix type derivation of subtype of derived typeMarc Poulhiès1-3/+33
Deriving from a subtype of a derived type of a private type, whose full view is itself a derived type of a discriminated record with a known discriminatant was failing with the error message: invalid constraint: type has no discriminant The compiler needs to use the full view to be able to constrain the type. Also fix minor typo in comments. gcc/ada/ * sem_ch3.adb (Build_Derived_Record_Type): Use full view as Parent_Base if needed.
2023-06-20ada: Pass Error_Node to calls to Error_Msg in lib-load.adbGhjuvan Lacambre1-8/+23
When not passing Error_Node, Error_Msg will treat Current_Node as the node attached to the message. When this happens in lib-load.adb due to a file that cannot be loaded, Current_Node might reference a node that doesn't actually exist. This is a problem when using -gnatdJ and -fdiagnostics-format, as in this case GNAT will attempt to retrieve information from the node attached to the message and thus crash when said node is invalid. gcc/ada/ * lib-load.adb (Load_Unit): Pass Error_Node to calls to Error_Msg.
2023-06-20ada: Remove references to Might_Not_Return and Always_ReturnClaire Dross36-461/+395
The Might_Not_Return and Always_Return annotations for GNATprove should now be replaced by the two more precise aspects Exceptional_Cases and Always_Terminates. They allow to specify whether a subprogram is allowed to raise exceptions or fail to complete. gcc/ada/ * libgnat/a-strfix.ads: Replace Might_Not_Return annotations by Exceptional_Cases and Always_Terminates aspects. * libgnat/a-tideio.ads: Idem. * libgnat/a-tienio.ads: Idem. * libgnat/a-tifiio.ads: Idem. * libgnat/a-tiflio.ads: Idem. * libgnat/a-tiinio.ads: Idem. * libgnat/a-timoio.ads: Idem. * libgnat/a-textio.ads: Idem. Also mark functions Name, Col, Line, and Page as out of SPARK as they might raise Layout_Error. * libgnarl/a-reatim.ads: Replace Always_Return annotations by Always_Terminates aspects. * libgnat/a-chahan.ads: Idem. * libgnat/a-nbnbig.ads: Idem. * libgnat/a-nbnbin.ads: Idem. * libgnat/a-nbnbre.ads: Idem. * libgnat/a-ngelfu.ads: Idem. * libgnat/a-nlelfu.ads: Idem. * libgnat/a-nllefu.ads: Idem. * libgnat/a-nselfu.ads: Idem. * libgnat/a-nuelfu.ads: Idem. * libgnat/a-strbou.ads: Idem. * libgnat/a-strmap.ads: Idem. * libgnat/a-strsea.ads: Idem. * libgnat/a-strsup.ads: Idem. * libgnat/a-strunb.ads: Idem. * libgnat/a-strunb__shared.ads: Idem. * libgnat/g-souinf.ads: Idem. * libgnat/i-c.ads: Idem. * libgnat/interfac.ads: Idem. * libgnat/interfac__2020.ads: Idem. * libgnat/s-aridou.adb: Idem. * libgnat/s-arit32.adb: Idem. * libgnat/s-atacco.ads: Idem. * libgnat/s-spcuop.ads: Idem. * libgnat/s-stoele.ads: Idem. * libgnat/s-vaispe.ads: Idem. * libgnat/s-vauspe.ads: Idem. * libgnat/i-cstrin.ads: Add a precondition instead of a Might_Not_Return annotation.
2023-06-20ada: Spurious error on package instantiationJavier Miranda1-101/+146
The compiler reports spurious errors processing the instantation of a generic package when the instantation is performed in the the body of a package that has a private type T, a dispatching primitive of T has the same name as a component of T, and an extension of T is used as the actual parameter for a formal derived type of T in the instantiation. gcc/ada/ * sem_ch4.adb (Try_Selected_Component_In_Instance): New subprogram; factorizes existing code. (Find_Component_In_Instance) Moved inside the new subprogram. (Analyze_Selected_Component): Invoke the new subprogram before trying the Object.Operation notation.
2023-06-20ada: Fix edge case in Ada.Calendar.Formatting.Time_OfRonan Desplanques1-28/+3
Before this patch, Ada.Calendar.Formatting.Time_Of executed extra code when passed a number of seconds equal to the number of seconds in a day. This caused the result to be off, perhaps because a statement resetting the number of seconds to zero was missing. Instead of adding such a statement, this patch removes the special handling of the problematic case, which gives the intended result. gcc/ada/ * libgnat/a-calfor.adb (Time_Of): Fix handling of special case.
2023-06-16Daily bump.GCC Administrator1-0/+174
2023-06-15configure: Implement --enable-host-pieMarek Polacek2-7/+9
[ This is my third attempt to add this configure option. The first version was approved but it came too late in the development cycle. The second version was also approved, but I had to revert it: <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>. I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer need to touch Makefile.def, so this patch is simplified. ] This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s won't add -shared to the linker flags whereas --e-h-p will add -pie. It is different from --enable-default-pie because that option just adds an implicit -fPIE/-pie when the compiler is invoked, but the compiler itself isn't PIE. Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH regressions. When building the compiler, the build process may use various in-tree libraries; these need to be built with -fPIE so that it's possible to use them when building a PIE. For instance, when --with-included-gettext is in effect, intl object files must be compiled with -fPIE. Similarly, when building in-tree gmp, isl, mpfr and mpc, they must be compiled with -fPIE. With this patch and --enable-host-pie used to configure gcc: $ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1 gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped I plan to add an option to link with -Wl,-z,now. Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext --enable-host-pie as well as without --enable-host-pie. Also tested on a Debian system where the system gcc was configured with --enable-default-pie. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> ChangeLog: * configure.ac (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. c++tools/ChangeLog: * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it. Use pic/libiberty.a if PICFLAG is set. * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG. (--enable-host-pie): New check. * configure: Regenerate. fixincludes/ChangeLog: * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic" build of libiberty if PICFLAG is set. * configure.ac: * configure: Regenerate. gcc/ChangeLog: * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie. Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. * doc/install.texi: Document --enable-host-pie. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o. * gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set. Remove NO_PIE_FLAG. gcc/m2/ChangeLog: * Make-lang.in: New var, GM2_PICFLAGS. Use it. gcc/d/ChangeLog: * Make-lang.in: Remove NO_PIE_CFLAGS. intl/ChangeLog: * Makefile.in: Use @PICFLAG@ in COMPILE as well. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libcody/ChangeLog: * Makefile.in: Pass LD_PICFLAG to LDFLAGS. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. libcpp/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libdecnumber/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libiberty/ChangeLog: * configure.ac: Also set shared when enable_host_pie. * configure: Regenerate. zlib/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate.
2023-06-15ada: Remove unused filesMarc Poulhiès6-28/+0
gcc/ada/ChangeLog: * vxworks7-cert-rtp-base-link.spec: Removed. * vxworks7-cert-rtp-base-link__ppc64.spec: Removed. * vxworks7-cert-rtp-base-link__x86.spec: Removed. * vxworks7-cert-rtp-base-link__x86_64.spec: Removed. * vxworks7-cert-rtp-link.spec: Removed. * vxworks7-cert-rtp-link__ppcXX.spec: Removed.
2023-06-15ada: Fix wrong code for ACATS cd1c03i on Morello targetEric Botcazou1-2/+6
gcc/ada/ * gcc-interface/utils2.cc (build_binary_op) <MODIFY_EXPR>: Do not remove a VIEW_CONVERT_EXPR on the LHS if it is also on the RHS.
2023-06-15ada: Fix wrong finalization for double subtype of bounded vectorEric Botcazou1-4/+10
The special handling of temporaries created for return values and subject to a renaming needs to be restricted to the top level, where it is needed to prevent dangling references to the frame of the elaboration routine from being created, because, at a lower level, the front-end may create implicit renamings of objects as these temporaries, so a copy is not allowed. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Restrict the special handling of temporaries created for return values and subject to a renaming to the top level.
2023-06-15ada: Make minor improvements to user's guideRonan Desplanques3-37/+36
gcc/ada/ * doc/gnat_ugn/about_this_guide.rst: Fix typo. Uniformize punctuation. * doc/gnat_ugn/the_gnat_compilation_model.rst: Uniformize punctuation. Fix capitalization. Fix indentation of code block. Fix RST formatting syntax errors. * gnat_ugn.texi: Regenerate.
2023-06-15ada: Reject Loop_Entry inside prefix of Loop_EntryYannick Moy1-3/+18
This rule was incompletely stated in SPARK RM and not checked. This is now fixed. gcc/ada/ * sem_attr.adb (Analyze_Attribute): Reject case of Loop_Entry inside the prefix of Loop_Entry, as per SPARK RM 5.5.3.1(4,8).
2023-06-15ada: Fix too small secondary stack allocation for returned conversionEric Botcazou2-30/+63
The previous fix did not address a latent issue whereby the allocation would be made using the (static) subtype of the conversion instead of the (dynamic) subtype of the return object, so this change rewrites the code responsible for determining the type used for the allocation, and also contains a small improvement to the Has_Tag_Of_Type predicate. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_Return): Rewrite the logic that determines the type used for the allocation and add assertions. * exp_util.adb (Has_Tag_Of_Type): Also return true for extension aggregates.
2023-06-15ada: Fix internal error on loop iterator filter with -gnatVaEric Botcazou3-4/+13
The problem is that the condition of the iterator filter is expanded early, before it is integrated into an if statement of the loop body, so there is no place to attach the actions generated by this expansion. This happens only for simple loops, i.e. with a parameter specification, so the fix uses the same approach for them as for loops based on iterators. gcc/ada/ * sinfo.ads (Iterator_Filter): Document field. * sem_ch5.adb (Analyze_Iterator_Specification): Move comment around. (Analyze_Loop_Parameter_Specification): Only preanalyze the iterator filter, if any. * exp_ch5.adb (Expand_N_Loop_Statement): Analyze the new list built when an iterator filter is present.
2023-06-15ada: Revert latest change to Find_Hook_ContextEric Botcazou1-10/+0
The issue is that, if an aggregate is both below a conditional expression and above another conditional expression in the tree, we have currently no place to put the finalization actions generated by the innermost expression in the context of the aggregate before it is expanded, so they end up being placed after the outermost expression. But it is not clear whether that's really problematic because this does not seem to happen for array aggregates with multiple or others choices: in this case the aggregate is expanded first and the code path is not taken. gcc/ada/ * exp_util.adb (Find_Hook_Context): Revert latest change.
2023-06-15ada: Fix too small secondary stack allocation for returned aggregateEric Botcazou1-3/+14
This restores the specific treatment of aggregates that are returned through an extended return statement in a function returning a class-wide type, and which was incorrectly dropped in an earlier change. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_Return): Deal again specifically with an aggregate returned through an object of a class-wide type.
2023-06-15ada: Remove dead code in Expand_Iterator_Loop_Over_ContainerEric Botcazou1-13/+4
The Condition_Actions field can only be populated for while loops. gcc/ada/ * exp_ch5.adb (Expand_Iterator_Loop_Over_Container): Do not insert an always empty list. Remove unused parameter Isc. (Expand_Iterator_Loop): Adjust call to above procedure.
2023-06-15ada: Add escape hatch to configurable run-timeRonan Desplanques2-0/+12
Before this patch, the fact that Restrictions pragmas had to fit on a single line in system.ads was difficult to reconcile with the 80-character line limit that is enforced in that file. The special rules for pragmas in system.ads made it impossible to us the Style_Checks pragma to allow long Restrictions pragmas. This patch relaxes those rules so the Style_Checks pragma can be used in system.ads. gcc/ada/ * targparm.adb: Allow pragma Style_Checks in some forms. * targparm.ads: Document new pragma permission.
2023-06-15ada: Fix missing finalization for aggregates nested in conditional expressionsEric Botcazou2-1/+23
The finalization actions for the components of the aggregates are blocked by Expand_Ctrl_Function_Call, which sets Is_Ignored_Transient on all the temporaries generated from within a conditional expression whatever the intermediate constructs. Now aggregates and their expansion in the form of block and loop statements are "impenetrable" as far as temporaries are concerned, i.e. the lifetime of temporaries generated within them does not extend beyond them, so their finalization must not be blocked there. gcc/ada/ * exp_util.ads (Within_Case_Or_If_Expression): Adjust description. * exp_util.adb (Find_Hook_Context): Stop the search for the topmost conditional expression, if within one, at contexts where temporaries may be contained. (Within_Case_Or_If_Expression): Return false upon first encoutering contexts where temporaries may be contained.
2023-06-15ada: Adjust QNX Ada priorities to match QNX system prioritiesJohannes Kliemann2-9/+7
The Ada priority range of the QNX runtime started from 0, differing from the QNX system priorities range starting from 1. As this may cause confusion, especially if used in a mixed language environment, the Ada priority range now starts at 1. The default priority of Ada tasks as mandated is the middle of the priority range. On QNX this means the default priority of Ada tasks is 30. This is much higher than the default QNX priority of 10 and may cause unexpected system interruptions when Ada tasks take a lot of CPU time. gcc/ada/ * libgnarl/s-osinte__qnx.adb: Adjust priority conversion function. * libgnat/system-qnx-arm.ads: Adjust priority range and default priority.
2023-06-15ada: Adjust comments in targparm.adsRonan Desplanques1-20/+5
This patch removes a few dangling references to the late front-end implementation of exceptions from the comments of targparm.ads, and also fixes a thinko there. gcc/ada/ * targparm.ads: Remove references to front-end-based exceptions. Fix thinko.
2023-06-15ada: Accept aspect Always_Terminates on packagesPiotr Trojanek2-2/+21
The recently added aspect Always_Terminates is now allowed on packages and generic packages, but only when it has no arguments. The intuitive meaning is that all subprograms declared in such a package are always terminating. gcc/ada/ * contracts.adb (Add_Contract_Item): Add pragma Always_Terminates to package contract. * sem_prag.adb (Analyze_Pragma): Accept pragma Always_Terminates on packages and generic packages, but only when it has no arguments.
2023-06-15ada: Accept aspect Always_Terminates on entriesPiotr Trojanek1-0/+5
The recently added aspect Always_Terminates is allowed on both procedures and entries. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Accept pragma Always_Terminates when it applies to an entry.
2023-06-15ada: Reject aspect Always_Terminates on functions and generic functionsPiotr Trojanek1-0/+13
The recently added aspect Always_Terminates is only allowed on procedures. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Reject pragma Always_Terminates when it applies to a function or generic function.
2023-06-15ada: Fix missing error on function call returning incomplete viewEric Botcazou1-0/+6
Testing for the presence of Non_Limited_View is not sufficient to detect whether the nonlimited view has been analyzed because Build_Limited_Views always sets the field on the limited view. Instead the discriminant is whether this nonlimited view is itself an incomplete type. gcc/ada/ * sem_ch4.adb (Analyze_Call): Adjust the test to detect the presence of an incomplete view of a type on a function call.
2023-06-15ada: Fix minor issues in commentsRonan Desplanques1-3/+2
The package Ttypef has been removed but a reference to it was left over in a comment. This patch removes that reference, and also fixes a typo. gcc/ada/ * ttypes.ads: Remove reference to Ttypef in comment. Fix typo in comment.
2023-06-15ada: Remove Ttypes.Max_Unaligned_FieldEric Botcazou6-28/+2
This constant has been unused for ages. The corresponding getter function is also removed from the Get_Targ package, but the corresponding constant declared in Set_Targ is preserved for the sake of backward compatibility of the target file format. gcc/ada/ * get_targ.ads (Get_Max_Unaligned_Field): Delete. * ada_get_targ.adb (Get_Max_Unaligned_Field): Likewise. * get_targ.adb (Get_Max_Unaligned_Field): Likewise. * set_targ.ads (Max_Unaligned_Field): Adjust comment. * set_targ.adb: Set Max_Unaligned_Field to 1 during elaboration. * ttypes.ads (Max_Unaligned_Field): Delete.
2023-06-15ada: Fix inverted implementation of RM 8.4(10) clause for operatorsEric Botcazou1-1/+1
The comment is correct but the code implements the opposite outcome. gcc/ada/ * sem_type.adb (Disambiguate): Fix pasto in the implementation of the RM 8.4(10) clause for operators.
2023-06-15ada: Accept aspect Always_Terminates without expressionPiotr Trojanek3-51/+53
The recently added aspect Always_Terminates is now accepted without explicit boolean expression, where a missing expression implicitly means True, similar to aspects Async_Readers, Async_Writers, etc. gcc/ada/ * aspects.adb (Base_Aspect): Fix layout. * aspects.ads (Aspect_Argument): Expression for Always_Terminates is optional. * sem_prag.adb (Analyze_Always_Terminates_In_Decl_Part): Only analyze expression when pragma argument is present. (Analyze_Pragma): Argument for Always_Terminates is optional; fix whitespace for Async_Readers.
2023-06-15ada: Crash on C++ constructor of private typeJavier Miranda1-2/+18
The compiler crashes compiling a function that has pragma CPP_constructor when its return type is a private type. gcc/ada/ * sem_util.adb (Is_CPP_Constructor_Call): Add missing support for calls to functions returning a private type.
2023-06-15ada: Remove obsolete references for Build_Transient_Object_StatementsEric Botcazou1-3/+3
gcc/ada/ * exp_util.ads (Build_Transient_Object_Statements): Remove obsolete references to array and record aggregates in documentation.