aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2018-07-07 10:20:12 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2018-07-07 10:20:12 +0000
commit9269b9d3e6e91229044fc18630430170da6e03d1 (patch)
treecb9596a739f084236484b459cb331d9799e513e8
parent89bf88bfbf4fdabcd687009119e307d3de85bee1 (diff)
* gcc-interface/gigi.h (add_decl_expr): Adjust prototype.
* gcc-interface/decl.c (gnat_to_gnu_entity): Remove useless test. * gcc-interface/trans.c (add_stmt_with_node): Remove exceptions. (add_decl_expr): Change type of second parameter and rename it. (renaming_from_instantiation_p): New function moved from... (set_expr_location_from_node): Test for exceptions here and add one for actual subtypes built for unconstrained composite actuals. * gcc-interface/utils.c (renaming_from_instantiation_p): ...here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262497 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/gcc-interface/decl.c7
-rw-r--r--gcc/ada/gcc-interface/gigi.h6
-rw-r--r--gcc/ada/gcc-interface/trans.c48
-rw-r--r--gcc/ada/gcc-interface/utils.c31
5 files changed, 58 insertions, 45 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index bc353c5c52f..537a088a3af 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,16 @@
2018-07-07 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/gigi.h (add_decl_expr): Adjust prototype.
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Remove useless test.
+ * gcc-interface/trans.c (add_stmt_with_node): Remove exceptions.
+ (add_decl_expr): Change type of second parameter and rename it.
+ (renaming_from_instantiation_p): New function moved from...
+ (set_expr_location_from_node): Test for exceptions here and add one
+ for actual subtypes built for unconstrained composite actuals.
+ * gcc-interface/utils.c (renaming_from_instantiation_p): ...here.
+
+2018-07-07 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/trans.c (lvalue_required_p): Remove ALIASED parameter
and adjust recursive calls.
(Identifier_to_gnu): Adjust calls to lvalue_required_p.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index def48f16974..4ccb7f8c039 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -430,11 +430,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
|| Is_Public (gnat_entity));
/* Get the name of the entity and set up the line number and filename of
- the original definition for use in any decl we make. Make sure we do not
- inherit another source location. */
+ the original definition for use in any decl we make. Make sure we do
+ not inherit another source location. */
gnu_entity_name = get_entity_name (gnat_entity);
- if (Sloc (gnat_entity) != No_Location
- && !renaming_from_instantiation_p (gnat_entity))
+ if (!renaming_from_instantiation_p (gnat_entity))
Sloc_to_locus (Sloc (gnat_entity), &input_location);
/* For cases when we are not defining (i.e., we are referencing from
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 8950f8e10b1..a6bc1f0c9d4 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -77,9 +77,9 @@ extern tree end_stmt_group (void);
/* Set the BLOCK node corresponding to the current code group to GNU_BLOCK. */
extern void set_block_for_group (tree);
-/* Add a declaration statement for GNU_DECL to the current BLOCK_STMT node.
- Get SLOC from GNAT_ENTITY. */
-extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity);
+/* Add a declaration statement for GNU_DECL to the current statement group.
+ Get the SLOC to be put onto the statement from GNAT_NODE. */
+extern void add_decl_expr (tree gnu_decl, Node_Id gnat_node);
/* Mark nodes rooted at T with TREE_VISITED and types as having their
sized gimplified. We use this to indicate all variable sizes and
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index e7992e8a938..effd28160a7 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -8119,9 +8119,7 @@ add_stmt_force (tree gnu_stmt)
void
add_stmt_with_node (tree gnu_stmt, Node_Id gnat_node)
{
- /* Do not emit a location for renamings that come from generic instantiation,
- they are likely to disturb debugging. */
- if (Present (gnat_node) && !renaming_from_instantiation_p (gnat_node))
+ if (Present (gnat_node))
set_expr_location_from_node (gnu_stmt, gnat_node);
add_stmt (gnu_stmt);
}
@@ -8137,10 +8135,10 @@ add_stmt_with_node_force (tree gnu_stmt, Node_Id gnat_node)
}
/* Add a declaration statement for GNU_DECL to the current statement group.
- Get SLOC from Entity_Id. */
+ Get the SLOC to be put onto the statement from GNAT_NODE. */
void
-add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
+add_decl_expr (tree gnu_decl, Node_Id gnat_node)
{
tree type = TREE_TYPE (gnu_decl);
tree gnu_stmt, gnu_init;
@@ -8179,7 +8177,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
MARK_VISITED (TYPE_ADA_SIZE (type));
}
else
- add_stmt_with_node (gnu_stmt, gnat_entity);
+ add_stmt_with_node (gnu_stmt, gnat_node);
/* If this is a variable and an initializer is attached to it, it must be
valid for the context. Similar to init_const in create_var_decl. */
@@ -8203,7 +8201,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
gnu_decl = convert (TREE_TYPE (TYPE_FIELDS (type)), gnu_decl);
gnu_stmt = build_binary_op (INIT_EXPR, NULL_TREE, gnu_decl, gnu_init);
- add_stmt_with_node (gnu_stmt, gnat_entity);
+ add_stmt_with_node (gnu_stmt, gnat_node);
}
}
@@ -10005,6 +10003,32 @@ Sloc_to_locus (Source_Ptr Sloc, location_t *locus, bool clear_column)
return true;
}
+/* Return whether GNAT_NODE is a defining identifier for a renaming that comes
+ from the parameter association for the instantiation of a generic. We do
+ not want to emit source location for them: the code generated for their
+ initialization is likely to disturb debugging. */
+
+bool
+renaming_from_instantiation_p (Node_Id gnat_node)
+{
+ if (Nkind (gnat_node) != N_Defining_Identifier
+ || !Is_Object (gnat_node)
+ || Comes_From_Source (gnat_node)
+ || !Present (Renamed_Object (gnat_node)))
+ return false;
+
+ /* Get the object declaration of the renamed object, if any and if the
+ renamed object is a mere identifier. */
+ gnat_node = Renamed_Object (gnat_node);
+ if (Nkind (gnat_node) != N_Identifier)
+ return false;
+
+ gnat_node = Parent (Entity (gnat_node));
+ return (Present (gnat_node)
+ && Nkind (gnat_node) == N_Object_Declaration
+ && Present (Corresponding_Generic_Association (gnat_node)));
+}
+
/* Similar to set_expr_location, but start with the Sloc of GNAT_NODE and
don't do anything if it doesn't correspond to a source location. And,
if CLEAR_COLUMN is true, set the column information to 0. */
@@ -10014,6 +10038,16 @@ set_expr_location_from_node (tree node, Node_Id gnat_node, bool clear_column)
{
location_t locus;
+ /* Do not set a location for constructs likely to disturb debugging. */
+ if (Nkind (gnat_node) == N_Defining_Identifier)
+ {
+ if (Is_Type (gnat_node) && Is_Actual_Subtype (gnat_node))
+ return;
+
+ if (renaming_from_instantiation_p (gnat_node))
+ return;
+ }
+
if (!Sloc_to_locus (Sloc (gnat_node), &locus, clear_column))
return;
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index e0e5cfe4de2..af85a0fe858 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -2938,37 +2938,6 @@ value_factor_p (tree value, HOST_WIDE_INT factor)
return false;
}
-/* Return whether GNAT_NODE is a defining identifier for a renaming that comes
- from the parameter association for the instantiation of a generic. We do
- not want to emit source location for them: the code generated for their
- initialization is likely to disturb debugging. */
-
-bool
-renaming_from_instantiation_p (Node_Id gnat_node)
-{
- if (Nkind (gnat_node) != N_Defining_Identifier
- || !Is_Object (gnat_node)
- || Comes_From_Source (gnat_node)
- || !Present (Renamed_Object (gnat_node)))
- return false;
-
- /* Get the object declaration of the renamed object, if any and if the
- renamed object is a mere identifier. */
- gnat_node = Renamed_Object (gnat_node);
- if (Nkind (gnat_node) != N_Identifier)
- return false;
-
- gnat_node = Entity (gnat_node);
- if (!Present (Parent (gnat_node)))
- return false;
-
- gnat_node = Parent (gnat_node);
- return
- (Present (gnat_node)
- && Nkind (gnat_node) == N_Object_Declaration
- && Present (Corresponding_Generic_Association (gnat_node)));
-}
-
/* Defer the initialization of DECL's DECL_CONTEXT attribute, scheduling to
feed it with the elaboration of GNAT_SCOPE. */