aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2016-10-11 10:35:43 +0000
committerEric Botcazou <ebotcazou@adacore.com>2016-10-11 10:35:43 +0000
commitccddd81cb3840f1007c4cd62500c8735441bc2e6 (patch)
tree8ee7e92fd6e2a32018317f96b606021e045aed70 /gcc/ada/gcc-interface/utils.c
parent74873d599d20250ba078ce10d47c1c8e2f9f86d6 (diff)
* exp_dbug.adb (Debug_Renaming_Declaration): Process underlying types.
Emit GNAT encodings for object renamings involving record components whose normalized bit offset is not null. * uintp.h (UI_No_Uint): Declare. * gcc-interface/gigi.h (can_materialize_object_renaming_p): New. * gcc-interface/utils.c (can_materialize_object_renaming_p): New function. * gcc-interface/trans.c (gnat_to_gnu) <N_Object_Renaming_Declaration>: In code generation mode, materialize all renamings as long as they need debug info and we are not optimizing. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@240985 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 221b0b51713..21e12658380 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -6185,6 +6185,58 @@ handle_vector_type_attribute (tree *node, tree name, tree ARG_UNUSED (args),
return NULL_TREE;
}
+/* Return whether EXPR, which is the renamed object in an object renaming
+ declaration, can be materialized as a reference (REFERENCE_TYPE). This
+ should be synchronized with Exp_Dbug.Debug_Renaming_Declaration. */
+
+bool
+can_materialize_object_renaming_p (Node_Id expr)
+{
+ while (true)
+ {
+ switch Nkind (expr)
+ {
+ case N_Identifier:
+ case N_Expanded_Name:
+ return true;
+
+ case N_Selected_Component:
+ {
+ if (Is_Packed (Underlying_Type (Etype (Prefix (expr)))))
+ return false;
+
+ const Uint bitpos
+ = Normalized_First_Bit (Entity (Selector_Name (expr)));
+ if (!UI_Is_In_Int_Range (bitpos)
+ || (bitpos != UI_No_Uint && bitpos != UI_From_Int (0)))
+ return false;
+
+ expr = Prefix (expr);
+ break;
+ }
+
+ case N_Indexed_Component:
+ case N_Slice:
+ {
+ const Entity_Id t = Underlying_Type (Etype (Prefix (expr)));
+
+ if (Is_Array_Type (t) && Present (Packed_Array_Impl_Type (t)))
+ return false;
+
+ expr = Prefix (expr);
+ break;
+ }
+
+ case N_Explicit_Dereference:
+ expr = Prefix (expr);
+ break;
+
+ default:
+ return true;
+ };
+ }
+}
+
/* ----------------------------------------------------------------------- *
* BUILTIN FUNCTIONS *
* ----------------------------------------------------------------------- */