diff mbox series

[Ada] Fix -fdump-ada-spec issue with array field

Message ID 2601463.SceXTyEzXo@polaris
State New
Headers show
Series [Ada] Fix -fdump-ada-spec issue with array field | expand

Commit Message

Eric Botcazou Nov. 13, 2019, noon UTC
This is a regression present on mainline and 9 branch: if the component type 
of array type is a structure declared in another file, then the binding would 
contain a local declaration for this structure type.

Tested on x86_64-suse-linux, applied on the mainline and 9 branch.


2019-11-13  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	* 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.
diff mbox series

Patch

Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c	(revision 277906)
+++ c-ada-spec.c	(working copy)
@@ -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)))
@@ -2454,6 +2456,9 @@  dump_forward_type (pretty_printer *buffe
   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);
@@ -2522,7 +2527,10 @@  dump_nested_type (pretty_printer *buffer
       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);