Patchwork [c-family] Small tweak to -fdump-ada-spec

login
register
mail settings
Submitter Eric Botcazou
Date Oct. 9, 2012, 11:34 a.m.
Message ID <3282139.CPa9RoBt6V@polaris>
Download mbox | patch
Permalink /patch/190283/
State New
Headers show

Comments

Eric Botcazou - Oct. 9, 2012, 11:34 a.m.
Hi,

we noticed that we dump TEMPLATE_DECLs that are built for template friend 
declarations in the current file, which doesn't really make sense.

Tested on x86_64-suse-linux, OK for the mainline?


2012-10-09  Eric Botcazou  <ebotcazou@adacore.com>

	* c-ada-spec.c (dump_ada_template): Bail out for template declarations
	declaring something coming from another file.
Eric Botcazou - Oct. 11, 2012, 10:30 a.m.
> 2012-10-09  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* c-ada-spec.c (dump_ada_template): Bail out for template declarations
> 	declaring something coming from another file.

That's a small patch affecting only -fdump-ada-spec so I went ahead and 
installed it on the mainline.

Patch

Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c	(revision 192137)
+++ c-ada-spec.c	(working copy)
@@ -1700,10 +1700,18 @@  static int
 dump_ada_template (pretty_printer *buffer, tree t,
 		   int (*cpp_check)(tree, cpp_operation), int spc)
 {
-  tree inst = DECL_VINDEX (t);
   /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context.  */
+  tree inst = DECL_VINDEX (t);
+  /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context.  */
+  tree result = DECL_RESULT_FLD (t);
   int num_inst = 0;
 
+  /* Don't look at template declarations declaring something coming from
+     another file.  This can occur for template friend declarations.  */
+  if (LOCATION_FILE (decl_sloc (result, false))
+      != LOCATION_FILE (decl_sloc (t, false)))
+    return 0;
+
   while (inst && inst != error_mark_node)
     {
       tree types = TREE_PURPOSE (inst);