Commit 6b1cce3a by Eric Botcazou Committed by Eric Botcazou

trans.c (Attribute_to_gnu): Do not return the RM size for padded types.

	* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Object_Size>: Do not
	return the RM size for padded types.

From-SVN: r153720
parent d0539838
2009-10-29 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Object_Size>: Do not
return the RM size for padded types.
2009-10-28 Robert Dewar <dewar@adacore.com> 2009-10-28 Robert Dewar <dewar@adacore.com>
* sem_type.adb: Minor reformatting * sem_type.adb: Minor reformatting
......
...@@ -1317,28 +1317,28 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -1317,28 +1317,28 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
} }
/* If we're looking for the size of a field, return the field size. /* If we're looking for the size of a field, return the field size.
Otherwise, if the prefix is an object, or if 'Object_Size or Otherwise, if the prefix is an object, or if we're looking for
'Max_Size_In_Storage_Elements has been specified, the result is the 'Object_Size or 'Max_Size_In_Storage_Elements, the result is the
GCC size of the type. Otherwise, the result is the RM size of the GCC size of the type. Otherwise, it is the RM size of the type. */
type. */
if (TREE_CODE (gnu_prefix) == COMPONENT_REF) if (TREE_CODE (gnu_prefix) == COMPONENT_REF)
gnu_result = DECL_SIZE (TREE_OPERAND (gnu_prefix, 1)); gnu_result = DECL_SIZE (TREE_OPERAND (gnu_prefix, 1));
else if (TREE_CODE (gnu_prefix) != TYPE_DECL else if (TREE_CODE (gnu_prefix) != TYPE_DECL
|| attribute == Attr_Object_Size || attribute == Attr_Object_Size
|| attribute == Attr_Max_Size_In_Storage_Elements) || attribute == Attr_Max_Size_In_Storage_Elements)
{ {
/* If this is a padded type, the GCC size isn't relevant to the /* If the prefix is an object of a padded type, the GCC size isn't
programmer. Normally, what we want is the RM size, which was set relevant to the programmer. Normally what we want is the RM size,
from the specified size, but if it was not set, we want the size which was set from the specified size, but if it was not set, we
of the relevant field. Using the MAX of those two produces the want the size of the field. Using the MAX of those two produces
right result in all case. Don't use the size of the field if it's the right result in all cases. Don't use the size of the field
a self-referential type, since that's never what's wanted. */ if it's self-referential, since that's never what's wanted. */
if (TYPE_IS_PADDING_P (gnu_type) if (TREE_CODE (gnu_prefix) != TYPE_DECL
&& TYPE_IS_PADDING_P (gnu_type)
&& TREE_CODE (gnu_expr) == COMPONENT_REF) && TREE_CODE (gnu_expr) == COMPONENT_REF)
{ {
gnu_result = rm_size (gnu_type); gnu_result = rm_size (gnu_type);
if (!(CONTAINS_PLACEHOLDER_P if (!CONTAINS_PLACEHOLDER_P
(DECL_SIZE (TREE_OPERAND (gnu_expr, 1))))) (DECL_SIZE (TREE_OPERAND (gnu_expr, 1))))
gnu_result gnu_result
= size_binop (MAX_EXPR, gnu_result, = size_binop (MAX_EXPR, gnu_result,
DECL_SIZE (TREE_OPERAND (gnu_expr, 1))); DECL_SIZE (TREE_OPERAND (gnu_expr, 1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment