From: Eric Botcazou Date: Sun, 6 Apr 2008 10:22:23 +0000 (+0000) Subject: decl.c (rest_of_type_decl_compilation_no_defer): New local function used to process... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1bde5bc4681ac3713d54d6511cfb6000be57114f;p=gcc.git decl.c (rest_of_type_decl_compilation_no_defer): New local function used to process all the variants of the specified type. * decl.c (rest_of_type_decl_compilation_no_defer): New local function used to process all the variants of the specified type. (gnat_to_gnu_entity): Invoke rest_of_type_decl_compilation for enumeral types too. Call rest_of_type_decl_compilation_no_defer if undeferring. (rest_of_type_decl_compilation): Likewise. * utils.c (gnat_pushdecl): Propagate the name to all variants of type. From-SVN: r133957 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 57c55e21868..a6f14035db3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,7 +1,16 @@ +2008-04-06 Eric Botcazou + + * decl.c (rest_of_type_decl_compilation_no_defer): New local function + used to process all the variants of the specified type. + (gnat_to_gnu_entity): Invoke rest_of_type_decl_compilation for enumeral + types too. Call rest_of_type_decl_compilation_no_defer if undeferring. + (rest_of_type_decl_compilation): Likewise. + * utils.c (gnat_pushdecl): Propagate the name to all variants of type. + 2008-04-03 Paolo Bonzini - * gigi.h (insert_block): Kill. - * utils.c (insert_block): Kill. + * gigi.h (insert_block): Kill. + * utils.c (insert_block): Kill. 2008-04-02 Eric Botcazou diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index ee9c1c58cde..e31b52528ed 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -119,7 +119,8 @@ static tree make_type_from_size (tree, tree, bool); static unsigned int validate_alignment (Uint, Entity_Id, unsigned int); static unsigned int ceil_alignment (unsigned HOST_WIDE_INT); static void check_ok_for_atomic (tree, Entity_Id, bool); -static int compatible_signatures_p (tree ftype1, tree ftype2); +static int compatible_signatures_p (tree ftype1, tree ftype2); +static void rest_of_type_decl_compilation_no_defer (tree); /* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a GCC type corresponding to that entity. GNAT_ENTITY is assumed to @@ -4417,12 +4418,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (TREE_CODE (gnu_scalar_type) == ENUMERAL_TYPE) { - TYPE_STUB_DECL (gnu_scalar_type) = gnu_decl; - /* Since this has both a typedef and a tag, avoid outputting the name twice. */ DECL_ARTIFICIAL (gnu_decl) = 1; - rest_of_type_compilation (gnu_scalar_type, global_bindings_p ()); + rest_of_type_decl_compilation (gnu_decl); } } @@ -4462,12 +4461,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) now proceed with the finalization of the deferred types. */ if (defer_finalize_level == 0 && defer_finalize_list) { - int toplev = global_bindings_p (); unsigned int i; tree t; for (i = 0; VEC_iterate (tree, defer_finalize_list, i, t); i++) - rest_of_decl_compilation (t, toplev, 0); + rest_of_type_decl_compilation_no_defer (t); VEC_free (tree, heap, defer_finalize_list); } @@ -4514,17 +4512,46 @@ gnat_to_gnu_field_decl (Entity_Id gnat_entity) return gnu_field; } -/* Wrap up compilation of T, a TYPE_DECL, possibly deferring it. */ +/* Wrap up compilation of DECL, a TYPE_DECL, possibly deferring it. + Every TYPE_DECL generated for a type definition must be passed + to this function once everything else has been done for it. */ void -rest_of_type_decl_compilation (tree t) +rest_of_type_decl_compilation (tree decl) { /* We need to defer finalizing the type if incomplete types are being deferred or if they are being processed. */ if (defer_incomplete_level || defer_finalize_level) - VEC_safe_push (tree, heap, defer_finalize_list, t); + VEC_safe_push (tree, heap, defer_finalize_list, decl); else - rest_of_decl_compilation (t, global_bindings_p (), 0); + rest_of_type_decl_compilation_no_defer (decl); +} + +/* Same as above but without deferring the compilation. This + function should not be invoked directly on a TYPE_DECL. */ + +static void +rest_of_type_decl_compilation_no_defer (tree decl) +{ + const int toplev = global_bindings_p (); + tree t = TREE_TYPE (decl); + + rest_of_decl_compilation (decl, toplev, 0); + + /* Now process all the variants. This is needed for STABS. */ + for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t)) + { + if (t == TREE_TYPE (decl)) + continue; + + if (!TYPE_STUB_DECL (t)) + { + TYPE_STUB_DECL (t) = build_decl (TYPE_DECL, DECL_NAME (decl), t); + DECL_ARTIFICIAL (TYPE_STUB_DECL (t)) = 1; + } + + rest_of_type_compilation (t, toplev); + } } /* Finalize any From_With_Type incomplete types. We do this after processing diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 2cde34e6565..d13897606ba 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -447,7 +447,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) tree t = TREE_TYPE (decl); if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE) - TYPE_NAME (t) = decl; + ; else if (TYPE_FAT_POINTER_P (t)) { tree tt = build_variant_type_copy (t); @@ -455,9 +455,18 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) TREE_USED (tt) = TREE_USED (t); TREE_TYPE (decl) = tt; DECL_ORIGINAL_TYPE (decl) = t; + t = NULL_TREE; } else if (DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl)) - TYPE_NAME (t) = decl; + ; + else + t = NULL_TREE; + + /* Propagate the name to all the variants. This is needed for + the type qualifiers machinery to work properly. */ + if (t) + for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t)) + TYPE_NAME (t) = decl; } }