diff options
author | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-05-09 22:01:24 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-05-09 22:14:04 +0200 |
commit | ad00a297ec4236b327430c171dfbe7587901ffd7 (patch) | |
tree | 4b41900f1bb918b06dad4b1004ad185a12002bd9 /gcc/ada/gcc-interface/gigi.h | |
parent | 65ba91b79e1664ba7e7f60f68e4cb956453b692e (diff) | |
download | gcc-ad00a297ec4236b327430c171dfbe7587901ffd7.zip gcc-ad00a297ec4236b327430c171dfbe7587901ffd7.tar.gz gcc-ad00a297ec4236b327430c171dfbe7587901ffd7.tar.bz2 |
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) <Attr_Component_Size>:
Remove useless code.
<Attr_Null_Parameter>: Remove obsolete code.
(Call_to_gn): Likewise. Use maybe_padded_object to remove padding.
(gnat_to_gnu): Likewise.
<N_String_Literal>: Do not add a useless null character at the end.
<N_Indexed_Component>: 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.
Diffstat (limited to 'gcc/ada/gcc-interface/gigi.h')
-rw-r--r-- | gcc/ada/gcc-interface/gigi.h | 55 |
1 files changed, 34 insertions, 21 deletions
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; } |