From ad00a297ec4236b327430c171dfbe7587901ffd7 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 9 May 2020 22:01:24 +0200 Subject: Small housekeeping work in gigi No functional changes. * gcc-interface/gigi.h (change_qualified_type): Move around. (maybe_vector_array): Likewise. (maybe_padded_object): New static line function. * gcc-interface/trans.c (Attribute_to_gnu) : Remove useless code. : Remove obsolete code. (Call_to_gn): Likewise. Use maybe_padded_object to remove padding. (gnat_to_gnu): Likewise. : Do not add a useless null character at the end. : Likewise and remove obsolete code. (add_decl_expr): Likewise. (maybe_implicit_deref): Likewise. * gcc-interface/utils.c (maybe_unconstrained_array): Likewise. * gcc-interface/utils2.c (gnat_invariant_expr): Likewise. --- gcc/ada/gcc-interface/gigi.h | 55 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 'gcc/ada/gcc-interface/gigi.h') diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index edfcbd5..c4e9d77 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -1065,20 +1065,6 @@ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int, #define gigi_checking_assert(EXPR) \ gcc_checking_assert ((EXPR) || type_annotate_only) -/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated - TYPE_REPRESENTATIVE_ARRAY. */ - -static inline tree -maybe_vector_array (tree exp) -{ - tree etype = TREE_TYPE (exp); - - if (VECTOR_TYPE_P (etype)) - exp = convert (TYPE_REPRESENTATIVE_ARRAY (etype), exp); - - return exp; -} - /* Return the smallest power of 2 larger than X. */ static inline unsigned HOST_WIDE_INT @@ -1144,6 +1130,33 @@ gnat_signed_type_for (tree type_node) return gnat_signed_or_unsigned_type_for (0, type_node); } +/* Like build_qualified_type, but TYPE_QUALS is added to the existing + qualifiers on TYPE. */ + +static inline tree +change_qualified_type (tree type, int type_quals) +{ + /* Qualifiers must be put on the associated array type. */ + if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) + return type; + + return build_qualified_type (type, TYPE_QUALS (type) | type_quals); +} + +/* If EXPR's type is a VECTOR_TYPE, return EXPR converted to the associated + TYPE_REPRESENTATIVE_ARRAY. */ + +static inline tree +maybe_vector_array (tree expr) +{ + tree type = TREE_TYPE (expr); + + if (VECTOR_TYPE_P (type)) + expr = convert (TYPE_REPRESENTATIVE_ARRAY (type), expr); + + return expr; +} + /* Adjust the character type TYPE if need be. */ static inline tree @@ -1186,15 +1199,15 @@ maybe_debug_type (tree type) return type; } -/* Like build_qualified_type, but TYPE_QUALS is added to the existing - qualifiers on TYPE. */ +/* Remove the padding around EXPR if need be. */ static inline tree -change_qualified_type (tree type, int type_quals) +maybe_padded_object (tree expr) { - /* Qualifiers must be put on the associated array type. */ - if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) - return type; + tree type = TREE_TYPE (expr); - return build_qualified_type (type, TYPE_QUALS (type) | type_quals); + if (TYPE_IS_PADDING_P (type)) + expr = convert (TREE_TYPE (TYPE_FIELDS (type)), expr); + + return expr; } -- cgit v1.1 From 1e3cabd45d499652abc3bfe28f82a363ed70390d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 9 May 2020 23:04:38 +0200 Subject: Fix small issues with -fgnat-encodings=minimal This is the mode where the GNAT compiler does not use special encodings in the debug info to describe some Ada constructs, for example packed array types. * gcc-interface/ada-tree.h (TYPE_PACKED_ARRAY_TYPE_P): Rename into... (TYPE_BIT_PACKED_ARRAY_TYPE_P): ...this. (TYPE_IS_PACKED_ARRAY_TYPE_P): Rename into... (BIT_PACKED_ARRAY_TYPE_P): ...this. (TYPE_IMPL_PACKED_ARRAY_P): Adjust to above renaming. * gcc-interface/gigi.h (maybe_pad_type): Remove IS_USER_TYPE.. * gcc-interface/decl.c (gnat_to_gnu_entity) : Adjust call to maybe_pad_type. : Remove const qualifiers for tree. : Remove redundant test and redundant call to associate_original_type_to_packed_array. Turn into assertion. Call associate_original_type_to_packed_array and modify gnu_entity_name accordingly. Explicitly set the parallel type for GNAT encodings. Call create_type_decl in the misaligned case before maybe_pad_type. : Do not use the name of the implementation type for a packed array when not using GNAT encodings. : Move around setting flags. Use the result of the call to associate_original_type_to_packed_array for gnu_entity_name. : Create XVS type and XVZ variable only if debug info is requested for the type. Call create_type_decl if a padded type was created for a type entity (gnat_to_gnu_component_type): Use local variable and adjust calls to maybe_pad_type. (gnat_to_gnu_subprog_type): Adjust call to maybe_pad_type. (gnat_to_gnu_field): Likewise. (validate_size): Adjust to renaming of macro. (set_rm_size): Likewise. (associate_original_type_to_packed_array): Adjust return type and return the name of the original type if GNAT encodings are not used * gcc-interface/misc.c (gnat_get_debug_typ): Remove obsolete stuff. (gnat_get_fixed_point_type_info): Remove const qualifiers for tree. (gnat_get_array_descr_info): Likewise and set variables lazily. Remove call to maybe_debug_type. Simplify a few computations. (enumerate_modes): Remove const qualifier for tree. * gcc-interface/utils.c (make_type_from_size): Adjust to renaming. (maybe_pad_type): Remove IS_USER_TYPE parameter and adjust. Remove specific code for implementation types for packed arrays. (compute_deferred_decl_context): Remove const qualifier for tree. (convert): Adjust call to maybe_pad_type. (unchecked_convert): Likewise. * gcc-interface/utils2.c (is_simple_additive_expressio): Likewise. --- gcc/ada/gcc-interface/gigi.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface/gigi.h') diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index c4e9d77..1adf627 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -138,14 +138,12 @@ extern tree make_type_from_size (tree type, tree size_tree, bool for_biased); if needed. We have already verified that SIZE and ALIGN are large enough. GNAT_ENTITY is used to name the resulting record and to issue a warning. IS_COMPONENT_TYPE is true if this is being done for the component type of - an array. IS_USER_TYPE is true if the original type needs to be completed. - DEFINITION is true if this type is being defined. SET_RM_SIZE is true if - the RM size of the resulting type is to be set to SIZE too; in this case, - the padded type is canonicalized before being returned. */ + an array. DEFINITION is true if this type is being defined. SET_RM_SIZE + is true if the RM size of the resulting type is to be set to SIZE too; in + this case, the padded type is canonicalized before being returned. */ extern tree maybe_pad_type (tree type, tree size, unsigned int align, Entity_Id gnat_entity, bool is_component_type, - bool is_user_type, bool definition, - bool set_rm_size); + bool definition, bool set_rm_size); /* Return true if padded TYPE was built with an RM size. */ extern bool pad_type_has_rm_size (tree type); -- cgit v1.1 From 925b418e065a9d94bd2c0d87fbfc93b573a309af Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 9 May 2020 23:17:39 +0200 Subject: Update copyright year --- gcc/ada/gcc-interface/gigi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/ada/gcc-interface/gigi.h') diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 1adf627..fcdea32 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -6,7 +6,7 @@ * * * C Header File * * * - * Copyright (C) 1992-2019, Free Software Foundation, Inc. * + * Copyright (C) 1992-2020, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * -- cgit v1.1 From 5dce843f32edfd998ae4844d8115a9c9b9c394bc Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 25 May 2020 09:18:03 +0200 Subject: Fix wrong assignment to mutable Out parameter of task entry Under very specific circumstances the compiler can generate a wrong assignment to a mutable record object which contains an array component, because it does not correctly handle the update of the discriminant. gcc/ada/ChangeLog * gcc-interface/gigi.h (operand_type): New static inline function. * gcc-interface/trans.c (gnat_to_gnu): Do not suppress conversion to the resulty type at the end for array types. * gcc-interface/utils2.c (build_binary_op) : Do not remove conversions between array types on the LHS. gcc/testsuite/ChangeLog * gnat.dg/array39.adb: New test. * gnat.dg/array39_pkg.ads: New helper. * gnat.dg/array39_pkg.adb: Likewise. --- gcc/ada/gcc-interface/gigi.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/ada/gcc-interface/gigi.h') diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index fcdea32..e43b3db 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -1209,3 +1209,11 @@ maybe_padded_object (tree expr) return expr; } + +/* Return the type of operand #0 of EXPR. */ + +static inline tree +operand_type (tree expr) +{ + return TREE_TYPE (TREE_OPERAND (expr, 0)); +} -- cgit v1.1