aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2005-02-10 14:53:21 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2005-02-10 14:53:21 +0100
commit8afc118e11c9b2091f76c5e44fe7e6ad28820d7e (patch)
tree684c32a8daeae86786653d8ce917537a2c90db20 /gcc/ada/utils.c
parentcc892b2c9128f71cf72f4fbad94d272d02562435 (diff)
downloadgcc-8afc118e11c9b2091f76c5e44fe7e6ad28820d7e.zip
gcc-8afc118e11c9b2091f76c5e44fe7e6ad28820d7e.tar.gz
gcc-8afc118e11c9b2091f76c5e44fe7e6ad28820d7e.tar.bz2
Fix for c330001 - PR ada/19386
2005-02-09 Eric Botcazou <ebotcazou@adacore.com> Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 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
Diffstat (limited to 'gcc/ada/utils.c')
-rw-r--r--gcc/ada/utils.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index 4d4fad4..549c093 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.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- *
@@ -309,7 +309,7 @@ insert_block (tree block)
}
/* Records a ..._DECL node DECL as belonging to the current lexical scope
- and uses GNAT_NODE for location information. */
+ and uses GNAT_NODE for location information and propagating flags. */
void
gnat_pushdecl (tree decl, Node_Id gnat_node)
@@ -321,6 +321,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
else
DECL_CONTEXT (decl) = current_function_decl;
+ TREE_NO_WARNING (decl) = (gnat_node == Empty || Warnings_Off (gnat_node));
+
/* Set the location of DECL and emit a declaration for it. */
if (Present (gnat_node))
Sloc_to_locus (Sloc (gnat_node), &DECL_SOURCE_LOCATION (decl));
@@ -1182,8 +1184,8 @@ create_type_decl (tree type_name, tree type, struct attrib *attr_list,
|| !debug_info_p)
DECL_IGNORED_P (type_decl) = 1;
else if (code != ENUMERAL_TYPE && code != RECORD_TYPE
- && !((code == POINTER_TYPE || code == REFERENCE_TYPE)
- && TYPE_IS_DUMMY_P (TREE_TYPE (type))))
+ && !((code == POINTER_TYPE || code == REFERENCE_TYPE)
+ && TYPE_IS_DUMMY_P (TREE_TYPE (type))))
rest_of_decl_compilation (type_decl, global_bindings_p (), 0);
if (!TYPE_IS_DUMMY_P (type))
@@ -2905,21 +2907,29 @@ convert (tree type, tree expr)
return unchecked_convert (type, expr, false);
case UNION_TYPE:
- /* Just validate that the type is indeed that of a field
- of the type. Then make the simple conversion. */
- for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
+ /* For unchecked unions, just validate that the type is indeed that of
+ a field of the type. Then make the simple conversion. */
+ if (TYPE_UNCHECKED_UNION_P (type))
{
- if (TREE_TYPE (tem) == etype)
- return build1 (CONVERT_EXPR, type, expr);
- else if (TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE
- && (TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (tem))
- || TYPE_IS_PADDING_P (TREE_TYPE (tem)))
- && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (tem))) == etype)
- return build1 (CONVERT_EXPR, type,
- convert (TREE_TYPE (tem), expr));
- }
+ for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
+ {
+ if (TREE_TYPE (tem) == etype)
+ return build1 (CONVERT_EXPR, type, expr);
+ else if (TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE
+ && (TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (tem))
+ || TYPE_IS_PADDING_P (TREE_TYPE (tem)))
+ && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (tem))) == etype)
+ return build1 (CONVERT_EXPR, type,
+ convert (TREE_TYPE (tem), expr));
+ }
- gcc_unreachable ();
+ gcc_unreachable ();
+ }
+ else
+ /* Otherwise, this is a conversion between a tagged type and some
+ subtype, which we have to mark as a UNION_TYPE because of
+ overlapping fields. */
+ return unchecked_convert (type, expr, false);
case UNCONSTRAINED_ARRAY_TYPE:
/* If EXPR is a constrained array, take its address, convert it to a
@@ -3214,6 +3224,7 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
/* Search the chain of currently reachable declarations for a builtin
FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
Return the first node found, if any, or NULL_TREE otherwise. */
+
tree
builtin_decl_for (tree name __attribute__ ((unused)))
{