From 4880a940ffe902439a7cf5626d2c17c42f2aa083 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Wed, 22 Apr 2009 08:34:09 +0000 Subject: [PATCH] * gcc-interface/ada-tree.def: Fix formatting nits. (REGION_STMT): Delete. (HANDLER_STMT): Likewise. * gcc-interface/ada-tree.h: Fix formatting nits. (IS_STMT): Delete. (REGION_STMT_BODY): Likewise. (REGION_STMT_HANDLE): Likewise. (REGION_STMT_BLOCK): Likewise. (HANDLER_STMT_ARG): Likewise. (HANDLER_STMT_LIST): Likewise. (HANDLER_STMT_BLOCK): Likewise. * gcc-interface/gigi.h (fp_prec_to_size): Update comment. (fp_size_to_prec): Likewise. (largest_move_alignment): Delete. (gnat_compute_largest_alignment): Likewise. Fix minor nits. * gcc-interface/decl.c (gnat_to_gnu_entity) : Remove redundant code. : Remove redundant assert. : Exit early from index computation in pathological cases. Rewrite conditional assignment. (make_type_from_size): Likewise. * gcc-interface/misc.c (largest_move_alignment): Delete. (gnat_finish_incomplete_decl): Likewise. (LANG_HOOKS_FINISH_INCOMPLETE_DECL): Likewise. (asm_out_file): Likewise (gnat_print_type) : Fall through to ENUMERAL_TYPE case. (gnat_dwarf_name): Move around. * gcc-interface/trans.c (Attribute_to_gnu): Fix minor nits. (gigi): Remove call to gnat_compute_largest_alignment. * utils.c (create_field_decl): Rewrite conditional assignment. Fix minor nits. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146551 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 36 +++++++++++ gcc/ada/gcc-interface/ada-tree.def | 32 +++------- gcc/ada/gcc-interface/ada-tree.h | 69 +++++++++------------ gcc/ada/gcc-interface/decl.c | 124 +++++++++++++++++++++---------------- gcc/ada/gcc-interface/gigi.h | 96 +++++++++++++--------------- gcc/ada/gcc-interface/misc.c | 89 +++++++++----------------- gcc/ada/gcc-interface/trans.c | 51 +++++++-------- gcc/ada/gcc-interface/utils.c | 15 +++-- 8 files changed, 252 insertions(+), 260 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f2686b8e455..6074e3f439a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,41 @@ 2009-04-22 Eric Botcazou + * gcc-interface/ada-tree.def: Fix formatting nits. + (REGION_STMT): Delete. + (HANDLER_STMT): Likewise. + * gcc-interface/ada-tree.h: Fix formatting nits. + (IS_STMT): Delete. + (REGION_STMT_BODY): Likewise. + (REGION_STMT_HANDLE): Likewise. + (REGION_STMT_BLOCK): Likewise. + (HANDLER_STMT_ARG): Likewise. + (HANDLER_STMT_LIST): Likewise. + (HANDLER_STMT_BLOCK): Likewise. + * gcc-interface/gigi.h (fp_prec_to_size): Update comment. + (fp_size_to_prec): Likewise. + (largest_move_alignment): Delete. + (gnat_compute_largest_alignment): Likewise. + Fix minor nits. + * gcc-interface/decl.c (gnat_to_gnu_entity) : + Remove redundant code. + : Remove redundant assert. + : Exit early from index computation in pathological + cases. + Rewrite conditional assignment. + (make_type_from_size): Likewise. + * gcc-interface/misc.c (largest_move_alignment): Delete. + (gnat_finish_incomplete_decl): Likewise. + (LANG_HOOKS_FINISH_INCOMPLETE_DECL): Likewise. + (asm_out_file): Likewise + (gnat_print_type) : Fall through to ENUMERAL_TYPE case. + (gnat_dwarf_name): Move around. + * gcc-interface/trans.c (Attribute_to_gnu): Fix minor nits. + (gigi): Remove call to gnat_compute_largest_alignment. + * utils.c (create_field_decl): Rewrite conditional assignment. + Fix minor nits. + +2009-04-22 Eric Botcazou + * gcc-interface/decl.c (gnat_to_gnu_entity): Compute is_type predicate on entry. Defer common processing for types. Reorder and clean up. Compute the equivalent GNAT node and the default size for types only. diff --git a/gcc/ada/gcc-interface/ada-tree.def b/gcc/ada/gcc-interface/ada-tree.def index 04643c5dde4..454b4bd1106 100644 --- a/gcc/ada/gcc-interface/ada-tree.def +++ b/gcc/ada/gcc-interface/ada-tree.def @@ -6,7 +6,7 @@ * * * Specification * * * - * Copyright (C) 1992-2008, Free Software Foundation, Inc. * + * Copyright (C) 1992-2009, 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- * @@ -23,19 +23,17 @@ * * ****************************************************************************/ -/* A type that is an unconstrained array itself. This node is never passed - to GCC. TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE - is the type of a record containing the template and data. */ - +/* A type that is an unconstrained array. This node is never passed to GCC. + TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE is + the type of a record containing the template and data. */ DEFTREECODE (UNCONSTRAINED_ARRAY_TYPE, "unconstrained_array_type", tcc_type, 0) /* A reference to an unconstrained array. This node only exists as an intermediate node during the translation of a GNAT tree to a GCC tree; it is never passed to GCC. The only field used is operand 0, which is the fat pointer object. */ - DEFTREECODE (UNCONSTRAINED_ARRAY_REF, "unconstrained_array_ref", - tcc_reference, 1) + tcc_reference, 1) /* An expression that returns an RTL suitable for its type. Operand 0 is an expression to be evaluated for side effects only. */ @@ -51,7 +49,7 @@ DEFTREECODE (MINUS_NOMOD_EXPR, "minus_nomod_expr", tcc_binary, 2) /* Same as ADDR_EXPR, except that if the operand represents a bit field, return the address of the byte containing the bit. This is used - for the 'Address attribute and never shows up in the tree. */ + for the Address attribute and never shows up in the tree. */ DEFTREECODE (ATTR_ADDR_EXPR, "attr_addr_expr", tcc_reference, 1) /* Here are the tree codes for the statement types known to Ada. These @@ -64,10 +62,10 @@ DEFTREECODE (ATTR_ADDR_EXPR, "attr_addr_expr", tcc_reference, 1) DEFTREECODE (STMT_STMT, "stmt_stmt", tcc_statement, 1) /* A loop. LOOP_STMT_TOP_COND and LOOP_STMT_BOT_COND are the tests to exit a - loop at the top and bottom, respectively. LOOP_STMT_UPDATE is the statement + loop at the top and bottom respectively. LOOP_STMT_UPDATE is the statement to update the loop iterator at the continue point. LOOP_STMT_BODY are the - statements in the body of the loop. LOOP_STMT_LABEL points to the LABEL_DECL - of the end label of the loop. */ + statements in the body of the loop. LOOP_STMT_LABEL points to the + LABEL_DECL of the end label of the loop. */ DEFTREECODE (LOOP_STMT, "loop_stmt", tcc_statement, 5) /* Conditionally exit a loop. EXIT_STMT_COND is the condition, which, if @@ -75,15 +73,3 @@ DEFTREECODE (LOOP_STMT, "loop_stmt", tcc_statement, 5) the loop is unconditionally exited. EXIT_STMT_LABEL is the end label corresponding to the loop to exit. */ DEFTREECODE (EXIT_STMT, "exit_stmt", tcc_statement, 2) - -/* A exception region. REGION_STMT_BODY is the statement to be executed - inside the region. REGION_STMT_HANDLE is a statement that represents - the exception handlers (usually a BLOCK_STMT of HANDLE_STMTs). - REGION_STMT_BLOCK is the BLOCK node for the declarative region, if any. */ -DEFTREECODE (REGION_STMT, "region_stmt", tcc_statement, 3) - -/* An exception handler. HANDLER_STMT_ARG is the value to pass to - expand_start_catch, HANDLER_STMT_LIST is the list of statements for the - handler itself, and HANDLER_STMT_BLOCK is the BLOCK node for this - binding. */ -DEFTREECODE (HANDLER_STMT, "handler_stmt", tcc_statement, 3) diff --git a/gcc/ada/gcc-interface/ada-tree.h b/gcc/ada/gcc-interface/ada-tree.h index 8d1f6a87c9d..cd2b9703887 100644 --- a/gcc/ada/gcc-interface/ada-tree.h +++ b/gcc/ada/gcc-interface/ada-tree.h @@ -30,8 +30,8 @@ union lang_tree_node { union tree_node GTY((tag ("0"))) t; }; -struct lang_decl GTY(()) {tree t; }; -struct lang_type GTY(()) {tree t; }; +struct lang_decl GTY(()) { tree t; }; +struct lang_type GTY(()) { tree t; }; /* Define macros to get and set the tree in TYPE_ and DECL_LANG_SPECIFIC. */ #define GET_TYPE_LANG_SPECIFIC(NODE) \ @@ -39,7 +39,7 @@ struct lang_type GTY(()) {tree t; }; #define SET_TYPE_LANG_SPECIFIC(NODE, X) \ (TYPE_LANG_SPECIFIC (NODE) \ = (TYPE_LANG_SPECIFIC (NODE) \ - ? TYPE_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_type))) \ + ? TYPE_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_type))) \ ->t = X; #define GET_DECL_LANG_SPECIFIC(NODE) \ @@ -47,7 +47,7 @@ struct lang_type GTY(()) {tree t; }; #define SET_DECL_LANG_SPECIFIC(NODE, VALUE) \ (DECL_LANG_SPECIFIC (NODE) \ = (DECL_LANG_SPECIFIC (NODE) \ - ? DECL_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_decl))) \ + ? DECL_LANG_SPECIFIC (NODE) : GGC_NEW (struct lang_decl))) \ ->t = VALUE; /* Flags added to GCC type nodes. */ @@ -57,7 +57,7 @@ struct lang_type GTY(()) {tree t; }; #define TYPE_IS_FAT_POINTER_P(NODE) \ TYPE_LANG_FLAG_0 (RECORD_OR_UNION_CHECK (NODE)) -#define TYPE_FAT_POINTER_P(NODE) \ +#define TYPE_FAT_POINTER_P(NODE) \ (TREE_CODE (NODE) == RECORD_TYPE && TYPE_IS_FAT_POINTER_P (NODE)) /* For integral types and array types, nonzero if this is a packed array type @@ -75,7 +75,7 @@ struct lang_type GTY(()) {tree t; }; /* For ARRAY_TYPE, nonzero if this type corresponds to a dimension of an Ada array other than the first. */ -#define TYPE_MULTI_ARRAY_P(NODE) TYPE_LANG_FLAG_1 (ARRAY_TYPE_CHECK (NODE)) +#define TYPE_MULTI_ARRAY_P(NODE) TYPE_LANG_FLAG_1 (ARRAY_TYPE_CHECK (NODE)) /* For FUNCTION_TYPE, nonzero if this denotes a function returning an unconstrained array or record. */ @@ -102,7 +102,7 @@ struct lang_type GTY(()) {tree t; }; /* For INTEGER_TYPE, nonzero if this really represents a VAX floating-point type. */ -#define TYPE_VAX_FLOATING_POINT_P(NODE) \ +#define TYPE_VAX_FLOATING_POINT_P(NODE) \ TYPE_LANG_FLAG_3 (INTEGER_TYPE_CHECK (NODE)) /* True if NODE is a thin pointer. */ @@ -154,22 +154,22 @@ struct lang_type GTY(()) {tree t; }; /* True if TYPE can alias any other types. */ #define TYPE_UNIVERSAL_ALIASING_P(NODE) TYPE_LANG_FLAG_6 (NODE) -/* This field is only defined for FUNCTION_TYPE nodes. If the Ada - subprogram contains no parameters passed by copy in/copy out then this - field is 0. Otherwise it points to a list of nodes used to specify the - return values of the out (or in out) parameters that qualify to be passed - by copy in copy out. It is a CONSTRUCTOR. For a full description of the - cico parameter passing mechanism refer to the routine gnat_to_gnu_entity. */ -#define TYPE_CI_CO_LIST(NODE) TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE)) +/* This field is only defined for FUNCTION_TYPE nodes. If the Ada subprogram + contains no parameters passed by copy in/copy out then this field is zero. + Otherwise it points to a list of nodes used to specify the return values + of the out (or in out) parameters that qualify to be passed by copy in/ + copy out. For a full description of the copy in/copy out parameter passing + mechanism refer to the routine gnat_to_gnu_entity. */ +#define TYPE_CI_CO_LIST(NODE) TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE)) /* For integral types, this is the RM Size of the type. */ -#define TYPE_RM_SIZE(NODE) \ +#define TYPE_RM_SIZE(NODE) \ TYPE_LANG_SLOT_1 (TREE_CHECK3 (NODE, ENUMERAL_TYPE, BOOLEAN_TYPE, INTEGER_TYPE)) /* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the modulus. */ #define TYPE_MODULUS(NODE) GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) -#define SET_TYPE_MODULUS(NODE, X) \ +#define SET_TYPE_MODULUS(NODE, X) \ SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X) /* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, points to @@ -183,21 +183,21 @@ struct lang_type GTY(()) {tree t; }; Digits_Value. */ #define TYPE_DIGITS_VALUE(NODE) \ GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) -#define SET_TYPE_DIGITS_VALUE(NODE, X) \ +#define SET_TYPE_DIGITS_VALUE(NODE, X) \ SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X) /* For a RECORD_TYPE that is a fat pointer, point to the type for the unconstrained object. Likewise for a RECORD_TYPE that is pointed to by a thin pointer. */ -#define TYPE_UNCONSTRAINED_ARRAY(NODE) \ +#define TYPE_UNCONSTRAINED_ARRAY(NODE) \ GET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE)) -#define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \ +#define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \ SET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE), X) /* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, the Ada size of the object. This differs from the GCC size in that it does not include any rounding up to the alignment of the type. */ -#define TYPE_ADA_SIZE(NODE) \ +#define TYPE_ADA_SIZE(NODE) \ GET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE)) #define SET_TYPE_ADA_SIZE(NODE, X) \ SET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE), X) @@ -205,7 +205,7 @@ struct lang_type GTY(()) {tree t; }; /* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is the index type that should be used when the actual bounds are required for a template. This is used in the case of packed arrays. */ -#define TYPE_ACTUAL_BOUNDS(NODE) \ +#define TYPE_ACTUAL_BOUNDS(NODE) \ GET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE)) #define SET_TYPE_ACTUAL_BOUNDS(NODE, X) \ SET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE), X) @@ -298,24 +298,15 @@ struct lang_type GTY(()) {tree t; }; discriminant number. */ #define DECL_DISCRIMINANT_NUMBER(NODE) DECL_INITIAL (FIELD_DECL_CHECK (NODE)) -/* Define fields and macros for statements. +/* Define fields and macros for statements. */ +#define IS_ADA_STMT(NODE) \ + (STATEMENT_CLASS_P (NODE) && TREE_CODE (NODE) >= STMT_STMT) - Start by defining which tree codes are used for statements. */ -#define IS_STMT(NODE) (STATEMENT_CLASS_P (NODE)) -#define IS_ADA_STMT(NODE) (IS_STMT (NODE) \ - && TREE_CODE (NODE) >= STMT_STMT) - -#define STMT_STMT_STMT(NODE) TREE_OPERAND_CHECK_CODE (NODE, STMT_STMT, 0) +#define STMT_STMT_STMT(NODE) TREE_OPERAND_CHECK_CODE (NODE, STMT_STMT, 0) #define LOOP_STMT_TOP_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 0) #define LOOP_STMT_BOT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 1) -#define LOOP_STMT_UPDATE(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 2) -#define LOOP_STMT_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 3) -#define LOOP_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 4) -#define EXIT_STMT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 0) -#define EXIT_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 1) -#define REGION_STMT_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, REGION_STMT, 0) -#define REGION_STMT_HANDLE(NODE) TREE_OPERAND_CHECK_CODE (NODE, REGION_STMT, 1) -#define REGION_STMT_BLOCK(NODE) TREE_OPERAND_CHECK_CODE (NODE, REGION_STMT, 2) -#define HANDLER_STMT_ARG(NODE) TREE_OPERAND_CHECK_CODE (NODE, HANDLER_STMT, 0) -#define HANDLER_STMT_LIST(NODE) TREE_OPERAND_CHECK_CODE (NODE, HANDLER_STMT, 1) -#define HANDLER_STMT_BLOCK(NODE) TREE_OPERAND_CHECK_CODE(NODE, HANDLER_STMT, 2) +#define LOOP_STMT_UPDATE(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 2) +#define LOOP_STMT_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 3) +#define LOOP_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 4) +#define EXIT_STMT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 0) +#define EXIT_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 1) diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index c13c641f940..31e51b0b34e 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -363,7 +363,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) else max_esize = LONG_LONG_TYPE_SIZE; - esize = MIN (esize, max_esize); + if (esize > max_esize) + esize = max_esize; } else esize = LONG_LONG_TYPE_SIZE; @@ -1578,15 +1579,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_BIASED_REPRESENTATION_P (gnu_type) = Has_Biased_Representation (gnat_entity); - /* This should be an unsigned type if the lower bound is constant - and non-negative or if the base type is unsigned; a signed type - otherwise. */ - TYPE_UNSIGNED (gnu_type) - = (TYPE_UNSIGNED (TREE_TYPE (gnu_type)) - || (TREE_CODE (TYPE_MIN_VALUE (gnu_type)) == INTEGER_CST - && TREE_INT_CST_HIGH (TYPE_MIN_VALUE (gnu_type)) >= 0) - || TYPE_BIASED_REPRESENTATION_P (gnu_type) - || Is_Unsigned_Type (gnat_entity)); + /* This should be an unsigned type if the base type is unsigned or + if the lower bound is constant and non-negative (as computed by + layout_type) or if the type is biased. */ + TYPE_UNSIGNED (gnu_type) = (TYPE_UNSIGNED (TREE_TYPE (gnu_type)) + || TYPE_BIASED_REPRESENTATION_P (gnu_type) + || Is_Unsigned_Type (gnat_entity)); layout_type (gnu_type); @@ -1979,14 +1977,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_NONALIASED_COMPONENT (tem) = 1; } - /* If an alignment is specified, use it if valid. But ignore it for - types that represent the unpacked base type for packed arrays. If - the alignment was requested with an explicit user alignment clause, - state so. */ + /* If an alignment is specified, use it if valid. But ignore it + for the original type of packed array types. If the alignment + was requested with an explicit alignment clause, state so. */ if (No (Packed_Array_Type (gnat_entity)) && Known_Alignment (gnat_entity)) { - gcc_assert (Present (Alignment (gnat_entity))); TYPE_ALIGN (tem) = validate_alignment (Alignment (gnat_entity), gnat_entity, TYPE_ALIGN (tem)); @@ -2124,62 +2120,85 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && TREE_CODE (gnu_min) == INTEGER_CST && TREE_CODE (gnu_max) == INTEGER_CST && TREE_OVERFLOW (gnu_min) && TREE_OVERFLOW (gnu_max) - && (!TREE_OVERFLOW + && !TREE_OVERFLOW (fold_build2 (MINUS_EXPR, gnu_index_subtype, TYPE_MAX_VALUE (gnu_index_subtype), - TYPE_MIN_VALUE (gnu_index_subtype))))) + TYPE_MIN_VALUE (gnu_index_subtype)))) { TREE_OVERFLOW (gnu_min) = 0; TREE_OVERFLOW (gnu_max) = 0; + if (tree_int_cst_lt (gnu_max, gnu_min)) + { + gnu_min = size_one_node; + gnu_max = size_zero_node; + } + gnu_high = gnu_max; } /* Similarly, if the range is null, use bounds of 1..0 for the sizetype bounds. */ else if ((TYPE_PRECISION (gnu_index_subtype) > TYPE_PRECISION (sizetype) - || TYPE_UNSIGNED (gnu_index_subtype) - != TYPE_UNSIGNED (sizetype)) + || TYPE_UNSIGNED (gnu_index_subtype) + != TYPE_UNSIGNED (sizetype)) && TREE_CODE (gnu_min) == INTEGER_CST && TREE_CODE (gnu_max) == INTEGER_CST && (TREE_OVERFLOW (gnu_min) || TREE_OVERFLOW (gnu_max)) && tree_int_cst_lt (TYPE_MAX_VALUE (gnu_index_subtype), TYPE_MIN_VALUE (gnu_index_subtype))) - gnu_min = size_one_node, gnu_max = size_zero_node; - - /* Now compute the size of this bound. We need to provide - GCC with an upper bound to use but have to deal with the - "superflat" case. There are three ways to do this. If we - can prove that the array can never be superflat, we can - just use the high bound of the index subtype. If we can - prove that the low bound minus one can't overflow, we - can do this as MAX (hb, lb - 1). Otherwise, we have to use - the expression hb >= lb ? hb : lb - 1. */ - gnu_high = size_binop (MINUS_EXPR, gnu_min, size_one_node); + { + gnu_min = size_one_node; + gnu_max = size_zero_node; + gnu_high = gnu_max; + } /* See if the base array type is already flat. If it is, we - are probably compiling an ACVC test, but it will cause the + are probably compiling an ACATS test, but it will cause the code below to malfunction if we don't handle it specially. */ - if (TREE_CODE (gnu_base_min) == INTEGER_CST - && TREE_CODE (gnu_base_max) == INTEGER_CST - && !TREE_OVERFLOW (gnu_base_min) - && !TREE_OVERFLOW (gnu_base_max) - && tree_int_cst_lt (gnu_base_max, gnu_base_min)) - gnu_high = size_zero_node, gnu_min = size_one_node; - - /* If gnu_high is now an integer which overflowed, the array - cannot be superflat. */ - else if (TREE_CODE (gnu_high) == INTEGER_CST - && TREE_OVERFLOW (gnu_high)) - gnu_high = gnu_max; - else if (TYPE_UNSIGNED (gnu_base_subtype) - || TREE_CODE (gnu_high) == INTEGER_CST) - gnu_high = size_binop (MAX_EXPR, gnu_max, gnu_high); + else if (TREE_CODE (gnu_base_min) == INTEGER_CST + && TREE_CODE (gnu_base_max) == INTEGER_CST + && !TREE_OVERFLOW (gnu_base_min) + && !TREE_OVERFLOW (gnu_base_max) + && tree_int_cst_lt (gnu_base_max, gnu_base_min)) + { + gnu_min = size_one_node; + gnu_max = size_zero_node; + gnu_high = gnu_max; + } + else - gnu_high - = build_cond_expr - (sizetype, build_binary_op (GE_EXPR, integer_type_node, - gnu_max, gnu_min), - gnu_max, gnu_high); + { + /* Now compute the size of this bound. We need to provide + GCC with an upper bound to use but have to deal with the + "superflat" case. There are three ways to do this. If + we can prove that the array can never be superflat, we + can just use the high bound of the index subtype. If we + can prove that the low bound minus one can't overflow, + we can do this as MAX (hb, lb - 1). Otherwise, we have + to use the expression hb >= lb ? hb : lb - 1. */ + gnu_high = size_binop (MINUS_EXPR, gnu_min, size_one_node); + + /* If gnu_high is now an integer which overflowed, the array + cannot be superflat. */ + if (TREE_CODE (gnu_high) == INTEGER_CST + && TREE_OVERFLOW (gnu_high)) + gnu_high = gnu_max; + + /* gnu_high cannot overflow if the subtype is unsigned since + sizetype is signed, or if it is now a constant that hasn't + overflowed. */ + else if (TYPE_UNSIGNED (gnu_base_subtype) + || TREE_CODE (gnu_high) == INTEGER_CST) + gnu_high = size_binop (MAX_EXPR, gnu_max, gnu_high); + + else + gnu_high + = build_cond_expr (sizetype, + build_binary_op (GE_EXPR, + integer_type_node, + gnu_max, gnu_min), + gnu_max, gnu_high); + } gnu_index_type[index] = create_index_type (gnu_min, gnu_high, gnu_index_subtype, @@ -7338,7 +7357,8 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) break; biased_p |= for_biased; - size = MIN (size, LONG_LONG_TYPE_SIZE); + if (size > LONG_LONG_TYPE_SIZE) + size = LONG_LONG_TYPE_SIZE; if (TYPE_UNSIGNED (type) || biased_p) new_type = make_unsigned_type (size); diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index f4113f81adf..e9f6885abca 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -25,30 +25,6 @@ /* Declare all functions and types used by gigi. */ -/* The largest alignment, in bits, that is needed for using the widest - move instruction. */ -extern unsigned int largest_move_alignment; - -/* Compute the alignment of the largest mode that can be used for copying - objects. */ -extern void gnat_compute_largest_alignment (void); - -/* GNU_TYPE is a type. Determine if it should be passed by reference by - default. */ -extern bool default_pass_by_ref (tree gnu_type); - -/* GNU_TYPE is the type of a subprogram parameter. Determine from the type - if it should be passed by reference. */ -extern bool must_pass_by_ref (tree gnu_type); - -/* Initialize DUMMY_NODE_TABLE. */ -extern void init_dummy_type (void); - -/* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a - GCC type corresponding to that entity. GNAT_ENTITY is assumed to - refer to an Ada type. */ -extern tree gnat_to_gnu_type (Entity_Id gnat_entity); - /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada entity, this routine returns the equivalent GCC tree for that entity (an ..._DECL node) and associates the ..._DECL node with the input GNAT @@ -71,6 +47,10 @@ extern tree gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, FIELD_DECL. */ extern tree gnat_to_gnu_field_decl (Entity_Id gnat_entity); +/* Similar, but GNAT_ENTITY is assumed to refer to a GNAT type. Return + the GCC type corresponding to that entity. */ +extern tree gnat_to_gnu_type (Entity_Id gnat_entity); + /* Wrap up compilation of T, a TYPE_DECL, possibly deferring it. */ extern void rest_of_type_decl_compilation (tree t); @@ -98,7 +78,7 @@ extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity); /* Mark nodes rooted at *TP with TREE_VISITED and types as having their sized gimplified. We use this to indicate all variable sizes and positions in global types may not be shared by any subprogram. */ -extern void mark_visited (tree *); +extern void mark_visited (tree *tp); /* Finalize any From_With_Type incomplete types. We do this after processing our compilation unit and after processing its spec, if this is a body. */ @@ -110,7 +90,7 @@ extern void finalize_from_with_types (void); for its representation, return GNAT_ENTITY. If a type is supposed to exist, but does not, abort unless annotating types, in which case return Empty. If GNAT_ENTITY is Empty, return Empty. */ -extern Entity_Id Gigi_Equivalent_Type (Entity_Id); +extern Entity_Id Gigi_Equivalent_Type (Entity_Id gnat_entity); /* Given GNAT_ENTITY, elaborate all expressions that are required to be elaborated at the point of its definition, but do nothing else. */ @@ -120,9 +100,6 @@ extern void elaborate_entity (Entity_Id gnat_entity); any entities on its entity chain similarly. */ extern void mark_out_of_scope (Entity_Id gnat_entity); -/* Make a dummy type corresponding to GNAT_TYPE. */ -extern tree make_dummy_type (Entity_Id gnat_type); - /* Get the unpadded version of a GNAT type. */ extern tree get_unpadded_type (Entity_Id gnat_entity); @@ -227,7 +204,7 @@ extern tree gnat_to_gnu (Node_Id gnat_node); /* GNU_STMT is a statement. We generate code for that statement. */ extern void gnat_expand_stmt (tree gnu_stmt); -/* ??? missing documentation */ +/* Generate GIMPLE in place for the expression at *EXPR_P. */ extern int gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p ATTRIBUTE_UNUSED); @@ -244,7 +221,7 @@ extern bool Sloc_to_locus (Source_Ptr Sloc, location_t *locus); /* Post an error message. MSG is the error message, properly annotated. NODE is the node at which to post the error and the node to use for the "&" substitution. */ -extern void post_error (const char *, Node_Id); +extern void post_error (const char *msg, Node_Id node); /* Similar, but NODE is the node at which to post the error and ENT is the node to use for the "&" substitution. */ @@ -273,7 +250,7 @@ extern tree protect_multiple_eval (tree exp); /* Return a label to branch to for the exception type in KIND or NULL_TREE if none. */ -extern tree get_exception_label (char); +extern tree get_exception_label (char kind); /* Current node being treated, in case gigi_abort or Check_Elaboration_Code called. */ @@ -381,7 +358,7 @@ enum standard_datatypes /* Function declaration nodes for run-time functions for allocating memory. Ada allocators cause calls to these functions to be generated. Malloc32 - is used only on 64bit systems needing to allocate 32bit memory. */ + is used only on 64bit systems needing to allocate 32bit memory. */ ADT_malloc_decl, ADT_malloc32_decl, @@ -442,7 +419,7 @@ extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1]; /* Returns nonzero if we are currently in the global binding level. */ extern int global_bindings_p (void); -/* Enter and exit a new binding level. */ +/* Enter and exit a new binding level. */ extern void gnat_pushlevel (void); extern void gnat_poplevel (void); @@ -496,6 +473,9 @@ extern tree convert (tree type, tree expr); /* Routines created solely for the tree translator's sake. Their prototypes can be changed as desired. */ +/* Initialize the association of GNAT nodes to GCC trees. */ +extern void init_gnat_to_gnu (void); + /* GNAT_ENTITY is a GNAT tree node for a defining identifier. GNU_DECL is the GCC tree which is to be associated with GNAT_ENTITY. Such gnu tree node is always an ..._DECL node. @@ -512,8 +492,11 @@ extern tree get_gnu_tree (Entity_Id gnat_entity); /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */ extern bool present_gnu_tree (Entity_Id gnat_entity); -/* Initialize tables for above routines. */ -extern void init_gnat_to_gnu (void); +/* Initialize the association of GNAT nodes to GCC trees as dummies. */ +extern void init_dummy_type (void); + +/* Make a dummy type corresponding to GNAT_TYPE. */ +extern tree make_dummy_type (Entity_Id gnat_type); /* Record TYPE as a builtin type for Ada. NAME is the name of the type. */ extern void record_builtin_type (const char *name, tree type); @@ -600,7 +583,7 @@ extern tree create_type_decl (tree type_name, tree type, it indicates whether to always allocate storage to the variable. GNAT_NODE is used for the position of the decl. */ -tree +extern tree create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, bool const_flag, bool public_flag, bool extern_flag, bool static_flag, bool const_decl_allowed_p, @@ -629,11 +612,11 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, /* Given a DECL and ATTR_LIST, apply the listed attributes. */ extern void process_attributes (tree decl, struct attrib *attr_list); -/* Record a global renaming pointer. */ -void record_global_renaming_pointer (tree); +/* Record DECL as a global renaming pointer. */ +extern void record_global_renaming_pointer (tree decl); -/* Invalidate the global renaming pointers. */ -void invalidate_global_renaming_pointers (void); +/* Invalidate the global renaming pointers. */ +extern void invalidate_global_renaming_pointers (void); /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if @@ -648,7 +631,7 @@ extern tree create_field_decl (tree field_name, tree field_type, /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter, PARAM_TYPE is its type. READONLY is true if the parameter is readonly (either an In parameter or an address of a pass-by-ref - parameter). */ + parameter). */ extern tree create_param_decl (tree param_name, tree param_type, bool readonly); @@ -692,7 +675,7 @@ extern tree build_template (tree template_type, tree array_type, tree expr); extern tree build_vms_descriptor (tree type, Mechanism_Type mech, Entity_Id gnat_entity); -/* Build a 32bit VMS descriptor from a Mechanism_Type. See above. */ +/* Build a 32bit VMS descriptor from a Mechanism_Type. See above. */ extern tree build_vms_descriptor32 (tree type, Mechanism_Type mech, Entity_Id gnat_entity); @@ -710,7 +693,7 @@ extern tree build_unc_object_type (tree template_type, tree object_type, tree name); /* Same as build_unc_object_type, but taking a thin or fat pointer type - instead of the template type. */ + instead of the template type. */ extern tree build_unc_object_type_from_ptr (tree thin_fat_ptr_type, tree object_type, tree name); @@ -743,13 +726,13 @@ extern tree maybe_unconstrained_array (tree exp); If NOTRUNC_P is true, truncation operations should be suppressed. */ extern tree unchecked_convert (tree type, tree expr, bool notrunc_p); -/* Return the appropriate GCC tree code for the specified GNAT type, +/* Return the appropriate GCC tree code for the specified GNAT_TYPE, the latter being a record type as predicated by Is_Record_Type. */ -extern enum tree_code tree_code_for_record_type (Entity_Id); +extern enum tree_code tree_code_for_record_type (Entity_Id gnat_type); /* Return true if GNU_TYPE is suitable as the type of a non-aliased component of an aggregate type. */ -extern bool type_for_nonaliased_component_p (tree); +extern bool type_for_nonaliased_component_p (tree gnu_type); /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical operation. @@ -775,7 +758,7 @@ extern tree get_base_type (tree type); extern unsigned int known_alignment (tree exp); /* Return true if VALUE is a multiple of FACTOR. FACTOR must be a power - of 2. */ + of 2. */ extern bool value_factor_p (tree value, HOST_WIDE_INT factor); /* Make a binary operation of kind OP_CODE. RESULT_TYPE is the type @@ -785,7 +768,7 @@ extern bool value_factor_p (tree value, HOST_WIDE_INT factor); extern tree build_binary_op (enum tree_code op_code, tree result_type, tree left_operand, tree right_operand); -/* Similar, but make unary operation. */ +/* Similar, but make unary operation. */ extern tree build_unary_op (enum tree_code op_code, tree result_type, tree operand); @@ -870,6 +853,14 @@ extern tree gnat_builtin_function (tree decl); Return the first node found, if any, or NULL_TREE otherwise. */ extern tree builtin_decl_for (tree name); +/* GNU_TYPE is a type. Determine if it should be passed by reference by + default. */ +extern bool default_pass_by_ref (tree gnu_type); + +/* GNU_TYPE is the type of a subprogram parameter. Determine from the type + if it should be passed by reference. */ +extern bool must_pass_by_ref (tree gnu_type); + /* This function is called by the front end to enumerate all the supported modes for the machine. We pass a function which is called back with the following integer parameters: @@ -884,9 +875,10 @@ extern tree builtin_decl_for (tree name); extern void enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int)); -/* These are temporary function to deal with recent GCC changes related to - FP type sizes and precisions. */ +/* Return the size of the FP mode with precision PREC. */ extern int fp_prec_to_size (int prec); + +/* Return the precision of the FP mode with size SIZE. */ extern int fp_size_to_prec (int size); /* These functions return the basic data type sizes and related parameters @@ -922,7 +914,7 @@ extern Nat get_strict_alignment (void); /* VMS macro set by default, when clear forces 32bit mallocs and 32bit Descriptors. Always used in combination with TARGET_ABI_OPEN_VMS - so no effect on non-VMS systems. */ + so no effect on non-VMS systems. */ #ifndef TARGET_MALLOC64 #define TARGET_MALLOC64 0 #endif diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 6edf7f49bb7..c35a9c37848 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -72,14 +72,7 @@ #include "opts.h" #include "options.h" -extern FILE *asm_out_file; - -/* The largest alignment, in bits, that is needed for using the widest - move instruction. */ -unsigned int largest_move_alignment; - static bool gnat_init (void); -static void gnat_finish_incomplete_decl (tree); static unsigned int gnat_init_options (unsigned int, const char **); static int gnat_handle_option (size_t, const char *, int); static bool gnat_post_options (const char **); @@ -118,8 +111,6 @@ static tree gnat_type_max_size (const_tree); #define LANG_HOOKS_PUSHDECL gnat_return_tree #undef LANG_HOOKS_WRITE_GLOBALS #define LANG_HOOKS_WRITE_GLOBALS gnat_write_global_declarations -#undef LANG_HOOKS_FINISH_INCOMPLETE_DECL -#define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl #undef LANG_HOOKS_GET_ALIAS_SET #define LANG_HOOKS_GET_ALIAS_SET gnat_get_alias_set #undef LANG_HOOKS_MARK_ADDRESSABLE @@ -153,18 +144,14 @@ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; are incompatible with regular GDB versions, so we must make sure to only produce them on explicit request. This is eventually reflected into the use_gnu_debug_info_extensions common flag for later processing. */ - static int gnat_dwarf_extensions = 0; -/* Command-line argc and argv. - These variables are global, since they are imported and used in - back_end.adb */ - +/* Command-line argc and argv. These variables are global + since they are imported in back_end.adb. */ unsigned int save_argc; const char **save_argv; -/* gnat standard argc argv */ - +/* GNAT argc and argv. */ extern int gnat_argc; extern char **gnat_argv; @@ -202,8 +189,8 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) /* Decode all the language specific options that cannot be decoded by GCC. The option decoding phase of GCC calls this routine on the flags that - it cannot decode. This routine returns the number of consecutive arguments - from ARGV that it successfully decoded; 0 indicates failure. */ + it cannot decode. Return the number of consecutive arguments from ARGV + that have been successfully decoded or 0 on failure. */ static int gnat_handle_option (size_t scode, const char *arg, int value) @@ -427,34 +414,6 @@ gnat_init (void) return true; } -/* This function is called indirectly from toplev.c to handle incomplete - declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise, - compile_file in toplev.c makes an indirect call through the function pointer - incomplete_decl_finalize_hook which is initialized to this routine in - init_decl_processing. */ - -static void -gnat_finish_incomplete_decl (tree dont_care ATTRIBUTE_UNUSED) -{ - gcc_unreachable (); -} - -/* Compute the alignment of the largest mode that can be used for copying - objects. */ - -void -gnat_compute_largest_alignment (void) -{ - enum machine_mode mode; - - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) - if (optab_handler (mov_optab, mode)->insn_code != CODE_FOR_nothing) - largest_move_alignment = MIN (BIGGEST_ALIGNMENT, - MAX (largest_move_alignment, - GET_MODE_ALIGNMENT (mode))); -} - /* If we are using the GCC mechanism to process exception handling, we have to register the personality routine for Ada and to initialize various language dependent hooks. */ @@ -506,7 +465,7 @@ gnat_init_gcc_eh (void) #endif } -/* Language hooks, first one to print language-specific items in a DECL. */ +/* Print language-specific items in declaration NODE. */ static void gnat_print_decl (FILE *file, tree node, int indent) @@ -533,6 +492,8 @@ gnat_print_decl (FILE *file, tree node, int indent) } } +/* Print language-specific items in type NODE. */ + static void gnat_print_type (FILE *file, tree node, int indent) { @@ -542,11 +503,6 @@ gnat_print_type (FILE *file, tree node, int indent) print_node (file, "ci_co_list", TYPE_CI_CO_LIST (node), indent + 4); break; - case ENUMERAL_TYPE: - case BOOLEAN_TYPE: - print_node (file, "RM size", TYPE_RM_SIZE (node), indent + 4); - break; - case INTEGER_TYPE: if (TYPE_MODULAR_P (node)) print_node (file, "modulus", TYPE_MODULUS (node), indent + 4); @@ -558,6 +514,10 @@ gnat_print_type (FILE *file, tree node, int indent) else print_node (file, "index type", TYPE_INDEX_TYPE (node), indent + 4); + /* ... fall through ... */ + + case ENUMERAL_TYPE: + case BOOLEAN_TYPE: print_node (file, "RM size", TYPE_RM_SIZE (node), indent + 4); break; @@ -583,13 +543,7 @@ gnat_print_type (FILE *file, tree node, int indent) } } -static const char * -gnat_dwarf_name (tree t, int verbosity ATTRIBUTE_UNUSED) -{ - gcc_assert (DECL_P (t)); - - return (const char *) IDENTIFIER_POINTER (DECL_NAME (t)); -} +/* Return the name to be printed for DECL. */ static const char * gnat_printable_name (tree decl, int verbosity) @@ -604,8 +558,17 @@ gnat_printable_name (tree decl, int verbosity) Set_Identifier_Casing (ada_name, (char *) DECL_SOURCE_FILE (decl)); return ggc_strdup (Name_Buffer); } - else - return ada_name; + + return ada_name; +} + +/* Return the name to be used in DWARF debug info for DECL. */ + +static const char * +gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED) +{ + gcc_assert (DECL_P (decl)); + return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl)); } /* Do nothing (return the tree node passed). */ @@ -810,6 +773,8 @@ enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int)) } } +/* Return the size of the FP mode with precision PREC. */ + int fp_prec_to_size (int prec) { @@ -823,6 +788,8 @@ fp_prec_to_size (int prec) gcc_unreachable (); } +/* Return the precision of the FP mode with size SIZE. */ + int fp_size_to_prec (int size) { diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 84aa3963910..807b370e077 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -301,7 +301,6 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, /* Initialize ourselves. */ init_code_table (); init_gnat_to_gnu (); - gnat_compute_largest_alignment (); init_dummy_type (); /* If we are just annotating types, give VOID_TYPE zero sizes to avoid @@ -1058,7 +1057,7 @@ Pragma_to_gnu (Node_Id gnat_node) return gnu_result; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an N_Attribute, +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Attribute node, to a GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer to where we should place the result type. ATTRIBUTE is the attribute ID. */ @@ -1075,20 +1074,19 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) /* If the input is a NULL_EXPR, make a new one. */ if (TREE_CODE (gnu_prefix) == NULL_EXPR) { - *gnu_result_type_p = get_unpadded_type (Etype (gnat_node)); - return build1 (NULL_EXPR, *gnu_result_type_p, - TREE_OPERAND (gnu_prefix, 0)); + gnu_result_type = get_unpadded_type (Etype (gnat_node)); + *gnu_result_type_p = gnu_result_type; + return build1 (NULL_EXPR, gnu_result_type, TREE_OPERAND (gnu_prefix, 0)); } switch (attribute) { case Attr_Pos: case Attr_Val: - /* These are just conversions until since representation clauses for - enumerations are handled in the front end. */ + /* These are just conversions since representation clauses for + enumeration types are handled in the front-end. */ { bool checkp = Do_Range_Check (First (Expressions (gnat_node))); - gnu_result = gnat_to_gnu (First (Expressions (gnat_node))); gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result = convert_with_check (Etype (gnat_node), gnu_result, @@ -1098,8 +1096,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) case Attr_Pred: case Attr_Succ: - /* These just add or subject the constant 1. Representation clauses for - enumerations are handled in the front-end. */ + /* These just add or subtract the constant 1 since representation + clauses for enumeration types are handled in the front-end. */ gnu_expr = gnat_to_gnu (First (Expressions (gnat_node))); gnu_result_type = get_unpadded_type (Etype (gnat_node)); @@ -1117,16 +1115,15 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) } gnu_result - = build_binary_op (attribute == Attr_Pred - ? MINUS_EXPR : PLUS_EXPR, + = build_binary_op (attribute == Attr_Pred ? MINUS_EXPR : PLUS_EXPR, gnu_result_type, gnu_expr, convert (gnu_result_type, integer_one_node)); break; case Attr_Address: case Attr_Unrestricted_Access: - /* Conversions don't change something's address but can cause us to miss - the COMPONENT_REF case below, so strip them off. */ + /* Conversions don't change addresses but can cause us to miss the + COMPONENT_REF case below, so strip them off. */ gnu_prefix = remove_conversions (gnu_prefix, !Must_Be_Byte_Aligned (gnat_node)); @@ -1237,9 +1234,9 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) gnu_result_type = get_unpadded_type (Etype (gnat_node)); - /* If this is an unconstrained array, we know the object must have been - allocated with the template in front of the object. So compute the - template address.*/ + /* If this is an unconstrained array, we know the object has been + allocated with the template in front of the object. So compute + the template address. */ if (TYPE_FAT_POINTER_P (TREE_TYPE (gnu_ptr))) gnu_ptr = convert (build_pointer_type @@ -1273,7 +1270,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) case Attr_Max_Size_In_Storage_Elements: gnu_expr = gnu_prefix; - /* Remove NOPS from gnu_expr and conversions from gnu_prefix. + /* Remove NOPs from GNU_EXPR and conversions from GNU_PREFIX. We only use GNU_EXPR to see if a COMPONENT_REF was involved. */ while (TREE_CODE (gnu_expr) == NOP_EXPR) gnu_expr = TREE_OPERAND (gnu_expr, 0); @@ -1351,8 +1348,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) gcc_assert (gnu_result); - /* Deal with a self-referential size by returning the maximum size for a - type and by qualifying the size with the object for 'Size of an + /* Deal with a self-referential size by returning the maximum size for + a type and by qualifying the size with the object for 'Size of an object. */ if (CONTAINS_PLACEHOLDER_P (gnu_result)) { @@ -1521,7 +1518,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) much rarer cases, for extremely large arrays we expect never to encounter in practice. In addition, the former computation required the use of potentially constraining - signed arithmetic while the latter doesn't. Note that the + signed arithmetic while the latter doesn't. Note that the comparison must be done in the original index base type, otherwise the conversion of either bound to gnu_compute_type may overflow. */ @@ -1663,8 +1660,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) break; } - /* If this has a PLACEHOLDER_EXPR, qualify it by the object - we are handling. */ + /* If this has a PLACEHOLDER_EXPR, qualify it by the object we are + handling. */ gnu_result = SUBSTITUTE_PLACEHOLDER_IN_EXPR (gnu_result, gnu_prefix); break; } @@ -1714,8 +1711,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) break; case Attr_Null_Parameter: - /* This is just a zero cast to the pointer type for - our prefix and dereferenced. */ + /* This is just a zero cast to the pointer type for our prefix and + dereferenced. */ gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result = build_unary_op (INDIRECT_REF, NULL_TREE, @@ -1755,8 +1752,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) default: /* Say we have an unimplemented attribute. Then set the value to be - returned to be a zero and hope that's something we can convert to the - type of this attribute. */ + returned to be a zero and hope that's something we can convert to + the type of this attribute. */ post_error ("unimplemented attribute", gnat_node); gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result = integer_zero_node; diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 5e713437152..b2c4399a410 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -1472,10 +1472,13 @@ create_field_decl (tree field_name, tree field_type, tree record_type, DECL_BIT_FIELD (field_decl) = 1; DECL_SIZE (field_decl) = size; if (!packed && !pos) - DECL_ALIGN (field_decl) - = (TYPE_ALIGN (record_type) != 0 - ? MIN (TYPE_ALIGN (record_type), TYPE_ALIGN (field_type)) - : TYPE_ALIGN (field_type)); + { + if (TYPE_ALIGN (record_type) != 0 + && TYPE_ALIGN (record_type) < TYPE_ALIGN (field_type)) + DECL_ALIGN (field_decl) = TYPE_ALIGN (record_type); + else + DECL_ALIGN (field_decl) = TYPE_ALIGN (field_type); + } } DECL_PACKED (field_decl) = pos ? DECL_BIT_FIELD (field_decl) : packed; @@ -1636,7 +1639,7 @@ process_attributes (tree decl, struct attrib *attr_list) } } -/* Record a global renaming pointer. */ +/* Record DECL as a global renaming pointer. */ void record_global_renaming_pointer (tree decl) @@ -4520,7 +4523,7 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) return expr; } -/* Return the appropriate GCC tree code for the specified GNAT type, +/* Return the appropriate GCC tree code for the specified GNAT_TYPE, the latter being a record type as predicated by Is_Record_Type. */ enum tree_code -- 2.11.0