G++ templates & #pragma bug fixed, patch enclosed

Melissa O'Neill oneill@cs.sfu.ca
Wed Sep 2 14:00:00 GMT 1998


Since no-one else found time to fix (or even comment on) the G++
bug I reported (under subject ``class ``implementation'' info not
always generated'') regarding template instantiation and #pragma,
I fixed it myself.

It seems that sometimes template instantiation trashes the values
stored in the global variables ``interface_unused'' and
``interface_only''. My bandaid is to save their values and restore
them in the same way (and at the same places) that ``input_file''
and ``lineno'' are also saved and restored.  It's not for me it
say whether this is the ``one true fix'' but it works for me.

Enjoy.

    Melissa.

Enc.

--- cp/pt.c.orig	Tue Aug 25 21:49:12 1998
+++ cp/pt.c	Tue Sep  1 13:43:18 1998
@@ -3621,6 +3621,8 @@
   tree new_friend;
   int line = lineno;
   char *file = input_filename;
+  int iunknown = interface_unknown;
+  int ionly    = interface_only;
 
   lineno = DECL_SOURCE_LINE (decl);
   input_filename = DECL_SOURCE_FILE (decl);
@@ -3702,6 +3704,8 @@
  done:
   lineno = line;
   input_filename = file;
+  interface_unknown = iunknown;
+  interface_only = ionly;
   return new_friend;
 }
 
@@ -7207,6 +7211,8 @@
   int pattern_defined;
   int line = lineno;
   char *file = input_filename;
+  int iunknown = interface_unknown;
+  int ionly    = interface_only;
 
   for (td = tmpl; 
        DECL_TEMPLATE_INSTANTIATION (td) 
@@ -7300,6 +7306,8 @@
          function.  */
       lineno = line;
       input_filename = file;
+      interface_unknown = iunknown;
+      interface_only = ionly;
 
       add_pending_template (d);
       goto out;
@@ -7363,6 +7371,8 @@
 out:
   lineno = line;
   input_filename = file;
+  interface_unknown = iunknown;
+  interface_only = ionly;
 
   pop_from_top_level ();
   pop_tinst_level ();



More information about the Gcc-bugs mailing list