]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-ada-spec.c (get_underlying_decl): Do not look through typedefs.
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 13 Nov 2019 11:59:20 +0000 (11:59 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 13 Nov 2019 11:59:20 +0000 (11:59 +0000)
* c-ada-spec.c (get_underlying_decl): Do not look through typedefs.
(dump_forward_type): Do not generate a declaration for function types.
(dump_nested_type) <ARRAY_TYPE>: Do not generate a nested declaration
of the component type if it is declared in another file.

From-SVN: r278130

gcc/c-family/ChangeLog
gcc/c-family/c-ada-spec.c

index 6e9ed0bb17efdfc7f7755127fd9a59baff28244c..e7f0127dcf262f7183f0a8a37d9e2e57b1dc2805 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-ada-spec.c (get_underlying_decl): Do not look through typedefs.
+       (dump_forward_type): Do not generate a declaration for function types.
+       (dump_nested_type) <ARRAY_TYPE>: Do not generate a nested declaration
+       of the component type if it is declared in another file.
+
 2019-10-21  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 76e736964dee3fe33a25a8faa1dfbe0d23f58e48..0fee9a0d0376997cc91c7a466277a3f75e772e8a 100644 (file)
@@ -1025,7 +1025,9 @@ get_underlying_decl (tree type)
 
   if (TYPE_P (type))
     {
-      type = TYPE_MAIN_VARIANT (type);
+      /* Strip qualifiers but do not look through typedefs.  */
+      if (TYPE_QUALS_NO_ADDR_SPACE (type))
+       type = TYPE_MAIN_VARIANT (type);
 
       /* type is a typedef.  */
       if (TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
@@ -2451,6 +2453,9 @@ dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc)
   if (DECL_SOURCE_FILE (decl) != DECL_SOURCE_FILE (t))
     return;
 
+  if (TREE_CODE (type) == FUNCTION_TYPE)
+    return;
+
   /* Generate an incomplete type declaration.  */
   pp_string (buffer, "type ");
   dump_ada_node (buffer, decl, NULL_TREE, spc, false, true);
@@ -2519,7 +2524,10 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent,
       while (TREE_CODE (tmp) == ARRAY_TYPE)
        tmp = TREE_TYPE (tmp);
       decl = get_underlying_decl (tmp);
-      if (decl && !DECL_NAME (decl) && !TREE_VISITED (decl))
+      if (decl
+         && !DECL_NAME (decl)
+         && DECL_SOURCE_FILE (decl) == DECL_SOURCE_FILE (t)
+         && !TREE_VISITED (decl))
        {
          /* Generate full declaration.  */
          dump_nested_type (buffer, decl, t, parent, spc);