aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-03-07 08:46:52 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-03-07 08:46:52 +0000
commit4c33516338cccd40cea01a9830477ac055cc0c86 (patch)
treeb5d2b6eca817657c04843eba1fd5cd1cb1a9af92 /gcc
parent1878be32235c6f9c52a5368b18650b215dbdd508 (diff)
downloadgcc-4c33516338cccd40cea01a9830477ac055cc0c86.zip
gcc-4c33516338cccd40cea01a9830477ac055cc0c86.tar.gz
gcc-4c33516338cccd40cea01a9830477ac055cc0c86.tar.bz2
trans.c (statement_node_p): New predicate.
* gcc-interface/trans.c (statement_node_p): New predicate. (gnat_to_gnu): Invoke it to detect statement nodes. In ASIS mode, do not return dummy results for expressions attached to packed array implementation types. From-SVN: r234020
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/trans.c51
2 files changed, 46 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 0573865..8e06376 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,12 @@
2016-03-07 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/trans.c (statement_node_p): New predicate.
+ (gnat_to_gnu): Invoke it to detect statement nodes. In ASIS mode, do
+ not return dummy results for expressions attached to packed array
+ implementation types.
+
+2016-03-07 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Always mark
the expression of a renaming manually in case #3.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index c78b01b..357d26f 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -5715,6 +5715,28 @@ unchecked_conversion_nop (Node_Id gnat_node)
return false;
}
+/* Return true if GNAT_NODE represents a statement. */
+
+static bool
+statement_node_p (Node_Id gnat_node)
+{
+ const Node_Kind kind = Nkind (gnat_node);
+
+ if (kind == N_Label)
+ return true;
+
+ if (IN (kind, N_Statement_Other_Than_Procedure_Call))
+ return true;
+
+ if (kind == N_Procedure_Call_Statement)
+ return true;
+
+ if (IN (kind, N_Raise_xxx_Error) && Ekind (Etype (gnat_node)) == E_Void)
+ return true;
+
+ return false;
+}
+
/* This function is the driver of the GNAT to GCC tree transformation process.
It is the entry point of the tree transformer. GNAT_NODE is the root of
some GNAT tree. Return the root of the corresponding GCC tree. If this
@@ -5738,15 +5760,23 @@ gnat_to_gnu (Node_Id gnat_node)
error_gnat_node = gnat_node;
Sloc_to_locus (Sloc (gnat_node), &input_location);
- /* If this node is a statement and we are only annotating types, return an
- empty statement list. */
- if (type_annotate_only && IN (kind, N_Statement_Other_Than_Procedure_Call))
+ /* If we are only annotating types and this node is a statement, return
+ an empty statement list. */
+ if (type_annotate_only && statement_node_p (gnat_node))
return alloc_stmt_list ();
- /* If this node is a non-static subexpression and we are only annotating
- types, make this into a NULL_EXPR. */
+ /* If we are only annotating types and this node is a subexpression, return
+ a NULL_EXPR, but filter out nodes appearing in the expressions attached
+ to packed array implementation types. */
if (type_annotate_only
&& IN (kind, N_Subexpr)
+ && !(((IN (kind, N_Op) && kind != N_Op_Expon)
+ || kind == N_Type_Conversion)
+ && Is_Integer_Type (Etype (gnat_node)))
+ && !(kind == N_Attribute_Reference
+ && Get_Attribute_Id (Attribute_Name (gnat_node)) == Attr_Length
+ && Ekind (Etype (Prefix (gnat_node))) == E_Array_Subtype
+ && !Is_Constr_Subt_For_U_Nominal (Etype (Prefix (gnat_node))))
&& kind != N_Expanded_Name
&& kind != N_Identifier
&& !Compile_Time_Known_Value (gnat_node))
@@ -5754,13 +5784,9 @@ gnat_to_gnu (Node_Id gnat_node)
build_call_raise (CE_Range_Check_Failed, gnat_node,
N_Raise_Constraint_Error));
- if ((IN (kind, N_Statement_Other_Than_Procedure_Call)
- && kind != N_Null_Statement)
- || kind == N_Procedure_Call_Statement
- || kind == N_Label
- || kind == N_Implicit_Label_Declaration
+ if ((statement_node_p (gnat_node) && kind != N_Null_Statement)
|| kind == N_Handled_Sequence_Of_Statements
- || (IN (kind, N_Raise_xxx_Error) && Ekind (Etype (gnat_node)) == E_Void))
+ || kind == N_Implicit_Label_Declaration)
{
tree current_elab_proc = get_elaboration_procedure ();
@@ -5780,7 +5806,8 @@ gnat_to_gnu (Node_Id gnat_node)
spurious errors on dummy (empty) sequences created by the front-end
for package bodies in some cases. */
if (current_function_decl == current_elab_proc
- && kind != N_Handled_Sequence_Of_Statements)
+ && kind != N_Handled_Sequence_Of_Statements
+ && kind != N_Implicit_Label_Declaration)
Check_Elaboration_Code_Allowed (gnat_node);
}