aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
AgeCommit message (Collapse)AuthorFilesLines
2023-07-28ada: Elide the copy in extended returns for nonlimited by-reference typesEric Botcazou1-3/+4
gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu): Restrict previous change to the case where the simple return statement has got no storage pool.
2023-07-18ada: Use new typedefs in gcc-interfaceTom Tromey2-6/+14
This changes gcc-interface to use the typedefs that were recently introduced in gnat. This is another step toward switching the code generator to emit enums rather than preprocessor defines. In a couple of spots, a 'default' case is also added. These avoid warnings from -Wswitch when the typedefs are changed to be enums. gcc/ada/ * gcc-interface/decl.cc (check_ok_for_atomic_type): Use Pragma_Id. * gcc-interface/trans.cc (lvalue_required_p, Pragma_to_gnu): Use Pragma_Id. (get_type_length, Attribute_to_gnu, get_atomic_access): Use Attribute_Id.
2023-07-18ada: Expose expected_throw attributeAlexandre Oliva1-0/+19
Mark exception-raising subprograms with expected_throw attribute. Document the use of the attribute in Control Flow Redundancy. Enable marking subprograms as expected_throw with Machine_Attribute pragmas. gcc/ada/ * libgnat/a-except.ads (Raise_Exception): Mark expected_throw. (Reraise_Occurrence): Likewise. (Raise_Exception_Always): Likewise. (Raise_From_Controlled_Operation): Likewise. (Reraise_Occurrence_Always): Likewise. (Reraise_Occurrence_No_Defer): Likewise. * libgnat/a-except.adb (Exception_Propagation.Propagate_Exception): Likewise. (Complete_And_Propagate_Occurrence): Likewise. (Raise_Exception_No_Defer): Likewise. (Raise_From_Signal_Handler): Likewise. (Raise_With_Msg): Likewise. (Raise_With_Location_And_Msg): Likewise. (Raise_Constraint_Error): Likewise. (Raise_Constraint_Error_Msg): Likewise. (Raise_Program_Error): Likewise. (Raise_Program_Error_Msg): Likewise. (Raise_Storage_Error): Likewise. (Raise_Storage_Error_Msg): Likewise. (Reraise, Rcheck_*): Likewise. * doc/gnat_rm/security_hardening_features.rst (Control Flow Hardening): Note the influence of expected_throw. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate. * gcc-interface/utils.cc (handle_expected_throw_attribute): New. (gnat_internal_attribute_table): Add expected_throw.
2023-07-06ada: Add specification source files of runtime unitsClaire Dross1-0/+3
gcc/ada/ * gcc-interface/Make-lang.in: Add object files of specification files.
2023-06-29A couple of va_gc_atomic tweaksRichard Sandiford1-11/+0
The only current user of va_gc_atomic is Ada's: vec<Entity_Id, va_gc_atomic> It uses the generic gt_pch_nx routines (with gt_pch_nx being the “note pointers” hooks), such as: template<typename T, typename A> void gt_pch_nx (vec<T, A, vl_embed> *v) { extern void gt_pch_nx (T &); for (unsigned i = 0; i < v->length (); i++) gt_pch_nx ((*v)[i]); } It then defines gt_pch_nx routines for Entity_Id &. The problem is that if we wanted to take the same approach for an array of unsigned ints, we'd need to define: inline void gt_pch_nx (unsigned int &) { } which would then be ambiguous with: inline void gt_pch_nx (unsigned int) { } The point of va_gc_atomic is that the elements don't need to be GCed, and so we have: template<typename T> void gt_ggc_mx (vec<T, va_gc_atomic, vl_embed> *v ATTRIBUTE_UNUSED) { /* Nothing to do. Vectors of atomic types wrt GC do not need to be traversed. */ } I think it's therefore reasonable to assume that no pointers will need to be processed for PCH either. The patch also relaxes the array_slice constructor for vec<T, va_gc> * so that it handles all embedded vectors. gcc/ * vec.h (gt_pch_nx): Add overloads for va_gc_atomic. (array_slice): Relax va_gc constructor to handle all vectors with a vl_embed layout. gcc/ada/ * gcc-interface/decl.cc (gt_pch_nx): Remove overloads for Entity_Id.
2023-06-27ada: Fix build of GNAT toolsEric Botcazou1-3/+6
gcc/ada/ * gcc-interface/Makefile.in (LIBIBERTY): Fix condition. (TOOLS_LIBS): Add @LD_PICFLAG@.
2023-06-27ada: Fix bad interaction between inlining and thunk generationEric Botcazou1-3/+6
This may cause the type of the RESULT_DECL of a function which returns by invisible reference to be turned into a reference type twice. gcc/ada/ * gcc-interface/trans.cc (Subprogram_Body_to_gnu): Add guard to the code turning the type of the RESULT_DECL into a reference type. (maybe_make_gnu_thunk): Use a more precise guard in the same case.
2023-06-27ada: Make the identification of case expressions more robustEric Botcazou1-5/+3
gcc/ada/ * gcc-interface/trans.cc (Case_Statement_to_gnu): Rename boolean constant and use From_Conditional_Expression flag for its value.
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-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: 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-05-30ada: Fix wrong access for qualified aggregate with storage modelEric Botcazou1-3/+6
The previous fix to get_storage_model_access was incomplete and needs to be extended to the node itself. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Also strip any type conversion in the node when unwinding the components.
2023-05-30ada: Fix internal error on qualified aggregate with storage modelEric Botcazou1-17/+19
It comes from a small oversight in get_storage_model_access. gcc/ada/ * gcc-interface/trans.cc (node_is_component): Remove parentheses. (node_is_type_conversion): New predicate. (get_atomic_access): Use it. (get_storage_model_access): Likewise and look into the parent to find a component if it returns true. (present_in_lhs_or_actual_p): Likewise.
2023-05-30ada: Add missing guards for degenerate storage modelsEric Botcazou1-5/+10
gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) <Attr_Size>: Check that the storage model has Copy_From before instantiating loads for it. <Attr_Length>: Likewise. <Attr_Bit_Position>: Likewise. (gnat_to_gnu) <N_Indexed_Component>: Likewise. <N_Slice>: Likewise.
2023-05-30ada: Fix incorrect copies being used with 'AddressMarc Poulhiès1-4/+9
When using 'Address on an object with a size clause, gigi would end up creating a copy and using its address instead of the one of the original object, leading to incorrect behavior. Remove the conversion (that triggers the copy) when 'Address is applied to a declaration. gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu): Also strip conversion in case of DECL.
2023-05-30ada: Fix bogus Storage_Error on dynamic array with static zero lengthEric Botcazou1-4/+21
This works around the limitations present for the support of arrays in the middle-end by clearing the TREE_OVERFLOW flag for arrays with zero length. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Use a local variable for the GNAT index type. <E_Array_Subtype>: Likewise. Call Is_Null_Range on the bounds and force the zero on TYPE_SIZE and TYPE_SIZE_UNIT if it returns true.
2023-05-30ada: Fix minor issue with Mod operatorEric Botcazou1-4/+4
gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Mod>: Test the precision of the operation rather than that of the result type.
2023-05-30ada: Minor generic tweaks left and and rightEric Botcazou4-12/+14
No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Replace integer_zero_node with null_pointer_node for pointer types. * gcc-interface/trans.cc (gnat_gimplify_expr) <NULL_EXPR>: Likewise. * gcc-interface/utils.cc (maybe_pad_type): Do not attempt to make a packable type from a fat pointer type. * gcc-interface/utils2.cc (build_atomic_load): Use a local variable. (build_atomic_store): Likewise.
2023-05-30ada: Make internal_error_function more robustEric Botcazou1-6/+16
gcc/ada/ * gcc-interface/misc.cc (internal_error_function): Be prepared for an input_location set to UNKNOWN_LOCATION.
2023-05-30ada: Adjust again the implementation of storage modelsEric Botcazou1-22/+29
The code generator must now be prepared to translate assignment statements to objects allocated with a storage model and that are not initialized yet. gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) <Attr_Size>: Tweak. (gnat_to_gnu) <N_Assignment_Statement>: Declare a local variable. For a target with a storage model, use the Actual_Designated_Subtype to compute the size if it is present.
2023-05-30ada: Simplify the implementation of storage modelsEric Botcazou1-103/+27
As the additional temporaries required by the semantics of nonnative storage models are now created by the front-end, in particular for actual parameters and assignment statements, the corresponding code in gigi can be removed. gcc/ada/ * gcc-interface/trans.cc (Call_to_gnu): Remove code implementing the by-copy semantics for actuals with nonnative storage models. (gnat_to_gnu) <N_Assignment_Statement>: Remove code instantiating a temporary for assignments between nonnative storage models.
2023-05-30ada: Make use of Cannot_Be_Superflat flag on N_Range nodesEric Botcazou2-3/+4
gcc/ada/ * gcc-interface/decl.cc (range_cannot_be_superflat): Return true immediately if Cannot_Be_Superflat is set. * gcc-interface/misc.cc (gnat_post_options): Do not override the -Wstringop-overflow setting.
2023-05-30ada: Disable PIE mode during the build of the Ada front-endEric Botcazou1-13/+3
This also removes some obsolete stuff. gcc/ada/ * gcc-interface/Make-lang.in (ADA_CFLAGS): Move up. (ALL_ADAFLAGS): Add $(NO_PIE_CFLAGS). (ada/mdll.o): Remove. (ada/mdll-fil.o): Likewise. (ada/mdll-utl.o): Likewise.
2023-05-30ada: Fix storage model handling for dereference as lvalue and renamingsMarc Poulhiès1-3/+21
Don't require storage access for explicit dereferences used as lvalue (e.g. Some_Access.all'Address) or for renamings. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Don't require storage model access for dereference used as lvalue or renamings.
2023-05-26ada: Remove Is_Descendant_Of_Address flag from Standard_AddressEric Botcazou2-7/+14
It breaks the Allow_Integer_Address special mode. Add new standard_address parameters to gigi and alphabetize others, this is necessary when addresses are not treated like integers. gcc/ada/ * back_end.adb (Call_Back_End): Add gigi_standard_address to the signature of the gigi procedure and alphabetize other parameters. Pass Standard_Address as actual parameter for it. * cstand.adb (Create_Standard): Do not set Is_Descendant_Of_Address on Standard_Address. * gcc-interface/gigi.h (gigi): Add a standard_address parameter and alphabetize others. * gcc-interface/trans.cc (gigi): Likewise. Record a builtin address type and save it as the type for Standard.Address.
2023-05-18ada: use _P() defines from tree.hBernhard Reutner-Fischer4-31/+30
gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Use _P defines from tree.h. (constructor_address_p): Ditto. (elaborate_expression_1): Ditto. * gcc-interface/trans.cc (Identifier_to_gnu): Ditto. (is_nrv_p): Ditto. (Subprogram_Body_to_gnu): Ditto. (gnat_to_gnu): Ditto. (gnat_to_gnu_external): Ditto. (add_decl_expr): Ditto. (gnat_gimplify_expr): Ditto. * gcc-interface/utils.cc (create_var_decl): Ditto. * gcc-interface/utils2.cc (get_base_type): Ditto. (build_binary_op): Ditto. (build_unary_op): Ditto. (gnat_protect_expr): Ditto. (gnat_invariant_expr): Ditto.
2023-05-15ada: Fix proof of runtime unit System.Value*Claire Dross1-0/+2
Use cut operations to restore the proof of System.Value*. gcc/ada/ * libgnat/s-valueu.adb: Use cut operations inside assertion to restore proofs * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-spark and s-spcuop dependencies.
2023-04-18Fixed typo.Jin Ma1-1/+1
gcc/ada * gcc-interface/utils.cc (unchecked_convert): Fixed typo.
2023-04-15Fix fallout of previous change on x86/LinuxEric Botcazou1-6/+16
gcc/ada/ PR bootstrap/109510 * gcc-interface/decl.cc (gnat_to_gnu_entity) <types>: Do not reset align to zero in any case. Set TYPE_USER_ALIGN on the type only if it is an aggregate type, or else a type whose default alignment is specifically capped on selected platforms.
2023-04-14Fix build failure of Ada runtime for Aarch64 targetsEric Botcazou1-2/+6
The Aarch64 back-end now asserts that the main variant of scalar types has TYPE_USER_ALIGN cleared, and that's not the case for scalar types declared with a confirming alignment clause in Ada. gcc/ada/ PR bootstrap/109510 * gcc-interface/decl.cc (gnat_to_gnu_entity) <types>: Reset align to zero if its value is equal to TYPE_ALIGN and the type is scalar. Set TYPE_USER_ALIGN on the type only if align is positive.
2023-03-06Revert "Respect GNATMAKE Makefile variable" commitEric Botcazou1-1/+1
It breaks cross native builds. gcc/ada/ PR ada/108909 PR ada/108983 * Make-generated.in: Do not use GNATMAKE. * gcc-interface/Makefile.in: Ditto.
2023-02-26Respect GNATMAKE Makefile variablePeter Foley1-1/+1
gcc/ada/ PR ada/108909 * Make-generated.in: Use GNATMAKE. * gcc-interface/Makefile.in: Ditto.
2023-02-14Fix small regression in AdaEric Botcazou1-1/+3
gcc/ * gimplify.cc (gimplify_save_expr): Add missing guard. gcc/ada/ * gcc-interface/trans.cc (gnat_gimplify_expr): Add missing guard. gcc/testsuite/ * gnat.dg/shift2.adb: New test.
2023-01-16ada: Update copyright years.Marc Poulhiès20-22/+20
gcc/ada/ * gcc-interface/Make-lang.in: Update copyright years. * gcc-interface/Makefile.in: Likewise. * gcc-interface/ada-builtin-types.def: Likewise. * gcc-interface/ada-builtins.def: Likewise. * gcc-interface/ada-tree.def: Likewise. * gcc-interface/ada-tree.h: Likewise. * gcc-interface/ada.h: Likewise. * gcc-interface/config-lang.in: Likewise. * gcc-interface/cuintp.cc: Likewise. * gcc-interface/decl.cc: Likewise. * gcc-interface/gadaint.h: Likewise. * gcc-interface/gigi.h: Likewise. * gcc-interface/lang-specs.h: Likewise. * gcc-interface/lang.opt: Likewise. * gcc-interface/misc.cc: Likewise. * gcc-interface/system.ads: Likewise. * gcc-interface/targtyps.cc: Likewise. * gcc-interface/trans.cc: Likewise. * gcc-interface/utils.cc: Likewise. * gcc-interface/utils2.cc: Likewise.
2023-01-02Ada,Darwin: Do not link libgcc statically on Darwin 8 and 9 [PR108202].Iain Sandoe1-2/+11
Normally, GCC executables are built with -static-libstdc++ -static-libgcc on Darwin. This is fine in most cases, because GCC executables typically do no use exceptions. However gnat1 does use exceptions and also pulls in system libraries that are linked against the installed shared libgcc which contains the system unwinder. This means that gnat1 effectively has two unwinder instances (which does not work reliably since the unwinders have global state). A recent change in the initialization of FDEs has made this a hard error now on Darwin versions (8 and 9) with libgcc installed in /usr/lib (gnat1 now hangs when an exception is thrown). The solution is to link libgcc dynamically, picking up the installed system version. To do this we strip -static-libgcc from the link flags. PR ada/108202 gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (GCC_LINKERFLAGS, GCC_LDFLAGS): Versions of ALL_LINKERFLAGS, LDFLAGS with -Werror and -static-libgcc filtered out for Darwin8 and 9 (-Werror is filtered out for other hosts).
2022-12-29ada: don't map NULL decl to locusAlexandre Oliva1-1/+1
When decl is NULL, don't record its mapping in the decl_to_instance_map. for gcc/ada/ChangeLog * gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl.
2022-12-06ada: Elide the copy in extended returns for nonlimited by-reference typesEric Botcazou1-5/+7
This implements elision of the copy operation for extended return statements in the case of nonlimited by-reference types (the copy operation is already elided for limited types by the front-end and nonlimited non-by-reference types by the code generator), which comprise controlled and tagged types. The implementation partly reuses the machinery implemented for limited types (the build-in-place machinery) to allocate the return object directly on the primary or the secondary stack, depending on whether the result type of the function is constrained or not. This requires further special-casing for the allocators generated by this machinery as well as an adjustment to the implementation of a specific case of string concatenation. gcc/ada/ * einfo.ads (Actual_Subtype): Document additional usage. * exp_aggr.adb (Expand_Array_Aggregate): Replace test on Is_Build_In_Place_Return_Object with Is_Special_Return_Object. * exp_ch3.adb (Expand_N_Object_Declaration): Factor out parts of the processing done for build-in-place return objects and reuse them to implement a similar processing for specific return objects. * exp_ch4.adb (Expand_Allocator_Expression): Do not generate a tag assignment or an adjustment if the allocator was made for a special return object. (Expand_Concatenate): If the result is allocated on the secondary stack, use an unconstrained allocation. * exp_ch6.ads (Apply_CW_Accessibility_Check): New declaration. (Is_By_Reference_Return_Object): Likewise. (Is_Secondary_Stack_Return_Object): Likewise. (Is_Special_Return_Object): Likewise. * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not bail out for the expression in the declaration of a special return object. (Expand_N_Extended_Return_Statement): Add missing guard and move the class-wide accessibility check to Expand_N_Object_Declaration. (Expand_Simple_Function_Return): Delete obsolete commentary. Skip the special processing for types that require finalization or are returned on the secondary stack if the return originally comes from an extended return statement. Add missing Constant_Present. (Is_By_Reference_Return_Object): New predicate. (Is_Secondary_Stack_Return_Object): Likewise. (Is_Special_Return_Object): Likewise. * exp_util.adb (Is_Related_To_Func_Return): Also return true if the parent of the expression is the renaming declaration generated for the expansion of a return object. * gen_il-fields.ads (Opt_Field_Enum): Replace Alloc_For_BIP_Return with For_Special_Return_Object. * gen_il-gen-gen_nodes.adb (N_Allocator): Likewise. * gen_il-internals.adb (Image): Remove Alloc_For_BIP_Return. * sem_ch3.adb (Check_Return_Subtype_Indication): New procedure moved from sem_ch6.adb. (Analyze_Object_Declaration): Call it on a return object. * sem_ch4.adb: Add with and use clauses for Rtsfind. (Analyze_Allocator): Test For_Special_Return_Object to skip checks for allocators made for special return objects. Do not report restriction violations for the return stack pool. * sem_ch5.adb (Analyze_Assignment.Set_Assignment_Type): Return the Actual_Subtype for return objects that live on the secondary stack. * sem_ch6.adb (Check_Return_Subtype_Indication): Move procedure to sem_ch3.adb. (Analyze_Function_Return): Do not call above procedure. * sem_res.adb (Resolve_Allocator): Replace Alloc_For_BIP_Return with For_Special_Return_Object. * sinfo.ads: Likewise. * treepr.adb (Image): Remove Alloc_For_BIP_Return. * gcc-interface/trans.cc (gnat_to_gnu): Do not convert to the result type in the unconstrained array type case if the parent is a simple return statement.
2022-12-06ada: Accessibility code reorganization and bug fixesJustin Squirek1-0/+1
This patch performs a large reorganization of accessibility related sources, and also corrects some latent issues with accessibility checks - namely the calculation of accessibility levels for expanded iterators and type conversions. gcc/ada/ * accessibility.adb, accessibility.ads (Accessibility_Message): Moved from sem_attr. (Apply_Accessibility_Check): Moved from checks. (Apply_Accessibility_Check_For_Allocator): Moved from exp_ch4 and renamed (Check_Return_Construct_Accessibility): Moved from sem_ch6. (Innermost_Master_Scope_Depth): Moved from sem_util. Add condition to detect expanded iterators. (Prefix_With_Safe_Accessibility_Level): Moved from sem_attr. (Static_Accessibility_Level): Moved from sem_util. (Has_Unconstrained_Access_Discriminants): Likewise. (Has_Anonymous_Access_Discriminant): Likewise. (Is_Anonymous_Access_Actual): Likewise. (Is_Special_Aliased_Formal_Access): Likewise. (Needs_Result_Accessibility_Level): Likewise. (Subprogram_Access_Level): Likewise. (Type_Access_Level): Likewise. (Deepest_Type_Access_Level): Likewise. (Effective_Extra_Accessibility): Likewise. (Get_Dynamic_Accessibility): Likewise. (Has_Access_Values): Likewise. (Accessibility_Level): Likewise. * exp_attr.adb (Access_Cases): Obtain the proper enclosing object which applies to a given 'Access by looking through type conversions. * exp_ch4.adb (Apply_Accessibility_Check): Moved to accessibility. * exp_ch5.adb: Likewise. * exp_ch6.adb: Likewise. * exp_ch9.adb: Likewise. * exp_disp.adb: Likewise. * gen_il-fields.ads: Add new flag Comes_From_Iterator. * gen_il-gen-gen_nodes.adb: Add new flag Comes_From_Iterator for N_Object_Renaming_Declaration. * sem_ch5.adb (Analyze_Iterator_Specification): Mark object renamings resulting from iterator expansion with the new flag Comes_From_Iterator. * sem_aggr.adb (Resolve_Container_Aggregate): Refine test. * sem_ch13.adb: Add dependence on the accessibility package. * sem_ch3.adb: Likewise. * sem_ch4.adb: Likewise. * sem_ch9.adb: Likewise. * sem_res.adb: Likewise. * sem_warn.adb: Likewise. * exp_ch3.adb: Likewise. * sem_attr.adb (Accessibility_Message): Moved to accessibility. (Prefix_With_Safe_Accessibility_Level): Likewise. * checks.adb, checks.ads (Apply_Accessibility_Check): Likewise. * sem_ch6.adb (Check_Return_Construct_Accessibility): Likewise. * sem_util.adb, sem_util.ads (Accessibility_Level): Likewise. (Deepest_Type_Access_Level): Likewise. (Effective_Extra_Accessibility): Likewise. (Get_Dynamic_Accessibility): Likewise. (Has_Access_Values): Likewise. (Has_Anonymous_Access_Discriminant): Likewise. (Static_Accessibility_Level): Likewise. (Has_Unconstrained_Access_Discriminants): Likewise. (Is_Anonymous_Access_Actual): Likewise. (Is_Special_Aliased_Formal_Access): Likewise. (Needs_Result_Accessibility_Level): Likewise. (Subprogram_Access_Level): Likewise. (Type_Access_Level): Likewise. * sinfo.ads: Document new flag Comes_From_Iterator. * gcc-interface/Make-lang.in: Add entry for new Accessibility package.
2022-12-01ada: Strip conversions for the implementation of storage modelsEric Botcazou1-0/+5
This is necessary for unconstrained allocators with qualified expression. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Strip any type conversion around the node before looking into it.
2022-11-24ada: Add assertion for the implementation of storage modelsEric Botcazou1-0/+3
We cannot generate a call to memset for an aggregate with an Others choice when the target of the assignment has a storage model with Copy_To routine. gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) <N_Assignment_Statement>: Add assertion that memset is not supposed to be used when the target has a storage model with Copy_To routine.
2022-11-21ada: Adjust recent change for returns involving function callsEric Botcazou2-14/+8
gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Constant>: Revert latest change. * gcc-interface/trans.cc (gnat_to_gnu) <N_Object_Declaration>: Tweak latest change.
2022-11-14Revert "sphinx: ada: port to Sphinx"Martin Liska1-41/+57
This reverts commit 0a543515957ff47feba739e6f71062fb2fb99125.
2022-11-14Revert "sphinx: add --with-sphinx-build"Martin Liska1-12/+12
This reverts commit 1f5a932e89b0c2c4a7af7f849ca2e2e3dbf329e0.
2022-11-14Revert "sphinx: support installation if sphinx-build is missing"Martin Liska1-3/+6
This reverts commit e5821d3f62b5bf532db1be661459b7553a956fa2.
2022-11-09sphinx: support installation if sphinx-build is missingMartin Liska1-6/+3
gcc/ChangeLog: * Makefile.in: Support installation if sphinx-build is missing. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support installation if sphinx-build is missing. gcc/cp/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/d/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/fortran/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/go/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. Support installation if sphinx-build is missing. gcc/jit/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing.
2022-11-09sphinx: add --with-sphinx-buildMartin Liska1-12/+12
gcc/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: * configure: Regenerate. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support --with-sphinx-build. gcc/d/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/fortran/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/go/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/jit/ChangeLog: * Make-lang.in: Support --with-sphinx-build. libgomp/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise.. * configure: Regenerate. libiberty/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libitm/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libquadmath/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate.
2022-11-09sphinx: ada: port to SphinxMartin Liska1-57/+41
gcc/ada/ChangeLog: * doc/gnat-style.rst: Moved to... * doc/gnat-style/index.rst: ...here. * doc/gnat_rm.rst: Moved to... * doc/gnat_rm/index.rst: ...here. * doc/gnat_ugn.rst: Moved to... * doc/gnat_ugn/index.rst: ...here. * doc/share/latex_elements.py: Moved to... * doc/share/ada_latex_elements.py: ...here. * gcc-interface/Make-lang.in: * doc/Makefile: Removed. * doc/share/conf.py: Removed. * doc/share/gnu_free_documentation_license.rst: Removed. * gnat-style.texi: Removed. * gnat_rm.texi: Removed. * gnat_ugn.texi: Removed. * doc/gnat-style/conf.py: New file. * doc/gnat-style/gnu_free_documentation_license.rst: New file. * doc/gnat_rm/conf.py: New file. * doc/gnat_rm/gnu_free_documentation_license.rst: New file. * doc/gnat_ugn/conf.py: New file. * doc/gnat_ugn/gnu_free_documentation_license.rst: New file. * doc/share/adabaseconf.py: New file. * doc/gnat_rm/security_hardening_features.rst: Add role. * doc/gnat_ugn/platform_specific_information.rst: Remove duplicate definition of |nbsp|.
2022-11-08ada: Fix oversight in implementation of allocators for storage modelsEric Botcazou1-7/+26
When the allocator is of an unconstrained array type and has an initializing expression, the copy of the initializing expression must be done separately from that of the bounds. gcc/ada/ * gcc-interface/utils2.cc (build_allocator): For unconstrained array types with a storage model and an initializing expression, copy the initialization expression separately from the bounds. In all cases with a storage model, pass the locally computed size for the store.
2022-11-08ada: Move warnings switches -- initial workBob Duff3-3/+3
This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed).