aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.cc
AgeCommit message (Collapse)AuthorFilesLines
2025-01-07Update copyright years.Marc Poulhiès1-1/+1
2024-12-13ada: Pass artificial_p to create_type_declTom Tromey1-2/+2
The recent "nameless types" change to gcc-interface caused the gdb pretty-printer for VSS to fail. This happens because one call to create_type_decl unconditionally passes "true" as the "artificial_p" parameter. This patch changes this call to instead pass the entity's local artificial_p value instead. This makes sense, I think, because the type decl being created for debug purposes (as the comment says) is there to represent the relevant entity from the source. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to create_type_decl.
2024-11-14ada: Avoid doing unnecessary work in elaborate_expression_2Eric Botcazou1-9/+24
This prevents the expression from being tweaked by the match.pd machinery in the process, which can damage the readability of the -gnatR3 output. gcc/ada/ChangeLog: * gcc-interface/decl.cc (elaborate_expression_2): Do not divide and multiply back if the alignment factor is already explicit.
2024-11-04ada: Move special case for null string literal from frontend to backendPiotr Trojanek1-2/+12
Previously the lower bound of string literals indexed by non-static integer types was artificially set to 1 in the frontend. This was to avoid an overflow in calculation of a null string size by the GCC backend, which was causing an excessively large binary object file. However, setting the lower bound to 1 was problematic for GNATprove, which could not easily retrieve the lower bound of string literals. This patch avoids the overflow in GCC by recognizing null string literal subtypes in Gigi. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Recognize null string literal subtypes and set their bounds to 1 .. 0.
2024-11-04ada: Remove special case for the size of a string literal subtypePiotr Trojanek1-6/+2
Apparently we no longer need to ignore string literal subtypes case when validating size of a type entity. Code cleanup; behavior appears to be unaffected. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Remove special case for string literal subtypes.
2024-10-25ada: Change scope of XUB typeTom Tromey1-1/+1
An earlier patch in the "nameless" series caused a regression with -fgnat-encodings=all. Previously, all artificial types were emitted in the CU scope in the DWARF, but with the patch, an "XUB" type is emitted in the function scope. This causes gdb lookups to erroneously find the XUB type rather than the type that gdb expects to find. Note that I don't know why the earlier code worked, because decl.cc clearly sets the XUB type's context to be the current function. This patch changes the type's context so that it is nested in a type that is conveniently available. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Use gnu_fat_type as the type context for a XUB type.
2024-10-25ada: Set DECL_NAMELESS in create_type_declTom Tromey1-3/+3
When using minimal encodings, most artificial types do not need to have their names emitted in the DWARF. This patch changes the compiler to generally omit these names. However, a subset of names are needed: when the compiler creates an artificial type for certain kinds of arrays, the name is needed by gdb. So, a new parameter is added to create_type_decl to allow this omission to be disabled. Note that simply passing 'false' as the artificial_p argument to create_type_decl doesn't work properly -- other parts of the compiler seem to rely on this flag being set, and so making this change causes ICEs. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Update some calls to create_type_decl. * gcc-interface/gigi.h (create_type_decl): Add can_be_nameless parameter. * gcc-interface/utils.cc (create_type_decl): Add can_be_nameless parameter. Set DECL_NAMELESS on type decl.
2024-10-25ada: Mark XUA types as artificialTom Tromey1-1/+1
gdb does not need the name of XUA types. This patch changes the compiler to unconditionally mark these as artificial; a subsequent patch will arrange for the name to be omitted. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Pass 'true' to create_type_decl when creating XUA type.
2024-10-25ada: Mark XUB types as namelessTom Tromey1-0/+2
gdb does not need the name of XUB types. This patch changes the compiler to omit these names from the DWARF when minimal encodings are in use. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Set TYPE_NAMELESS on XUB types.
2024-10-25ada: Add 'artificial_p' parameter to build_unc_object_typeTom Tromey1-1/+1
This adds an 'artificial_p' parameter to build_unc_object_type, so that the artificiality of the type can be propagated to create_type_decl. This will affect the namelessness of the type in a subsequent patch. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to build_unc_object_type. * gcc-interface/gigi.h (build_unc_object_type): Update. * gcc-interface/utils.cc (build_unc_object_type) Add artificial_p parameter. (build_unc_object_type_from_ptr): Update.
2024-10-25ada: Standard types are not artificialTom Tromey1-2/+14
This changes gigi so that standard types are no longer marked artificial. This change is needed to prevent subsequent patches from causing standard types to have their names elided. Also, although DWARF says that DW_AT_artificial is used for "the declaration of an object or type artificially generated by a compiler and not explicitly declared by the source program", it seems to me that types provided by the language should not be marked as such; and this is what the C and C++ compilers do. gcc/ada/ChangeLog: * gcc-interface/decl.cc (is_artificial): New function. (gnat_to_gnu_entity): Use it.
2024-10-11Fix thinko in previous changeEric Botcazou1-1/+1
gcc/ada/ PR ada/116498 PR ada/117087 * gcc-interface/decl.cc (validate_size): Fix thinko.
2024-10-08ada: Fix infinite loop on MSP430 with -mlarge flagEric Botcazou1-7/+2
This removes the loop trying to find a pointer mode among the integer modes, which is obsolete and does not work on platforms where pointers have unusual size like MSP430 or special semantics like Morello. gcc/ada/ChangeLog: PR ada/116498 * gcc-interface/decl.cc (validate_size): Use the size of the default pointer mode as the minimum size for access types and fat pointers.
2024-10-05Fix various issues of -ftrivial-auto-var-init=zero with AdaEric Botcazou1-0/+7
This polishes a few rough edges that prevent -ftrivial-auto-var-init=zero from working in Ada: - build_common_builtin_nodes declares BUILT_IN_CLEAR_PADDING with 3 instead 2 parameters, now gimple_fold_builtin_clear_padding contains the assertion: gcc_assert (gimple_call_num_args (stmt) == 2) This causes gimple_builtin_call_types_compatible_p to always return false in Ada (this works in C/C++ because another declaration is used). - gimple_add_init_for_auto_var uses EXPR_LOCATION to fetch the location of a DECL node, which always returns UNKNOWN_LOCATION. - the machinery attempts to initialize Out parameters. gcc/ PR middle-end/116933 * gimplify.cc (gimple_add_init_for_auto_var): Use the correct macro to fetch the source location of the variable. * tree.cc (common_builtin_nodes): Remove the 3rd parameter in the type of BUILT_IN_CLEAR_PADDING. gcc/ada/ PR middle-end/116933 * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Out_Parameter>: Add the "uninitialized" attribute on Out parameters. * gcc-interface/utils.cc (gnat_internal_attributes): Add entry for the "uninitialized" attribute. (handle_uninitialized_attribute): New function. gcc/testsuite/ * gnat.dg/auto_var_init.adb: New test.
2024-09-10ada: Use the same warning character in continuationsViljar Indus1-4/+4
gcc/ada/ * gcc-interface/decl.cc: Use same warning characters in continuation messages. * gcc-interface/trans.cc: Likewise.
2024-09-03ada: Fix internal error on pragma pack with discriminated record componentEric Botcazou1-0/+2
When updating the size after making a packable type in gnat_to_gnu_field, we fail to clear it again when it is not constant. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_field): Clear again gnu_size after updating it if it is not constant.
2024-09-02ada: Diagnose too large size clause on floating-point typeEric Botcazou1-0/+4
The problem is that the size clause changes the floating-point format used for the type, but it must not when this format is the widest format that is supported in hardware on the target. Instead a padding type must be built and the associated warning given. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Cap the Esize of a floating-point type to the size of the widest format supported in hardware if it is explicity defined.
2024-07-03[debug] Avoid dropping bits from num/den in fixed-point typesAlexandre Oliva1-4/+15
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-06-21ada: Fix bogus Address Sanitizer stack-buffer-overflow on packed array copyEric Botcazou1-1/+1
The Address Sanitizer considers that the padding at the end of a justified modular type may be accessed through the object, but it is never accessed and therefore can always be reused. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <discrete_type>: Set the TYPE_JUSTIFIED_MODULAR_P flag earlier. * gcc-interface/misc.cc (gnat_unit_size_without_reusable_padding): New function. (LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING): Redefine to above function.
2024-06-14ada: Fix return mechanism reported by -gnatRmEric Botcazou1-7/+27
The return mechanism of functions is reported when the -gnatRm switch is specified, but it is incorrect when the result type is not a by-reference type in the language sense but is nevertheless returned by reference. gcc/ada/ * gcc-interface/decl.cc: Include function.h. (gnat_to_gnu_param): Minor comment tweaks. (gnat_to_gnu_subprog_type): Take into account the default for the computation of the return mechanism. Give a warning if a by-copy specified mechanism cannot be honored.
2024-06-14ada: Typo and indentation fixMarc Poulhiès1-4/+4
Fixes typo in comments and 2 instances of bad indentation. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Typo fix. (gnat_to_gnu_component_type): Indent fix. * gcc-interface/gigi.h (build_call_alloc_dealloc): Typo fix. * gcc-interface/utils.cc (make_dummy_type): Typo fix. * gcc-interface/utils2.cc (gnat_protect_expr): Indent fix.
2024-06-13Revert "map packed field type to unpacked for debug info"Alexandre Oliva1-4/+0
This reverts commit ea5c9f25241ae0658180afbcad7f4e298352f561.
2024-06-12map packed field type to unpacked for debug infoAlexandre Oliva1-0/+4
We create a distinct type for each field in a packed record with a gnu_size, but there is no distinct debug information for them. Use the same unpacked type for debug information. for gcc/ada/ChangeLog * gcc-interface/decl.cc (gnat_to_gnu_field): Use unpacked type as the debug type for packed fields. for gcc/testsuite/ChangeLog * gnat.dg/bias1.adb: Count occurrences of -7.*DW_AT_GNU_bias.
2024-06-05ada: Replace use of LONG_DOUBLE_TYPE_SIZEKewen Lin1-1/+2
Joseph pointed out "floating types should have their mode, not a poorly defined precision value" in the discussion[1], as he and Richi suggested, the existing macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a hook mode_for_floating_type. To be prepared for that, this patch is to replace use of LONG_DOUBLE_TYPE_SIZE in ada with TYPE_PRECISION of long_double_type_node. [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Use TYPE_PRECISION of long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
2024-05-21ada: Simplify test for propagation of attributes to subtypesEric Botcazou1-4/+3
This changes the test to use the Is_Base_Type predicate and also removes the superfluous call to Base_Type before First_Subtype. No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Use the Is_Base_Type predicate and remove superfluous calls to Base_Type.
2024-05-21ada: Fix strict aliasing violation in parameter passing (continued)Eric Botcazou1-13/+35
This fixes another long-standing (implicit) violation of the strict aliasing rules that occurs when the result of a value conversion is directly passed as an actual parameter in a call to a subprogram and the passing mechanism is by reference. In this case, the reference passed to the subprogram may be to a type that is too different from the type of the underlying object, which is the definition of such a violation. The change reworks and strengthens the previous fix as follows: first, the detection of these violations is moved into a dedicated predicate; second, an assertion is added to check that none of them has been missed, which is triggered by either -fchecking or -fstrict-aliasing, as the closely related assertion that is present in relate_alias_sets. The assertion uncovered two internal sources of violations: implementation types for packed array types with peculiar index types and interface types, which are fixed by propagating alias sets in the first case and resorting to universal aliasing in the second case. Finally, an unconditional warning is implemented to inform the user that the temporary is created and to suggest a possible solution to prevent that. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: For a packed type implemented specially, temporarily save the XUA type as equivalent to the entity before processing the implementation type. For this implementation type, if its component type is the same as that of the original type, copy the alias set from the latter. <types>: Resort to universal aliasing for all interface types. * gcc-interface/trans.cc (Call_to_gnu): Add GNU_ACTUAL_TYPE local variable and rename existing one to GNU_UNPADDED_ACTUAL_TYPE. If the formal is passed by reference and the actual is a conversion, call aliasable_p to detect aliasing violations, issue a warning upon finding one and create the temporary in the target type. Add an assertion that no such violation has been missed above. (addressable_p): Revert latest changes. (aliasable_p): New predicate. * gcc-interface/utils2.cc (build_binary_op) <ARRAY_RANGE_REF>: When creating a new array type on the fly, preserve the alias set of the operation type.
2024-05-21ada: Fix strict aliasing violation in parameter passingEric Botcazou1-1/+39
This fixes a long-standing (implicit) violation of the strict aliasing rules that occurs when the result of a call to an instance of Unchecked_Conversion is directly passed as an actual parameter in a call to a subprogram and the passing mechanism is by reference. In this case, the reference passed to the subprogram may be to a type that has nothing to do with the type of the underlying object, which is the definition of such a violation. This implements the following two-pronged approach: first, the problematic cases are detected and a reference to a temporary is passed instead of the direct reference to the underlying object; second, the implementation of pragma Universal_Aliasing is enhanced so that it is propagated from the component type of an array type to the array type itself, or else can be applied to the array type directly, and may therefore be used to prevent the violation from occurring in the first place, when the array type is involved in the Unchecked_Conversion. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Set TYPE_TYPELESS_STORAGE on the array types if Universal_Aliasing is set on the type or its component type. <E_Array_Subtype>: Likewise. For other aggregate types, set TYPE_TYPELESS_STORAGE in this case. (set_typeless_storage_on_aggregate_type): New function. (set_universal_aliasing_on_type): Likewise. * gcc-interface/trans.cc (Call_to_gnu): Add const to local variable. Adjust comment. Pass GNAT_NAME in the call to addressable_p and add a bypass for atomic types in case it returns false. (addressable_p): Add GNAT_EXPR third parameter with default value and add a default value to the existing second parameter. <VIEW_CONVERT_EXPR:>: Return false if the expression comes from a function call and if the alias sets of source and target types are both distinct from zero and each other.
2024-05-21ada: Minor typo fix in commentMarc Poulhiès1-1/+1
gcc/ada/ * gcc-interface/decl.cc: Fix typo in comment.
2024-05-21ada: Fix assembler error for gigantic library-level object on 64-bit WindowsEric Botcazou1-6/+21
Most small 64-bit code models have a limit of 2 GB on the span of binaries, so we also use the limit for the size of the largest statically allocatable object by the compiler. If the limit is topped, the compiler switches over to a dynamic allocation (if not forbidden) after giving a warning. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Give a warning for a statically allocated object whose size is constant, valid but too large. (allocatable_size_p): In the static case, return false for a size that is constant, valid but too large.
2024-05-21ada: Fix crash on aliased constant with packed array type and -g switchEric Botcazou1-0/+3
The problem is that we build a template whose array field is not an array in the case of an aliased object with nominal unconstrained array subtype. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: For an array allocated with its bounds, make sure to have an array type to build the template.
2024-01-22Update copyright years.Marc Poulhiès1-1/+1
2024-01-09ada: Fix bogus Constraint_Error on allocator for access to array of access typeEric Botcazou1-3/+3
This occurs because the access element type is not its own TYPE_CANONICAL, which creates a discrepancy between the aliasing support code, which deals with types directly, and the middle-end which looks at TYPE_CANONICAL only. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Use the TYPE_CANONICAL of types when it comes to aliasing. * gcc-interface/utils.cc (relate_alias_sets): Likewise.
2024-01-09ada: Preliminary cleanup in aliasing support codeEric Botcazou1-14/+13
This declares an explicit temporary for the fields of the fat pointer type in gnat_to_gnu_entity and removes the GNU_ prefix of the parameters of the relate_alias_sets routine for the sake of brevity. No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Use a separate FLD local variable to hold the first field of the fat pointer type being built. * gcc-interface/gigi.h (relate_alias_sets): Remove GNU_ prefix on the first two parameters. * gcc-interface/utils.cc (relate_alias_sets): Likewise and adjust.
2024-01-09ada: Add __atomic_store_n binding to System.Atomic_PrimitivesEric Botcazou1-2/+22
This is modeled on the existing binding for __atomic_load_n. gcc/ada/ * libgnat/s-atopri.ads (Atomic_Store): New generic procedure. (Atomic_Store_8): New instantiated procedure. (Atomic_Store_16): Likewise. (Atomic_Store_32): Likewise. (Atomic_Store_64): Likewise. * libgnat/s-atopri__32.ads (Atomic_Store): New generic procedure. (Atomic_Store_8): New instantiated procedure. (Atomic_Store_16): Likewise. (Atomic_Store_32): Likewise. * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Implement the support for __atomic_store_n and __sync_bool_compare_and_swap_n. * gcc-interface/gigi.h (list_second): New inline function.
2023-12-19ada: Rename Is_Constr_Subt_For_UN_Aliased flagEric Botcazou1-24/+20
The flag is set on the constructed subtype of an object with unconstrained nominal subtype that is aliased and is used by the code generator to adjust the layout of the object. But it is actually only used for array subtypes, where it determines whether the object is allocated with its bounds, and this usage could be extended to other cases than the original case. gcc/ada/ * einfo.ads (Is_Constr_Subt_For_UN_Aliased): Rename into... (Is_Constr_Array_Subt_With_Bounds): ...this. * exp_ch3.adb (Expand_N_Object_Declaration): Adjust to above renaming and remove now redundant test. * sem_ch3.adb (Analyze_Object_Declaration): Likewise, but set Is_Constr_Array_Subt_With_Bounds only on arrays. * gen_il-fields.ads (Opt_Field_Enum): Apply same renaming. * gen_il-gen-gen_entities.adb (Entity_Kind): Likewise. * gen_il-internals.adb (Image): Remove specific processing for Is_Constr_Subt_For_UN_Aliased. * treepr.adb (Image): Likewise. * gcc-interface/decl.cc (gnat_to_gnu_entity): Adjust to renaming and remove now redundant tests. * gcc-interface/trans.cc (Identifier_to_gnu): Likewise. (Call_to_gnu): Likewise.
2023-11-28ada: Fix wrong size value output with -gnatR -gnatcEric Botcazou1-0/+1
This happens when a parameter is involved in the computation. gcc/ada/ * gcc-interface/decl.cc (annotate_value): Apply the same processing for parameters as for variables.
2023-11-21ada: Fix issue with indefinite vector of overaligned unconstrained arrayEric Botcazou1-0/+12
The problem is that the aligning machinery is not consistently triggered, depending on whether a constrained view or the nominal unconstrained view of the element type is used to perform the allocations and deallocations. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Subtype>: Put the alignment directly on the type in the constrained case too. * gcc-interface/utils.cc (maybe_pad_type): For an array type, take the alignment of the element type as the original alignment.
2023-11-16Fix internal error on function returning dynamically-sized typeEric Botcazou1-0/+6
This is a tree sharing issue for the internal return type synthesized for a function returning a dynamically-sized type and taking an Out or In/Out parameter passed by copy. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a TYPE_DECL for the return type built for the CI/CO mechanism. gcc/testsuite/ * gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test. * gnat.dg/varsize4_pkg.ads: New helper.
2023-11-07ada: Fix debug info for aliased packed array with unconstrained nominal subtypeEric Botcazou1-0/+12
The front-end now rewrites it as a renaming when it is initialized with a function call and the same processing must be applied in the renaming case as in the regular case for this kind of special objects. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Apply the specific rewriting done for an aliased object with an unconstrained array nominal subtype in the renaming case too.
2023-10-10ada: Fix internal error on too large representation clause for small componentEric Botcazou1-1/+13
This is a small bug present on strict-alignment platforms for questionable representation clauses. gcc/ada/ * gcc-interface/decl.cc (inline_status_for_subprog): Minor tweak. (gnat_to_gnu_field): Try harder to get a packable form of the type for a bitfield.
2023-09-19ada: Refine upper array bound for bit packed arrayMarc Poulhiès1-0/+22
When using bit-packed arrays, the compiler creates new array subtypes of 1-bit component indexed by integers. The existing routine checks the index subtype to find the min/max values. Bit-packed arrays being indexed by integers, the routines gives up as returning the maximum possible integer carries no useful information. This change adds a simple max_value routine that can evaluate very simple expressions by substituting variables by their min/max value. Bit-packed array subtypes are currently declared as: subtype bp_array is packed_bytes1 (0 .. integer((1 * Var + 7) / 8 - 1)); The simple max_value evaluator handles the bare minimum for this expression pattern. gcc/ada/ChangeLog: * gcc-interface/utils.cc (max_value): New. * gcc-interface/gigi.h (max_value): New. * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Subtype>: When computing gnu_min/gnu_max, try to use max_value if there is an initial expression.
2023-09-05ada: Fix DWARF for certain arraysTom Tromey1-1/+7
An array whose index type is a nonstandard enum will be marked as "packed", but should not emit DW_AT_bit_stride unless it is also bit-packed. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Set bit-packed for constrained and unconstrained array types. * gcc-interface/misc.cc (gnat_get_array_descr_info): Examine BIT_PACKED_ARRAY_TYPE_P.
2023-07-18ada: Use new typedefs in gcc-interfaceTom Tromey1-1/+4
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-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-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-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 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: Minor generic tweaks left and and rightEric Botcazou1-1/+1
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 use of Cannot_Be_Superflat flag on N_Range nodesEric Botcazou1-0/+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-18ada: use _P() defines from tree.hBernhard Reutner-Fischer1-9/+8
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.