From 8afc118e11c9b2091f76c5e44fe7e6ad28820d7e Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 10 Feb 2005 14:53:21 +0100 Subject: Fix for c330001 - PR ada/19386 2005-02-09 Eric Botcazou Richard Kenner Fix for c330001 - PR ada/19386 * decl.c: (gnat_to_gnu_field): Do not necessarily invoke make_packable_type on the field if Pragma Component_Alignment (Storage_Unit). (gnat_to_gnu_entity, case object): Do not treat a renaming that has side-effects as if it were a constant; also make SAVE_EXPR to protect side-effects. (gnat_to_gnu_entity, case E_Record_Subtype): If have _Parent, make a UNION_TYPE. (make_dummy_type): Set TYPE_UNCHECKED_UNION_P. (components_to_record): Test it. Fix improper usage of REFERENCE_CLASS_P. * utils2.c (build_binary_op, case MODIFY_EXPRP): Treat UNION_TYPE as RECORD_TYPE. * utils2.c: Minor reformatting. * utils.c (convert, case UNION_TYPE): Check TYPE_UNCHECKED_UNION; handle other cases like RECORD_TYPE. * utils.c (gnat_pushdecl): Set TREE_NO_WARNING. From-SVN: r94812 --- gcc/ada/utils2.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'gcc/ada/utils2.c') diff --git a/gcc/ada/utils2.c b/gcc/ada/utils2.c index 04ab0cb..008ac6e 100644 --- a/gcc/ada/utils2.c +++ b/gcc/ada/utils2.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2004, Free Software Foundation, Inc. * + * Copyright (C) 1992-2005, 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- * @@ -660,13 +660,16 @@ build_binary_op (enum tree_code op_code, tree result_type, might indicate a conversion between a root type and a class-wide type, which we must not remove. */ while (TREE_CODE (right_operand) == VIEW_CONVERT_EXPR - && ((TREE_CODE (right_type) == RECORD_TYPE + && (((TREE_CODE (right_type) == RECORD_TYPE + || TREE_CODE (right_type) == UNION_TYPE) && !TYPE_JUSTIFIED_MODULAR_P (right_type) && !TYPE_ALIGN_OK (right_type) && !TYPE_IS_FAT_POINTER_P (right_type)) || TREE_CODE (right_type) == ARRAY_TYPE) - && (((TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) - == RECORD_TYPE) + && ((((TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) + == RECORD_TYPE) + || (TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) + == UNION_TYPE)) && !(TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) && !(TYPE_ALIGN_OK @@ -695,7 +698,9 @@ build_binary_op (enum tree_code op_code, tree result_type, operation_type = best_type; /* If a class-wide type may be involved, force use of the RHS type. */ - if (TREE_CODE (right_type) == RECORD_TYPE && TYPE_ALIGN_OK (right_type)) + if ((TREE_CODE (right_type) == RECORD_TYPE + || TREE_CODE (right_type) == UNION_TYPE) + && TYPE_ALIGN_OK (right_type)) operation_type = right_type; /* Ensure everything on the LHS is valid. If we have a field reference, @@ -1087,7 +1092,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) int unsignedp, volatilep; inner = get_inner_reference (operand, &bitsize, &bitpos, &offset, - &mode, &unsignedp, &volatilep, false); + &mode, &unsignedp, &volatilep, + false); /* If INNER is a padding type whose field has a self-referential size, convert to that inner type. We know the offset is zero -- cgit v1.1