This is the mail archive of the gcc-bugs@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]

Bug in cplus-dem.c


I think there is a bug in this change to cplus-dem.c:

1998-03-24  Mark Mitchell  <mmitchell@usa.net>

	* cplus-dem.c (optable): Add sizeof.
	(demangle_template_value_parm): New function containing code
	previously found in demangle_template.
	(demangle_integral_value): New function which handles complicated
	integral expressions.
	(demangle_template): Use them.

The newly created demangle_template_value_parm does not make sense.
It uses *mangled in two different ways: first as a pointer to a type,
and second as a pointer to a value.

The original code set old_p to *mangled and then called do_type and
then did the parsing now done in demangle_template_value_parm.  So the
original code had different values in old_p and *mangled, while the
new code does not.

The effect seems to be that the type of a template parameter is
ignored, and thus something like foo__t3bar1b0 will be demangled as
bar<0>::foo(void), when it should of course be demangled as
bar<false>::foo(void).

I have appended a partial patch, which fixes the case just cited.
However, this patch is not correct, because the same error appears to
occur in the call to demangle_template_value_parm in
demangle_integral_value.  I do not know what demangle_integral_value
is doing, and I do not know how to create an example, so I do not know
how to fix it correctly.

Ian

Index: cplus-dem.c
===================================================================
RCS file: /cvs/cvsfiles/devo/libiberty/cplus-dem.c,v
retrieving revision 1.88
diff -u -r1.88 cplus-dem.c
--- cplus-dem.c	1998/05/16 06:01:48	1.88
+++ cplus-dem.c	1998/07/02 03:41:51
@@ -357,7 +357,7 @@
 string_prepends PARAMS ((string *, string *));
 
 static int 
-demangle_template_value_parm PARAMS ((struct work_stuff*, 
+demangle_template_value_parm PARAMS ((struct work_stuff*, const char *,
 				      const char**, string*)); 
 
 /*  Translate count to integer, consuming tokens in the process.
@@ -1149,7 +1149,7 @@
 	  else
 	    need_operator = 1;
 
-	  success = demangle_template_value_parm (work, mangled, s);
+	  success = demangle_template_value_parm (work, *mangled, mangled, s);
 	}
 
       if (**mangled != 'W')
@@ -1183,12 +1183,12 @@
 }
 
 static int 
-demangle_template_value_parm (work, mangled, s)
+demangle_template_value_parm (work, old_p, mangled, s)
      struct work_stuff *work;
+     const char *old_p;
      const char **mangled;
      string* s;
 {
-  const char *old_p = *mangled;
   int is_pointer = 0;
   int is_real = 0;
   int is_integral = 0;
@@ -1516,11 +1516,14 @@
 	}
       else
 	{
+	  const char *old_p;
 	  string  param;
 	  string* s;
 
 	  /* otherwise, value parameter */
 
+	  old_p = *mangled;
+
 	  /* temp is initialized in do_type */
 	  success = do_type (work, mangled, &temp);
 	  /*
@@ -1546,7 +1549,7 @@
 	  else
 	    s = tname;
 
-	  success = demangle_template_value_parm (work, mangled, s);
+	  success = demangle_template_value_parm (work, old_p, mangled, s);
 
 	  if (!success)
 	    {



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