diff options
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils2.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 6ff1372..c8a2d7c 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -6,7 +6,7 @@ * * * C Implementation 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- * @@ -32,6 +32,7 @@ #include "alias.h" #include "tree.h" #include "inchash.h" +#include "builtins.h" #include "fold-const.h" #include "stor-layout.h" #include "stringpool.h" @@ -167,7 +168,10 @@ known_alignment (tree exp) break; case ADDR_EXPR: - this_alignment = expr_align (TREE_OPERAND (exp, 0)); + if (DECL_P (TREE_OPERAND (exp, 0))) + this_alignment = DECL_ALIGN (TREE_OPERAND (exp, 0)); + else + this_alignment = get_object_alignment (TREE_OPERAND (exp, 0)); break; case CALL_EXPR: @@ -871,31 +875,21 @@ build_binary_op (enum tree_code op_code, tree result_type, /* If there were integral or pointer conversions on the LHS, remove them; we'll be putting them back below if needed. Likewise for - conversions between array and record types, except for justified - modular types. But don't do this if the right operand is not - BLKmode (for packed arrays) unless we are not changing the mode. */ + conversions between record types, except for justified modular types. + But don't do this if the right operand is not BLKmode (for packed + arrays) unless we are not changing the mode. */ while ((CONVERT_EXPR_P (left_operand) || TREE_CODE (left_operand) == VIEW_CONVERT_EXPR) && (((INTEGRAL_TYPE_P (left_type) || POINTER_TYPE_P (left_type)) - && (INTEGRAL_TYPE_P (TREE_TYPE - (TREE_OPERAND (left_operand, 0))) - || POINTER_TYPE_P (TREE_TYPE - (TREE_OPERAND (left_operand, 0))))) - || (((TREE_CODE (left_type) == RECORD_TYPE - && !TYPE_JUSTIFIED_MODULAR_P (left_type)) - || TREE_CODE (left_type) == ARRAY_TYPE) - && ((TREE_CODE (TREE_TYPE - (TREE_OPERAND (left_operand, 0))) - == RECORD_TYPE) - || (TREE_CODE (TREE_TYPE - (TREE_OPERAND (left_operand, 0))) - == ARRAY_TYPE)) + && (INTEGRAL_TYPE_P (operand_type (left_operand)) + || POINTER_TYPE_P (operand_type (left_operand)))) + || (TREE_CODE (left_type) == RECORD_TYPE + && !TYPE_JUSTIFIED_MODULAR_P (left_type) + && TREE_CODE (operand_type (left_operand)) == RECORD_TYPE && (TYPE_MODE (right_type) == BLKmode - || (TYPE_MODE (left_type) - == TYPE_MODE (TREE_TYPE - (TREE_OPERAND - (left_operand, 0)))))))) + || TYPE_MODE (left_type) + == TYPE_MODE (operand_type (left_operand)))))) { left_operand = TREE_OPERAND (left_operand, 0); left_type = TREE_TYPE (left_operand); @@ -917,8 +911,7 @@ build_binary_op (enum tree_code op_code, tree result_type, && TREE_CONSTANT (TYPE_SIZE (left_type)) && ((TREE_CODE (right_operand) == COMPONENT_REF && TYPE_MAIN_VARIANT (left_type) - == TYPE_MAIN_VARIANT - (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) + == TYPE_MAIN_VARIANT (operand_type (right_operand))) || (TREE_CODE (right_operand) == CONSTRUCTOR && !CONTAINS_PLACEHOLDER_P (DECL_SIZE (TYPE_FIELDS (left_type))))) @@ -972,22 +965,23 @@ build_binary_op (enum tree_code op_code, tree result_type, || TREE_CODE (result) == ARRAY_RANGE_REF) while (handled_component_p (result)) result = TREE_OPERAND (result, 0); + else if (TREE_CODE (result) == REALPART_EXPR || TREE_CODE (result) == IMAGPART_EXPR || (CONVERT_EXPR_P (result) && (((TREE_CODE (restype) - == TREE_CODE (TREE_TYPE - (TREE_OPERAND (result, 0)))) - && (TYPE_MODE (TREE_TYPE - (TREE_OPERAND (result, 0))) - == TYPE_MODE (restype))) + == TREE_CODE (operand_type (result)) + && TYPE_MODE (restype) + == TYPE_MODE (operand_type (result)))) || TYPE_ALIGN_OK (restype)))) result = TREE_OPERAND (result, 0); + else if (TREE_CODE (result) == VIEW_CONVERT_EXPR) { TREE_ADDRESSABLE (result) = 1; result = TREE_OPERAND (result, 0); } + else break; } @@ -1036,8 +1030,15 @@ build_binary_op (enum tree_code op_code, tree result_type, /* For a range, make sure the element type is consistent. */ if (op_code == ARRAY_RANGE_REF && TREE_TYPE (operation_type) != TREE_TYPE (left_type)) - operation_type = build_array_type (TREE_TYPE (left_type), - TYPE_DOMAIN (operation_type)); + { + operation_type + = build_nonshared_array_type (TREE_TYPE (left_type), + TYPE_DOMAIN (operation_type)); + /* Declare it now since it will never be declared otherwise. This + is necessary to ensure that its subtrees are properly marked. */ + create_type_decl (TYPE_NAME (operation_type), operation_type, true, + false, Empty); + } /* Then convert the right operand to its base type. This will prevent unneeded sign conversions when sizetype is wider than integer. */ @@ -1996,6 +1997,8 @@ build_simple_component_ref (tree record, tree field, bool no_fold) tree type = TYPE_MAIN_VARIANT (TREE_TYPE (record)); tree ref; + /* The failure of this assertion will very likely come from a missing + insertion of an explicit dereference. */ gcc_assert (RECORD_OR_UNION_TYPE_P (type) && COMPLETE_TYPE_P (type)); /* Try to fold a conversion from another record or union type unless the type @@ -2916,7 +2919,7 @@ is_simple_additive_expression (tree expr, tree *add, tree *cst, bool *minus_p) tree gnat_invariant_expr (tree expr) { - const tree type = TREE_TYPE (expr); + tree type = TREE_TYPE (expr); tree add, cst; bool minus_p; @@ -2930,8 +2933,7 @@ gnat_invariant_expr (tree expr) { expr = DECL_INITIAL (expr); /* Look into CONSTRUCTORs built to initialize padded types. */ - if (TYPE_IS_PADDING_P (TREE_TYPE (expr))) - expr = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))), expr); + expr = maybe_padded_object (expr); expr = remove_conversions (expr, false); } |