OSDN Git Service

* gcc-interface/utils.c (gnat_set_type_context): New function.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 19 Oct 2013 10:57:08 +0000 (10:57 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 19 Oct 2013 10:57:08 +0000 (10:57 +0000)
(gnat_pushdecl): Use it to set the context of the type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@203850 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c

index 43f861c..fce5a21 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-19  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/utils.c (gnat_set_type_context): New function.
+       (gnat_pushdecl): Use it to set the context of the type.
+
 2013-09-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (Subprogram_Body_to_gnu): Pop the stack of
index e4e74b0..6951bc1 100644 (file)
@@ -500,6 +500,22 @@ gnat_zaplevel (void)
   free_binding_level = level;
 }
 \f
+/* Set the context of TYPE and its parallel types (if any) to CONTEXT.  */
+
+static void
+gnat_set_type_context (tree type, tree context)
+{
+  tree decl = TYPE_STUB_DECL (type);
+
+  TYPE_CONTEXT (type) = context;
+
+  while (decl && DECL_PARALLEL_TYPE (decl))
+    {
+      TYPE_CONTEXT (DECL_PARALLEL_TYPE (decl)) = context;
+      decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl));
+    }
+}
+
 /* Record DECL as belonging to the current lexical scope and use GNAT_NODE
    for location information and flag propagation.  */
 
@@ -581,7 +597,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
              if (TREE_CODE (t) == POINTER_TYPE)
                TYPE_NEXT_PTR_TO (t) = tt;
              TYPE_NAME (tt) = DECL_NAME (decl);
-             TYPE_CONTEXT (tt) = DECL_CONTEXT (decl);
+             gnat_set_type_context (tt, DECL_CONTEXT (decl));
              TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t);
              DECL_ORIGINAL_TYPE (decl) = tt;
            }
@@ -591,7 +607,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
          /* We need a variant for the placeholder machinery to work.  */
          tree tt = build_variant_type_copy (t);
          TYPE_NAME (tt) = decl;
-         TYPE_CONTEXT (tt) = DECL_CONTEXT (decl);
+         gnat_set_type_context (tt, DECL_CONTEXT (decl));
          TREE_USED (tt) = TREE_USED (t);
          TREE_TYPE (decl) = tt;
          if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
@@ -613,7 +629,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
          if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
            {
              TYPE_NAME (t) = decl;
-             TYPE_CONTEXT (t) = DECL_CONTEXT (decl);
+             gnat_set_type_context (t, DECL_CONTEXT (decl));
            }
     }
 }