X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Fada%2Fgcc-interface%2Futils.c;h=f35e9c729d72749e6f904f029ad0d7df6d141144;hp=cf0ff60b485aff1014bad6c4c8acab31b14df5e1;hb=18a49466c972ff6bc70f5da5645eefcde97e1ab8;hpb=2b1615767dd173780b0b3498ab32a5b112bf7270 diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index cf0ff60b485..f35e9c729d7 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -294,8 +294,8 @@ make_dummy_type (Entity_Id gnat_type) TYPE_DUMMY_P (gnu_type) = 1; TYPE_STUB_DECL (gnu_type) = create_type_stub_decl (TYPE_NAME (gnu_type), gnu_type); - if (AGGREGATE_TYPE_P (gnu_type) && Is_By_Reference_Type (gnat_type)) - TYPE_BY_REFERENCE_P (gnu_type) = 1; + if (AGGREGATE_TYPE_P (gnu_type)) + TYPE_BY_REFERENCE_P (gnu_type) = Is_By_Reference_Type (gnat_type); SET_DUMMY_NODE (gnat_underlying, gnu_type); @@ -3587,7 +3587,7 @@ convert_to_fat_pointer (tree type, tree expr) { tree fields = TYPE_FIELDS (TREE_TYPE (etype)); - expr = gnat_protect_expr (expr); + expr = protect_multiple_eval (expr); if (TREE_CODE (expr) == ADDR_EXPR) expr = TREE_OPERAND (expr, 0); else @@ -3656,12 +3656,12 @@ convert_to_thin_pointer (tree type, tree expr) tree convert (tree type, tree expr) { + enum tree_code code = TREE_CODE (type); tree etype = TREE_TYPE (expr); enum tree_code ecode = TREE_CODE (etype); - enum tree_code code = TREE_CODE (type); - /* If the expression is already of the right type, we are done. */ - if (etype == type) + /* If EXPR is already the right type, we are done. */ + if (type == etype) return expr; /* If both input and output have padding and are of variable size, do this @@ -3708,7 +3708,7 @@ convert (tree type, tree expr) /* If the inner type is of self-referential size and the expression type is a record, do this as an unchecked conversion. But first pad the expression if possible to have the same size on both sides. */ - if (ecode == RECORD_TYPE + if (TREE_CODE (etype) == RECORD_TYPE && CONTAINS_PLACEHOLDER_P (DECL_SIZE (TYPE_FIELDS (type)))) { if (TREE_CONSTANT (TYPE_SIZE (etype))) @@ -3721,7 +3721,7 @@ convert (tree type, tree expr) final conversion as an unchecked conversion, again to avoid the need for some variable-sized temporaries. If valid, this conversion is very likely purely technical and without real effects. */ - if (ecode == ARRAY_TYPE + if (TREE_CODE (etype) == ARRAY_TYPE && TREE_CODE (TREE_TYPE (TYPE_FIELDS (type))) == ARRAY_TYPE && !TREE_CONSTANT (TYPE_SIZE (etype)) && !TREE_CONSTANT (TYPE_SIZE (type))) @@ -4000,6 +4000,25 @@ convert (tree type, tree expr) } break; + case INDIRECT_REF: + /* If both types are record types, just convert the pointer and + make a new INDIRECT_REF. + + ??? Disable this for now since it causes problems with the + code in build_binary_op for MODIFY_EXPR which wants to + strip off conversions. But that code really is a mess and + we need to do this a much better way some time. */ + if (0 + && (TREE_CODE (type) == RECORD_TYPE + || TREE_CODE (type) == UNION_TYPE) + && (TREE_CODE (etype) == RECORD_TYPE + || TREE_CODE (etype) == UNION_TYPE) + && !TYPE_IS_FAT_POINTER_P (type) && !TYPE_IS_FAT_POINTER_P (etype)) + return build_unary_op (INDIRECT_REF, NULL_TREE, + convert (build_pointer_type (type), + TREE_OPERAND (expr, 0))); + break; + default: break; } @@ -4255,13 +4274,12 @@ maybe_unconstrained_array (tree exp) build_component_ref (new_exp, NULL_TREE, TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new_exp))), - false); + 0); } else if (TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (exp))) return build_component_ref (exp, NULL_TREE, - TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (exp))), - false); + TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (exp))), 0); break; default: @@ -4340,26 +4358,29 @@ tree unchecked_convert (tree type, tree expr, bool notrunc_p) { tree etype = TREE_TYPE (expr); - enum tree_code ecode = TREE_CODE (etype); - enum tree_code code = TREE_CODE (type); - /* If the expression is already of the right type, we are done. */ + /* If the expression is already the right type, we are done. */ if (etype == type) return expr; /* If both types types are integral just do a normal conversion. Likewise for a conversion to an unconstrained array. */ if ((((INTEGRAL_TYPE_P (type) - && !(code == INTEGER_TYPE && TYPE_VAX_FLOATING_POINT_P (type))) + && !(TREE_CODE (type) == INTEGER_TYPE + && TYPE_VAX_FLOATING_POINT_P (type))) || (POINTER_TYPE_P (type) && ! TYPE_IS_THIN_POINTER_P (type)) - || (code == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (type))) + || (TREE_CODE (type) == RECORD_TYPE + && TYPE_JUSTIFIED_MODULAR_P (type))) && ((INTEGRAL_TYPE_P (etype) - && !(ecode == INTEGER_TYPE && TYPE_VAX_FLOATING_POINT_P (etype))) + && !(TREE_CODE (etype) == INTEGER_TYPE + && TYPE_VAX_FLOATING_POINT_P (etype))) || (POINTER_TYPE_P (etype) && !TYPE_IS_THIN_POINTER_P (etype)) - || (ecode == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (etype)))) - || code == UNCONSTRAINED_ARRAY_TYPE) + || (TREE_CODE (etype) == RECORD_TYPE + && TYPE_JUSTIFIED_MODULAR_P (etype)))) + || TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) { - if (ecode == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (etype)) + if (TREE_CODE (etype) == INTEGER_TYPE + && TYPE_BIASED_REPRESENTATION_P (etype)) { tree ntype = copy_type (etype); TYPE_BIASED_REPRESENTATION_P (ntype) = 0; @@ -4367,7 +4388,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) expr = build1 (NOP_EXPR, ntype, expr); } - if (code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type)) + if (TREE_CODE (type) == INTEGER_TYPE + && TYPE_BIASED_REPRESENTATION_P (type)) { tree rtype = copy_type (type); TYPE_BIASED_REPRESENTATION_P (rtype) = 0; @@ -4394,7 +4416,7 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) layout_type (rec_type); expr = unchecked_convert (rec_type, expr, notrunc_p); - expr = build_component_ref (expr, NULL_TREE, field, false); + expr = build_component_ref (expr, NULL_TREE, field, 0); } /* Similarly if we are converting from an integral type whose precision @@ -4418,7 +4440,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) /* We have a special case when we are converting between two unconstrained array types. In that case, take the address, convert the fat pointer types, and dereference. */ - else if (ecode == code && code == UNCONSTRAINED_ARRAY_TYPE) + else if (TREE_CODE (etype) == UNCONSTRAINED_ARRAY_TYPE + && TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) expr = build_unary_op (INDIRECT_REF, NULL_TREE, build1 (VIEW_CONVERT_EXPR, TREE_TYPE (type), build_unary_op (ADDR_EXPR, NULL_TREE, @@ -4426,8 +4449,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) /* Another special case is when we are converting to a vector type from its representative array type; this a regular conversion. */ - else if (code == VECTOR_TYPE - && ecode == ARRAY_TYPE + else if (TREE_CODE (type) == VECTOR_TYPE + && TREE_CODE (etype) == ARRAY_TYPE && gnat_types_compatible_p (TYPE_REPRESENTATIVE_ARRAY (type), etype)) expr = convert (type, expr); @@ -4436,7 +4459,6 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) { expr = maybe_unconstrained_array (expr); etype = TREE_TYPE (expr); - ecode = TREE_CODE (etype); if (can_fold_for_view_convert_p (expr)) expr = fold_build1 (VIEW_CONVERT_EXPR, type, expr); else @@ -4449,7 +4471,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) is a biased type or if both the input and output are unsigned. */ if (!notrunc_p && INTEGRAL_TYPE_P (type) && TYPE_RM_SIZE (type) - && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type)) + && !(TREE_CODE (type) == INTEGER_TYPE + && TYPE_BIASED_REPRESENTATION_P (type)) && 0 != compare_tree_int (TYPE_RM_SIZE (type), GET_MODE_BITSIZE (TYPE_MODE (type))) && !(INTEGRAL_TYPE_P (etype) @@ -4460,8 +4483,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) 0)) && !(TYPE_UNSIGNED (type) && TYPE_UNSIGNED (etype))) { - tree base_type - = gnat_type_for_mode (TYPE_MODE (type), TYPE_UNSIGNED (type)); + tree base_type = gnat_type_for_mode (TYPE_MODE (type), + TYPE_UNSIGNED (type)); tree shift_expr = convert (base_type, size_binop (MINUS_EXPR,