This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: fix -fdump-ada-spec after PR debug/51410


The fix for PR debug/51410 (http://gcc.gnu.org/PR51410) available at:
  http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00375.html
has introduced a regression in the handling of -fdump-ada-spec which
was taking the previous behavior wrt ext_block into account to
avoid generating twice the same declarations, as in:

<<
struct _jobject;

typedef struct _jobject * jobject;

void P (jobject t);
>>

which should generate:

<<
package my_type_h is

   -- skipped empty struct u_jobject

   type jobject is new System.Address; -- my_type.h:3

   procedure P (arg1 : jobject); -- my_type.h:5
   pragma Import (C, P, "P");

end my_type_h;
>>

and now generates, after PR51410 change:

<<
package my_type_h is

   -- skipped empty struct u_jobject

   type jobject is new System.Address; -- my_type.h:3

end my_type_h;
>>

Fixed by now taking into account ext_block in collect_all_refs and
for_each_global_decl (and moving the declaration of ext_block up in the
file).

Tested on i686-pc-linux-gnu, OK for trunk?

2011-01-06  Arnaud Charlet  <charlet@adacore.com>

	* c-decl.c (ext_block): Moved up.
	(collect_all_refs, for_each_global_decl): Take ext_block into account.

Index: c-decl.c
===================================================================
--- c-decl.c	(revision 182586)
+++ c-decl.c	(working copy)
@@ -9951,6 +9951,9 @@ collect_source_ref_cb (tree decl)
     collect_source_ref (LOCATION_FILE (decl_sloc (decl, false)));
 }
 
+/* Preserve the external declarations scope across a garbage collect.  */
+static GTY(()) tree ext_block;
+
 /* Collect all references relevant to SOURCE_FILE.  */
 
 static void
@@ -9961,6 +9964,8 @@ collect_all_refs (const char *source_fil
 
   FOR_EACH_VEC_ELT (tree, all_translation_units, i, t)
     collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
+
+  collect_ada_nodes (BLOCK_VARS (ext_block), source_file);
 }
 
 /* Iterate over all global declarations and call CALLBACK.  */
@@ -9979,10 +9984,10 @@ for_each_global_decl (void (*callback) (
       for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
 	callback (decl);
     }
-}
 
-/* Preserve the external declarations scope across a garbage collect.  */
-static GTY(()) tree ext_block;
+  for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl))
+    callback (decl);
+}
 
 void
 c_write_global_declarations (void)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]