Commit e8fa3dcd by Pierre-Marie de Rodat Committed by Arnaud Charlet

decl.c (gnat_to_gnu_entity): Create a mere scalar constant instead of a…

decl.c (gnat_to_gnu_entity): Create a mere scalar constant instead of a reference for a renaming of scalar...

2014-07-30  Pierre-Marie Derodat  <derodat@adacore.com>
        
	* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Create a
	mere scalar constant instead of a reference for a renaming of
	scalar literal.
	* gcc-interface/utils.c (renaming_from_generic_instantiation_p): New.
	* gcc-interface/gigi.h (renaming_from_generic_instantiation_p): New.

From-SVN: r213258
parent 7b2888e6
2014-07-30 Pierre-Marie Derodat <derodat@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Create a
mere scalar constant instead of a reference for a renaming of
scalar literal.
* gcc-interface/utils.c (renaming_from_generic_instantiation_p): New.
* gcc-interface/gigi.h (renaming_from_generic_instantiation_p): New.
2014-07-30 Robert Dewar <dewar@adacore.com> 2014-07-30 Robert Dewar <dewar@adacore.com>
* s-tasuti.adb, s-tasuti.ads, einfo.ads, sem_prag.adb, s-taasde.adb, * s-tasuti.adb, s-tasuti.ads, einfo.ads, sem_prag.adb, s-taasde.adb,
......
...@@ -349,9 +349,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -349,9 +349,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
|| Is_Public (gnat_entity)); || Is_Public (gnat_entity));
/* Get the name of the entity and set up the line number and filename of /* 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. */ 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); gnu_entity_name = get_entity_name (gnat_entity);
Sloc_to_locus (Sloc (gnat_entity), &input_location); if (Sloc (gnat_entity) != No_Location
&& !renaming_from_generic_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 /* For cases when we are not defining (i.e., we are referencing from
another compilation unit) public entities, show we are at global level another compilation unit) public entities, show we are at global level
...@@ -1988,7 +1991,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1988,7 +1991,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
maybe_present = true; maybe_present = true;
break; break;
/* Array and String Types and Subtypes /* Array Types and Subtypes
Unconstrained array types are represented by E_Array_Type and Unconstrained array types are represented by E_Array_Type and
constrained array types are represented by E_Array_Subtype. There constrained array types are represented by E_Array_Subtype. There
...@@ -2001,7 +2004,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2001,7 +2004,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
Number_Dimensions Number of dimensions (an int). Number_Dimensions Number of dimensions (an int).
First_Index Type of first index. */ First_Index Type of first index. */
case E_String_Type:
case E_Array_Type: case E_Array_Type:
{ {
const bool convention_fortran_p const bool convention_fortran_p
...@@ -2312,7 +2314,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2312,7 +2314,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
} }
break; break;
case E_String_Subtype:
case E_Array_Subtype: case E_Array_Subtype:
/* This is the actual data type for array variables. Multidimensional /* This is the actual data type for array variables. Multidimensional
......
...@@ -1017,6 +1017,12 @@ extern int fp_prec_to_size (int prec); ...@@ -1017,6 +1017,12 @@ extern int fp_prec_to_size (int prec);
/* Return the precision of the FP mode with size SIZE. */ /* Return the precision of the FP mode with size SIZE. */
extern int fp_size_to_prec (int size); extern int fp_size_to_prec (int size);
/* 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. */
extern bool renaming_from_generic_instantiation_p (Node_Id gnat_node);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
......
...@@ -580,7 +580,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -580,7 +580,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
TREE_NO_WARNING (decl) = (No (gnat_node) || Warnings_Off (gnat_node)); TREE_NO_WARNING (decl) = (No (gnat_node) || Warnings_Off (gnat_node));
/* Set the location of DECL and emit a declaration for it. */ /* Set the location of DECL and emit a declaration for it. */
if (Present (gnat_node)) if (Present (gnat_node) && !renaming_from_generic_instantiation_p (gnat_node))
Sloc_to_locus (Sloc (gnat_node), &DECL_SOURCE_LOCATION (decl)); Sloc_to_locus (Sloc (gnat_node), &DECL_SOURCE_LOCATION (decl));
add_decl_expr (decl, gnat_node); add_decl_expr (decl, gnat_node);
...@@ -2550,6 +2550,37 @@ value_factor_p (tree value, HOST_WIDE_INT factor) ...@@ -2550,6 +2550,37 @@ value_factor_p (tree value, HOST_WIDE_INT factor)
return false; 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_generic_instantiation_p (Node_Id gnat_node)
{
if (Nkind (gnat_node) != N_Defining_Identifier
|| !IN (Ekind (gnat_node), Object_Kind)
|| 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)));
}
/* Return VALUE scaled by the biggest power-of-2 factor of EXPR. */ /* Return VALUE scaled by the biggest power-of-2 factor of EXPR. */
static unsigned int static unsigned int
......
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