Commit f1ff07ec by Eric Botcazou Committed by Eric Botcazou

trans.c (gnat_to_gnu): Rework special code dealing with boolean rvalues and set…

trans.c (gnat_to_gnu): Rework special code dealing with boolean rvalues and set the location directly.

	* gcc-interface/trans.c (gnat_to_gnu): Rework special code dealing
	with boolean rvalues and set the location directly.  Do not set the
	location in the other cases for a simple name.
	(gnat_to_gnu_external): Clear the location on the expression.

From-SVN: r237123
parent d5ebeb8c
2016-06-06 Eric Botcazou <ebotcazou@adacore.com> 2016-06-06 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (gnat_to_gnu): Rework special code dealing
with boolean rvalues and set the location directly. Do not set the
location in the other cases for a simple name.
(gnat_to_gnu_external): Clear the location on the expression.
2016-06-06 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Component>: Remove * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Component>: Remove
useless 'else' statements and tidy up. useless 'else' statements and tidy up.
<E_Array_Subtype>: Fully deal with the declaration here. <E_Array_Subtype>: Fully deal with the declaration here.
......
...@@ -7686,10 +7686,11 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -7686,10 +7686,11 @@ gnat_to_gnu (Node_Id gnat_node)
current_function_decl = NULL_TREE; current_function_decl = NULL_TREE;
/* When not optimizing, turn boolean rvalues B into B != false tests /* When not optimizing, turn boolean rvalues B into B != false tests
so that the code just below can put the location information of the so that we can put the location information of the reference to B on
reference to B on the inequality operator for better debug info. */ the inequality operator for better debug info. */
if (!optimize if (!optimize
&& TREE_CODE (gnu_result) != INTEGER_CST && TREE_CODE (gnu_result) != INTEGER_CST
&& TREE_CODE (gnu_result) != TYPE_DECL
&& (kind == N_Identifier && (kind == N_Identifier
|| kind == N_Expanded_Name || kind == N_Expanded_Name
|| kind == N_Explicit_Dereference || kind == N_Explicit_Dereference
...@@ -7698,15 +7699,19 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -7698,15 +7699,19 @@ gnat_to_gnu (Node_Id gnat_node)
|| kind == N_Selected_Component) || kind == N_Selected_Component)
&& TREE_CODE (get_base_type (gnu_result_type)) == BOOLEAN_TYPE && TREE_CODE (get_base_type (gnu_result_type)) == BOOLEAN_TYPE
&& !lvalue_required_p (gnat_node, gnu_result_type, false, false, false)) && !lvalue_required_p (gnat_node, gnu_result_type, false, false, false))
gnu_result = build_binary_op (NE_EXPR, gnu_result_type, {
convert (gnu_result_type, gnu_result), gnu_result
convert (gnu_result_type, = build_binary_op (NE_EXPR, gnu_result_type,
boolean_false_node)); convert (gnu_result_type, gnu_result),
convert (gnu_result_type, boolean_false_node));
/* Set the location information on the result. Note that we may have if (TREE_CODE (gnu_result) != INTEGER_CST)
no result if we tried to build a CALL_EXPR node to a procedure with set_gnu_expr_location_from_node (gnu_result, gnat_node);
no side-effects and optimization is enabled. */ }
if (gnu_result && EXPR_P (gnu_result))
/* Set the location information on the result if it's not a simple name.
Note that we may have no result if we tried to build a CALL_EXPR node
to a procedure with no side-effects and optimization is enabled. */
else if (kind != N_Identifier && gnu_result && EXPR_P (gnu_result))
set_gnu_expr_location_from_node (gnu_result, gnat_node); set_gnu_expr_location_from_node (gnu_result, gnat_node);
/* If we're supposed to return something of void_type, it means we have /* If we're supposed to return something of void_type, it means we have
...@@ -7858,6 +7863,10 @@ gnat_to_gnu_external (Node_Id gnat_node) ...@@ -7858,6 +7863,10 @@ gnat_to_gnu_external (Node_Id gnat_node)
if (went_into_elab_proc) if (went_into_elab_proc)
current_function_decl = NULL_TREE; current_function_decl = NULL_TREE;
/* Do not import locations from external units. */
if (gnu_result && EXPR_P (gnu_result))
SET_EXPR_LOCATION (gnu_result, UNKNOWN_LOCATION);
return gnu_result; return gnu_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