Commit dee12fcd by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Use XNEW instead of xmalloc.

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Subtype>: Use
	XNEW instead of xmalloc.  Do not build useless pointer type.
	<E_Anonymous_Access_Subprogram_Type>: Use XNEW instead of xmalloc.
	* gcc-interface/trans.c (gnat_to_gnu) <N_Raise_Constraint_Error>: Tidy.
	* gcc-interface/utils2.c (build_unary_op): Remove local variable.

From-SVN: r179168
parent dea976c4
2011-09-25 Eric Botcazou <ebotcazou@adacore.com> 2011-09-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Subtype>: Use
XNEW instead of xmalloc. Do not build useless pointer type.
<E_Anonymous_Access_Subprogram_Type>: Use XNEW instead of xmalloc.
* gcc-interface/trans.c (gnat_to_gnu) <N_Raise_Constraint_Error>: Tidy.
* gcc-interface/utils2.c (build_unary_op): Remove local variable.
2011-09-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not promote * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not promote
the alignment if this doesn't prevent BLKmode access to the object. the alignment if this doesn't prevent BLKmode access to the object.
......
...@@ -3512,8 +3512,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3512,8 +3512,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
fill it in later. */ fill it in later. */
if (!definition && defer_incomplete_level != 0) if (!definition && defer_incomplete_level != 0)
{ {
struct incomplete *p struct incomplete *p = XNEW (struct incomplete);
= (struct incomplete *) xmalloc (sizeof (struct incomplete));
gnu_type gnu_type
= build_pointer_type = build_pointer_type
...@@ -3838,15 +3837,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3838,15 +3837,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
case E_Access_Subtype: case E_Access_Subtype:
/* We treat this as identical to its base type; any constraint is /* We treat this as identical to its base type; any constraint is
meaningful only to the front end. meaningful only to the front-end.
The designated type must be elaborated as well, if it does The designated type must be elaborated as well, if it does
not have its own freeze node. Designated (sub)types created not have its own freeze node. Designated (sub)types created
for constrained components of records with discriminants are for constrained components of records with discriminants are
not frozen by the front end and thus not elaborated by gigi, not frozen by the front-end and thus not elaborated by gigi,
because their use may appear before the base type is frozen, because their use may appear before the base type is frozen,
and because it is not clear that they are needed anywhere in and because it is not clear that they are needed anywhere in
Gigi. With the current model, there is no correct place where gigi. With the current model, there is no correct place where
they could be elaborated. */ they could be elaborated. */
gnu_type = gnat_to_gnu_type (Etype (gnat_entity)); gnu_type = gnat_to_gnu_type (Etype (gnat_entity));
...@@ -3860,20 +3859,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3860,20 +3859,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
elaborate it later. */ elaborate it later. */
if (!definition && defer_incomplete_level != 0) if (!definition && defer_incomplete_level != 0)
{ {
struct incomplete *p struct incomplete *p = XNEW (struct incomplete);
= (struct incomplete *) xmalloc (sizeof (struct incomplete));
tree gnu_ptr_type
= build_pointer_type
(make_dummy_type (Directly_Designated_Type (gnat_entity)));
p->old_type = TREE_TYPE (gnu_ptr_type); p->old_type
= make_dummy_type (Directly_Designated_Type (gnat_entity));
p->full_type = Directly_Designated_Type (gnat_entity); p->full_type = Directly_Designated_Type (gnat_entity);
p->next = defer_incomplete_list; p->next = defer_incomplete_list;
defer_incomplete_list = p; defer_incomplete_list = p;
} }
else if (!IN (Ekind (Base_Type else if (!IN (Ekind (Base_Type
(Directly_Designated_Type (gnat_entity))), (Directly_Designated_Type (gnat_entity))),
Incomplete_Or_Private_Kind)) Incomplete_Or_Private_Kind))
gnat_to_gnu_entity (Directly_Designated_Type (gnat_entity), gnat_to_gnu_entity (Directly_Designated_Type (gnat_entity),
NULL_TREE, 0); NULL_TREE, 0);
} }
......
...@@ -5794,7 +5794,6 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -5794,7 +5794,6 @@ gnat_to_gnu (Node_Id gnat_node)
{ {
const int reason = UI_To_Int (Reason (gnat_node)); const int reason = UI_To_Int (Reason (gnat_node));
const Node_Id cond = Condition (gnat_node); const Node_Id cond = Condition (gnat_node);
bool handled = false;
if (type_annotate_only) if (type_annotate_only)
{ {
...@@ -5807,65 +5806,58 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -5807,65 +5806,58 @@ gnat_to_gnu (Node_Id gnat_node)
if (Exception_Extra_Info if (Exception_Extra_Info
&& !No_Exception_Handlers_Set () && !No_Exception_Handlers_Set ()
&& !get_exception_label (kind) && !get_exception_label (kind)
&& TREE_CODE (gnu_result_type) == VOID_TYPE && VOID_TYPE_P (gnu_result_type)
&& Present (cond)) && Present (cond))
{ switch (reason)
if (reason == CE_Access_Check_Failed) {
{ case CE_Access_Check_Failed:
gnu_result = build_call_raise_column (reason, gnat_node); gnu_result = build_call_raise_column (reason, gnat_node);
handled = true; break;
}
else if ((reason == CE_Index_Check_Failed
|| reason == CE_Range_Check_Failed
|| reason == CE_Invalid_Data)
&& Nkind (cond) == N_Op_Not
&& Nkind (Right_Opnd (cond)) == N_In
&& Nkind (Right_Opnd (Right_Opnd (cond))) == N_Range)
{
Node_Id op = Right_Opnd (cond); /* N_In node */
Node_Id index = Left_Opnd (op);
Node_Id type = Etype (index);
if (Is_Type (type) case CE_Index_Check_Failed:
&& Known_Esize (type) case CE_Range_Check_Failed:
&& UI_To_Int (Esize (type)) <= 32) case CE_Invalid_Data:
{ if (Nkind (cond) == N_Op_Not
Node_Id right_op = Right_Opnd (op); && Nkind (Right_Opnd (cond)) == N_In
&& Nkind (Right_Opnd (Right_Opnd (cond))) == N_Range)
{
Node_Id op = Right_Opnd (cond); /* N_In node */
Node_Id index = Left_Opnd (op);
Node_Id range = Right_Opnd (op);
Node_Id type = Etype (index);
if (Is_Type (type)
&& Known_Esize (type)
&& UI_To_Int (Esize (type)) <= 32)
gnu_result gnu_result
= build_call_raise_range = build_call_raise_range (reason, gnat_node,
(reason, gnat_node, gnat_to_gnu (index),
gnat_to_gnu (index), /* index */ gnat_to_gnu
gnat_to_gnu (Low_Bound (right_op)), /* first */ (Low_Bound (range)),
gnat_to_gnu (High_Bound (right_op))); /* last */ gnat_to_gnu
handled = true; (High_Bound (range)));
} }
} break;
default:
break;
} }
if (handled) if (gnu_result == error_mark_node)
gnu_result = build_call_raise (reason, gnat_node, kind);
set_expr_location_from_node (gnu_result, gnat_node);
/* If the type is VOID, this is a statement, so we need to generate
the code for the call. Handle a condition, if there is one. */
if (VOID_TYPE_P (gnu_result_type))
{ {
set_expr_location_from_node (gnu_result, gnat_node); if (Present (cond))
gnu_result = build3 (COND_EXPR, void_type_node, gnu_result
gnat_to_gnu (cond), = build3 (COND_EXPR, void_type_node, gnat_to_gnu (cond),
gnu_result, alloc_stmt_list ()); gnu_result, alloc_stmt_list ());
} }
else else
{ gnu_result = build1 (NULL_EXPR, gnu_result_type, gnu_result);
gnu_result = build_call_raise (reason, gnat_node, kind);
/* If the type is VOID, this is a statement, so we need to generate
the code for the call. Handle a Condition, if there is one. */
if (TREE_CODE (gnu_result_type) == VOID_TYPE)
{
set_expr_location_from_node (gnu_result, gnat_node);
if (Present (cond))
gnu_result = build3 (COND_EXPR, void_type_node,
gnat_to_gnu (cond),
gnu_result, alloc_stmt_list ());
}
else
gnu_result = build1 (NULL_EXPR, gnu_result_type, gnu_result);
}
} }
break; break;
......
...@@ -1000,7 +1000,6 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1000,7 +1000,6 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
tree base_type = get_base_type (type); tree base_type = get_base_type (type);
tree operation_type = result_type; tree operation_type = result_type;
tree result; tree result;
bool side_effects = false;
if (operation_type if (operation_type
&& TREE_CODE (operation_type) == RECORD_TYPE && TREE_CODE (operation_type) == RECORD_TYPE
...@@ -1235,8 +1234,12 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1235,8 +1234,12 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
TREE_READONLY (result) = TYPE_READONLY (TREE_TYPE (type)); TREE_READONLY (result) = TYPE_READONLY (TREE_TYPE (type));
} }
side_effects if (!TYPE_IS_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type)))
= (!TYPE_IS_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type))); {
TREE_SIDE_EFFECTS (result) = 1;
if (TREE_CODE (result) == INDIRECT_REF)
TREE_THIS_VOLATILE (result) = TYPE_VOLATILE (TREE_TYPE (result));
}
break; break;
case NEGATE_EXPR: case NEGATE_EXPR:
...@@ -1322,13 +1325,6 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1322,13 +1325,6 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
convert (operation_type, operand)); convert (operation_type, operand));
} }
if (side_effects)
{
TREE_SIDE_EFFECTS (result) = 1;
if (TREE_CODE (result) == INDIRECT_REF)
TREE_THIS_VOLATILE (result) = TYPE_VOLATILE (TREE_TYPE (result));
}
if (result_type && TREE_TYPE (result) != result_type) if (result_type && TREE_TYPE (result) != result_type)
result = convert (result_type, result); result = convert (result_type, result);
......
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