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]

Re: analysis of libiberty/cp-demangle.c for libsupc++/__cxa_demangle


Mark Mitchell <mark@codesourcery.com> writes:

> I guess that's OK.  Obviously, you or Benjamin will have to update the
> V3 testsuite.  Perhaps you could submit a patch that includes both the
> fixes for the demangler, Benjmain's tweakage of V3 to use your
> demangler, and patches to the V3 testsuite so that all the tests still
> pass?

Here is a patch for the 3.4 branch.  This patch includes fixes to the
libiberty demangler, Benjamin's patches to libstdc++-v3 to use the
libiberty demangler rather than the libstdc++-v3 demangler, and
patches to the libstdc++-v3 testsuite so that it passes.

The appended patch does not include the diffs to the generated files,
nor does it include the two removed files.

I have tested this patch by building the compiler and running the
libiberty and libstdc++-v3 testsuites on i686-pc-linux-gnu.

The libstdc++-v3 testsuite gets one XPASS for
26_numerics/c99_classification_macros_c.cc.  I don't think this has
anything to do with my patches.

The patches to the libiberty demangler have been checked in on
mainline.  I do not currently plan to check in the libstdc++-v3
patches to mainline--that's up to the libstdc++-v3 maintainers.

Do we want this for the 3.4 branch?

Ian


libiberty/ChangeLog:

2004-02-25  Ian Lance Taylor  <ian@wasabisystems.com>

	Taken from mainline:

	2004-02-24  Ian Lance Taylor  <ian@wasabisystems.com>

	* cp-demangle.h (enum d_builtin_type_print): Add D_PRINT_UNSIGNED,
	D_PRINT_UNSIGNED_LONG, D_PRINT_LONG_LONG,
	D_PRINT_UNSIGNED_LONG_LONG, D_PRINT_FLOAT.
	* cp-demangle.c (cplus_demangle_builtin_types): Change char and
	short types to D_PRINT_DEFAULT.  Change other integer types to use
	new D_PRINT_* values where appropriate.  Change float types to
	D_PRINT_FLOAT.
	(d_print_comp) [LITERAL, LITERAL_NEG]: Handle new D_PRINT_*
	values.
	* testsuite/demangle-expected: Adjust two test cases.

	* cp-demangle.c (d_print_function_type): Print a space before the
	parenthesis around the function type in more cases.
	* testsuite/demangle-expected: Adjust one test case.

	* cp-demangle.c (d_print_comp) [UNARY]: Don't emit extra
	parentheses around a cast.
	* testsuite/demangle-expected: Adjust two test cases to match new
	output.

	* cp-demangle.c (__cxa_demangle): Pass DMGL_PARAMS to d_demangle.

	* cp-demangle.c (d_print_comp) [RESTRICT, VOLATILE, CONST]: Don't
	push more than one of the same CV-qualifier on the top of the
	stack.
	(d_print_comp) [ARRAY_TYPE]: If the array itself is CV-qualified,
	move the CV-qualifiers to apply to the element type instead.
	(d_print_array_type): When checking the modifiers, keep looking
	past ones which have been printed already.
	* testsuite/demangle-expected: Add three test cases.

	2004-02-23  Ian Lance Taylor  <ian@wasabisystems.com>

	* cp-demangle.c (__cxa_demangle): Adjust last patch to handle
	empty string correctly.

	* cp-demangle.c (__cxa_demangle): It is not an error if status is
	not NULL.  It is an error if the mangled name is the same as a
	built-in type name.
	(main): If IN_GLIBCPP_V3 is defined, test __cxa_demangle rather
	than cplus_demangle_v3.

libstdc++-v3/ChangeLog:

2004-02-25  Ian Lance Taylor  <ian@wasabisystems.com>

	* testsuite/demangle/abi_examples/01.cc: Expect error -2.
	* testsuite/demangle/abi_examples/02.cc: Likewise.
	* testsuite/demangle/regression/cw-11.cc: Likewise.
	* testsuite/demangle/regression/cw-16.cc: Change two expected
	results to match libiberty demangler output.

2004-02-25  Benjamin Kosnik  <bkoz@redhat.com>

	* libsupc++/Makefile.am: Use libiberty demangler.
	(c_sources): Add cxa_demangle.c, dyn-string.c.
	* libsupc++/Makefile.in: Regenerate.
	* src/Makefile.am (sources): Remove demangle.cc.
	* src/Makefile.in: Regenerate.
	* include/Makefile.am (bits_headers): Remove demangle.h.
	* include/Makefile.in: Regenerate.
	* include/bits/demangle.h: Remove.
	* src/demangle.cc: Remove.


Index: libiberty/cp-demangle.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.c,v
retrieving revision 1.67
diff -p -u -r1.67 cp-demangle.c
--- libiberty/cp-demangle.c	13 Jan 2004 21:35:12 -0000	1.67
+++ libiberty/cp-demangle.c	25 Feb 2004 05:28:18 -0000
@@ -1748,31 +1748,33 @@ CP_STATIC_IF_GLIBCPP_V3
 const struct demangle_builtin_type_info
 cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] =
 {
-  /* a */ { NL ("signed char"),	NL ("signed char"),	D_PRINT_INT },
+  /* a */ { NL ("signed char"),	NL ("signed char"),	D_PRINT_DEFAULT },
   /* b */ { NL ("bool"),	NL ("boolean"),		D_PRINT_BOOL },
-  /* c */ { NL ("char"),	NL ("byte"),		D_PRINT_INT },
-  /* d */ { NL ("double"),	NL ("double"),		D_PRINT_DEFAULT },
-  /* e */ { NL ("long double"),	NL ("long double"),	D_PRINT_DEFAULT },
-  /* f */ { NL ("float"),	NL ("float"),		D_PRINT_DEFAULT },
-  /* g */ { NL ("__float128"),	NL ("__float128"),	D_PRINT_DEFAULT },
-  /* h */ { NL ("unsigned char"), NL ("unsigned char"),	D_PRINT_INT },
+  /* c */ { NL ("char"),	NL ("byte"),		D_PRINT_DEFAULT },
+  /* d */ { NL ("double"),	NL ("double"),		D_PRINT_FLOAT },
+  /* e */ { NL ("long double"),	NL ("long double"),	D_PRINT_FLOAT },
+  /* f */ { NL ("float"),	NL ("float"),		D_PRINT_FLOAT },
+  /* g */ { NL ("__float128"),	NL ("__float128"),	D_PRINT_FLOAT },
+  /* h */ { NL ("unsigned char"), NL ("unsigned char"),	D_PRINT_DEFAULT },
   /* i */ { NL ("int"),		NL ("int"),		D_PRINT_INT },
-  /* j */ { NL ("unsigned int"), NL ("unsigned"),	D_PRINT_INT },
+  /* j */ { NL ("unsigned int"), NL ("unsigned"),	D_PRINT_UNSIGNED },
   /* k */ { NULL, 0,		NULL, 0,		D_PRINT_DEFAULT },
   /* l */ { NL ("long"),	NL ("long"),		D_PRINT_LONG },
-  /* m */ { NL ("unsigned long"), NL ("unsigned long"),	D_PRINT_LONG },
+  /* m */ { NL ("unsigned long"), NL ("unsigned long"),	D_PRINT_UNSIGNED_LONG },
   /* n */ { NL ("__int128"),	NL ("__int128"),	D_PRINT_DEFAULT },
-  /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"),	D_PRINT_DEFAULT },
+  /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"),
+	    D_PRINT_DEFAULT },
   /* p */ { NULL, 0,		NULL, 0,		D_PRINT_DEFAULT },
   /* q */ { NULL, 0,		NULL, 0,		D_PRINT_DEFAULT },
   /* r */ { NULL, 0,		NULL, 0,		D_PRINT_DEFAULT },
-  /* s */ { NL ("short"),	NL ("short"),		D_PRINT_INT },
-  /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_INT },
+  /* s */ { NL ("short"),	NL ("short"),		D_PRINT_DEFAULT },
+  /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_DEFAULT },
   /* u */ { NULL, 0,		NULL, 0,		D_PRINT_DEFAULT },
   /* v */ { NL ("void"),	NL ("void"),		D_PRINT_VOID },
-  /* w */ { NL ("wchar_t"),	NL ("char"),		D_PRINT_INT },
-  /* x */ { NL ("long long"),	NL ("long"),		D_PRINT_DEFAULT },
-  /* y */ { NL ("unsigned long long"), NL ("unsigned long long"), D_PRINT_DEFAULT },
+  /* w */ { NL ("wchar_t"),	NL ("char"),		D_PRINT_DEFAULT },
+  /* x */ { NL ("long long"),	NL ("long"),		D_PRINT_LONG_LONG },
+  /* y */ { NL ("unsigned long long"), NL ("unsigned long long"),
+	    D_PRINT_UNSIGNED_LONG_LONG },
   /* z */ { NL ("..."),		NL ("..."),		D_PRINT_DEFAULT },
 };
 
@@ -3050,6 +3052,30 @@ d_print_comp (dpi, dc)
     case DEMANGLE_COMPONENT_RESTRICT:
     case DEMANGLE_COMPONENT_VOLATILE:
     case DEMANGLE_COMPONENT_CONST:
+      {
+	struct d_print_mod *pdpm;
+
+	/* When printing arrays, it's possible to have cases where the
+	   same CV-qualifier gets pushed on the stack multiple times.
+	   We only need to print it once.  */
+
+	for (pdpm = dpi->modifiers; pdpm != NULL; pdpm = pdpm->next)
+	  {
+	    if (! pdpm->printed)
+	      {
+		if (pdpm->mod->type != DEMANGLE_COMPONENT_RESTRICT
+		    && pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE
+		    && pdpm->mod->type != DEMANGLE_COMPONENT_CONST)
+		  break;
+		if (pdpm->mod->type == dc->type)
+		  {
+		    d_print_comp (dpi, d_left (dc));
+		    return;
+		  }
+	      }
+	  }
+      }
+      /* Fall through.  */
     case DEMANGLE_COMPONENT_RESTRICT_THIS:
     case DEMANGLE_COMPONENT_VOLATILE_THIS:
     case DEMANGLE_COMPONENT_CONST_THIS:
@@ -3125,24 +3151,65 @@ d_print_comp (dpi, dc)
 
     case DEMANGLE_COMPONENT_ARRAY_TYPE:
       {
-	struct d_print_mod dpm;
+	struct d_print_mod *hold_modifiers;
+	struct d_print_mod adpm[4];
+	unsigned int i;
+	struct d_print_mod *pdpm;
 
 	/* We must pass this type down as a modifier in order to print
-	   multi-dimensional arrays correctly.  */
+	   multi-dimensional arrays correctly.  If the array itself is
+	   CV-qualified, we act as though the element type were
+	   CV-qualified.  We do this by copying the modifiers down
+	   rather than fiddling pointers, so that we don't wind up
+	   with a d_print_mod higher on the stack pointing into our
+	   stack frame after we return.  */
 
-	dpm.next = dpi->modifiers;
-	dpi->modifiers = &dpm;
-	dpm.mod = dc;
-	dpm.printed = 0;
-	dpm.templates = dpi->templates;
+	hold_modifiers = dpi->modifiers;
+
+	adpm[0].next = hold_modifiers;
+	dpi->modifiers = &adpm[0];
+	adpm[0].mod = dc;
+	adpm[0].printed = 0;
+	adpm[0].templates = dpi->templates;
+
+	i = 1;
+	pdpm = hold_modifiers;
+	while (pdpm != NULL
+	       && (pdpm->mod->type == DEMANGLE_COMPONENT_RESTRICT
+		   || pdpm->mod->type == DEMANGLE_COMPONENT_VOLATILE
+		   || pdpm->mod->type == DEMANGLE_COMPONENT_CONST))
+	  {
+	    if (! pdpm->printed)
+	      {
+		if (i >= sizeof adpm / sizeof adpm[0])
+		  {
+		    d_print_error (dpi);
+		    return;
+		  }
+
+		adpm[i] = *pdpm;
+		adpm[i].next = dpi->modifiers;
+		dpi->modifiers = &adpm[i];
+		pdpm->printed = 1;
+		++i;
+	      }
+
+	    pdpm = pdpm->next;
+	  }
 
 	d_print_comp (dpi, d_right (dc));
 
-	dpi->modifiers = dpm.next;
+	dpi->modifiers = hold_modifiers;
 
-	if (dpm.printed)
+	if (adpm[0].printed)
 	  return;
 
+	while (i > 1)
+	  {
+	    --i;
+	    d_print_mod (dpi, adpm[i].mod);
+	  }
+
 	d_print_array_type (dpi, dc, dpi->modifiers);
 
 	return;
@@ -3212,15 +3279,13 @@ d_print_comp (dpi, dc)
 	d_print_expr_op (dpi, d_left (dc));
       else
 	{
-	  d_append_string_constant (dpi, "((");
+	  d_append_char (dpi, '(');
 	  d_print_cast (dpi, d_left (dc));
 	  d_append_char (dpi, ')');
 	}
       d_append_char (dpi, '(');
       d_print_comp (dpi, d_right (dc));
       d_append_char (dpi, ')');
-      if (d_left (dc)->type == DEMANGLE_COMPONENT_CAST)
-	d_append_char (dpi, ')');
       return;
 
     case DEMANGLE_COMPONENT_BINARY:
@@ -3284,62 +3349,86 @@ d_print_comp (dpi, dc)
 
     case DEMANGLE_COMPONENT_LITERAL:
     case DEMANGLE_COMPONENT_LITERAL_NEG:
-      /* For some builtin types, produce simpler output.  */
-      if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE)
-	{
-	  switch (d_left (dc)->u.s_builtin.type->print)
-	    {
-	    case D_PRINT_INT:
-	      if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
-		{
-		  if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
-		    d_append_char (dpi, '-');
-		  d_print_comp (dpi, d_right (dc));
-		  return;
-		}
-	      break;
+      {
+	enum d_builtin_type_print tp;
 
-	    case D_PRINT_LONG:
-	      if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
-		{
-		  if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
-		    d_append_char (dpi, '-');
-		  d_print_comp (dpi, d_right (dc));
-		  d_append_char (dpi, 'l');
-		  return;
-		}
-	      break;
+	/* For some builtin types, produce simpler output.  */
+	tp = D_PRINT_DEFAULT;
+	if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE)
+	  {
+	    tp = d_left (dc)->u.s_builtin.type->print;
+	    switch (tp)
+	      {
+	      case D_PRINT_INT:
+	      case D_PRINT_UNSIGNED:
+	      case D_PRINT_LONG:
+	      case D_PRINT_UNSIGNED_LONG:
+	      case D_PRINT_LONG_LONG:
+	      case D_PRINT_UNSIGNED_LONG_LONG:
+		if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
+		  {
+		    if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
+		      d_append_char (dpi, '-');
+		    d_print_comp (dpi, d_right (dc));
+		    switch (tp)
+		      {
+		      default:
+			break;
+		      case D_PRINT_UNSIGNED:
+			d_append_char (dpi, 'u');
+			break;
+		      case D_PRINT_LONG:
+			d_append_char (dpi, 'l');
+			break;
+		      case D_PRINT_UNSIGNED_LONG:
+			d_append_string_constant (dpi, "ul");
+			break;
+		      case D_PRINT_LONG_LONG:
+			d_append_string_constant (dpi, "ll");
+			break;
+		      case D_PRINT_UNSIGNED_LONG_LONG:
+			d_append_string_constant (dpi, "ull");
+			break;
+		      }
+		    return;
+		  }
+		break;
 
-	    case D_PRINT_BOOL:
-	      if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME
-		  && d_right (dc)->u.s_name.len == 1
-		  && dc->type == DEMANGLE_COMPONENT_LITERAL)
-		{
-		  switch (d_right (dc)->u.s_name.s[0])
-		    {
-		    case '0':
-		      d_append_string_constant (dpi, "false");
-		      return;
-		    case '1':
-		      d_append_string_constant (dpi, "true");
-		      return;
-		    default:
-		      break;
-		    }
-		}
-	      break;
+	      case D_PRINT_BOOL:
+		if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME
+		    && d_right (dc)->u.s_name.len == 1
+		    && dc->type == DEMANGLE_COMPONENT_LITERAL)
+		  {
+		    switch (d_right (dc)->u.s_name.s[0])
+		      {
+		      case '0':
+			d_append_string_constant (dpi, "false");
+			return;
+		      case '1':
+			d_append_string_constant (dpi, "true");
+			return;
+		      default:
+			break;
+		      }
+		  }
+		break;
 
-	    default:
-	      break;
-	    }
-	}
+	      default:
+		break;
+	      }
+	  }
 
-      d_append_char (dpi, '(');
-      d_print_comp (dpi, d_left (dc));
-      d_append_char (dpi, ')');
-      if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
-	d_append_char (dpi, '-');
-      d_print_comp (dpi, d_right (dc));
+	d_append_char (dpi, '(');
+	d_print_comp (dpi, d_left (dc));
+	d_append_char (dpi, ')');
+	if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
+	  d_append_char (dpi, '-');
+	if (tp == D_PRINT_FLOAT)
+	  d_append_char (dpi, '[');
+	d_print_comp (dpi, d_right (dc));
+	if (tp == D_PRINT_FLOAT)
+	  d_append_char (dpi, ']');
+      }
       return;
 
     default:
@@ -3549,11 +3638,13 @@ d_print_function_type (dpi, dc, mods)
 {
   int need_paren;
   int saw_mod;
+  int need_space;
   struct d_print_mod *p;
   struct d_print_mod *hold_modifiers;
 
   need_paren = 0;
   saw_mod = 0;
+  need_space = 0;
   for (p = mods; p != NULL; p = p->next)
     {
       if (p->printed)
@@ -3562,15 +3653,18 @@ d_print_function_type (dpi, dc, mods)
       saw_mod = 1;
       switch (p->mod->type)
 	{
+	case DEMANGLE_COMPONENT_POINTER:
+	case DEMANGLE_COMPONENT_REFERENCE:
+	  need_paren = 1;
+	  break;
 	case DEMANGLE_COMPONENT_RESTRICT:
 	case DEMANGLE_COMPONENT_VOLATILE:
 	case DEMANGLE_COMPONENT_CONST:
 	case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
-	case DEMANGLE_COMPONENT_POINTER:
-	case DEMANGLE_COMPONENT_REFERENCE:
 	case DEMANGLE_COMPONENT_COMPLEX:
 	case DEMANGLE_COMPONENT_IMAGINARY:
 	case DEMANGLE_COMPONENT_PTRMEM_TYPE:
+	  need_space = 1;
 	  need_paren = 1;
 	  break;
 	case DEMANGLE_COMPONENT_RESTRICT_THIS:
@@ -3589,18 +3683,14 @@ d_print_function_type (dpi, dc, mods)
 
   if (need_paren)
     {
-      switch (d_last_char (dpi))
+      if (! need_space)
 	{
-	case ' ':
-	case '(':
-	case '*':
-	  break;
-
-	default:
-	  d_append_char (dpi, ' ');
-	  break;
+	  if (d_last_char (dpi) != '('
+	      && d_last_char (dpi) != '*')
+	    need_space = 1;
 	}
-
+      if (need_space && d_last_char (dpi) != ' ')
+	d_append_char (dpi, ' ');
       d_append_char (dpi, '(');
     }
 
@@ -3643,19 +3733,19 @@ d_print_array_type (dpi, dc, mods)
       need_paren = 0;
       for (p = mods; p != NULL; p = p->next)
 	{
-	  if (p->printed)
-	    break;
-
-	  if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE)
+	  if (! p->printed)
 	    {
-	      need_space = 0;
-	      break;
-	    }
-	  else
-	    {
-	      need_paren = 1;
-	      need_space = 1;
-	      break;
+	      if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE)
+		{
+		  need_space = 0;
+		  break;
+		}
+	      else
+		{
+		  need_paren = 1;
+		  need_space = 1;
+		  break;
+		}
 	    }
 	}
 
@@ -3944,29 +4034,46 @@ __cxa_demangle (mangled_name, output_buf
   char *demangled;
   size_t alc;
 
-  if (status == NULL)
-    return NULL;
-
   if (mangled_name == NULL)
     {
-      *status = -3;
+      if (status != NULL)
+	*status = -3;
       return NULL;
     }
 
   if (output_buffer != NULL && length == NULL)
     {
-      *status = -3;
+      if (status != NULL)
+	*status = -3;
       return NULL;
     }
 
-  demangled = d_demangle (mangled_name, DMGL_TYPES, &alc);
+  /* The specification for __cxa_demangle() is that if the mangled
+     name could be either an extern "C" identifier, or an internal
+     built-in type name, then we resolve it as the identifier.  All
+     internal built-in type names are a single lower case character.
+     Frankly, this simplistic disambiguation doesn't make sense to me,
+     but it is documented, so we implement it here.  */
+  if (IS_LOWER (mangled_name[0])
+      && mangled_name[1] == '\0'
+      && cplus_demangle_builtin_types[mangled_name[0] - 'a'].name != NULL)
+    {
+      if (status != NULL)
+	*status = -2;
+      return NULL;
+    }
+
+  demangled = d_demangle (mangled_name, DMGL_PARAMS | DMGL_TYPES, &alc);
 
   if (demangled == NULL)
     {
-      if (alc == 1)
-	*status = -1;
-      else
-	*status = -2;
+      if (status != NULL)
+	{
+	  if (alc == 1)
+	    *status = -1;
+	  else
+	    *status = -2;
+	}
       return NULL;
     }
 
@@ -3990,7 +4097,8 @@ __cxa_demangle (mangled_name, output_buf
 	}
     }
 
-  *status = 0;
+  if (status != NULL)
+    *status = 0;
 
   return demangled;
 }
@@ -4296,7 +4404,11 @@ main (argc, argv)
 
 	  if (dyn_string_length (mangled) > 0)
 	    {
+#ifdef IN_GLIBCPP_V3
+	      s = __cxa_demangle (dyn_string_buf (mangled), NULL, NULL, NULL);
+#else
 	      s = cplus_demangle_v3 (dyn_string_buf (mangled), options);
+#endif
 
 	      if (s != NULL)
 		{
@@ -4328,9 +4440,16 @@ main (argc, argv)
       for (i = optind; i < argc; ++i)
 	{
 	  char *s;
+#ifdef IN_GLIBCPP_V3
+	  int status;
+#endif
 
 	  /* Attempt to demangle.  */
+#ifdef IN_GLIBCPP_V3
+	  s = __cxa_demangle (argv[i], NULL, NULL, &status);
+#else
 	  s = cplus_demangle_v3 (argv[i], options);
+#endif
 
 	  /* If it worked, print the demangled name.  */
 	  if (s != NULL)
@@ -4339,7 +4458,13 @@ main (argc, argv)
 	      free (s);
 	    }
 	  else
-	    fprintf (stderr, "Failed: %s\n", argv[i]);
+	    {
+#ifdef IN_GLIBCPP_V3
+	      fprintf (stderr, "Failed: %s (status %d)\n", argv[i], status);
+#else
+	      fprintf (stderr, "Failed: %s\n", argv[i]);
+#endif
+	    }
 	}
     }
 
Index: libiberty/cp-demangle.h
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.h,v
retrieving revision 1.1
diff -p -u -r1.1 cp-demangle.h
--- libiberty/cp-demangle.h	12 Jan 2004 19:46:31 -0000	1.1
+++ libiberty/cp-demangle.h	25 Feb 2004 05:28:18 -0000
@@ -53,10 +53,20 @@ enum d_builtin_type_print
   D_PRINT_DEFAULT,
   /* Print as integer.  */
   D_PRINT_INT,
-  /* Print as long, with trailing `l'.  */
+  /* Print as unsigned integer, with trailing "u".  */
+  D_PRINT_UNSIGNED,
+  /* Print as long, with trailing "l".  */
   D_PRINT_LONG,
+  /* Print as unsigned long, with trailing "ul".  */
+  D_PRINT_UNSIGNED_LONG,
+  /* Print as long long, with trailing "ll".  */
+  D_PRINT_LONG_LONG,
+  /* Print as unsigned long long, with trailing "ull".  */
+  D_PRINT_UNSIGNED_LONG_LONG,
   /* Print as bool.  */
   D_PRINT_BOOL,
+  /* Print as float--put value in square brackets.  */
+  D_PRINT_FLOAT,
   /* Print in usual way, but here to detect void.  */
   D_PRINT_VOID
 };
Index: libiberty/testsuite/demangle-expected
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/testsuite/demangle-expected,v
retrieving revision 1.27
diff -p -u -r1.27 demangle-expected
--- libiberty/testsuite/demangle-expected	2 Jan 2004 20:33:55 -0000	1.27
+++ libiberty/testsuite/demangle-expected	25 Feb 2004 05:28:21 -0000
@@ -3591,13 +3591,13 @@ hairyfunc5
 # This is from gcc PR 8861
 --format=gnu-v3 --no-params
 _Z1fILi1ELc120EEv1AIXplT_cviLd810000000000000000703DAD7A370C5EEE
-void f<1, 120>(A<(1) + (((int)((double)810000000000000000703DAD7A370C5)))>)
-f<1, 120>
+void f<1, (char)120>(A<(1) + ((int)((double)[810000000000000000703DAD7A370C5]))>)
+f<1, (char)120>
 #
 # This is also from gcc PR 8861
 --format=gnu-v3 --no-params
 _Z1fILi1EEv1AIXplT_cvingLf3f800000EEE
-void f<1>(A<(1) + (((int)(-((float)3f800000))))>)
+void f<1>(A<(1) + ((int)(-((float)[3f800000])))>)
 f<1>
 #
 # This is from a libstdc++ debug mode patch.
@@ -3635,7 +3635,7 @@ std::operator< <file_path, std::string>
 # More hairy qualifier handling.
 --format=gnu-v3 --no-params
 _Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE
-hairyfunc(int (* const (X::** (* restrict (* volatile*(Y::*)(int) const)(char*)) [2])(long) const) [3])
+hairyfunc(int (* const (X::** (* restrict (* volatile* (Y::*)(int) const)(char*)) [2])(long) const) [3])
 hairyfunc
 #
 # Check that negative numbers are handled correctly.
@@ -3680,6 +3680,24 @@ void BBd<Foo>()::Fob::Fab() const::Gob::
 _ZNK5boost6spirit5matchI13rcs_deltatextEcvMNS0_4impl5dummyEFvvEEv
 boost::spirit::match<rcs_deltatext>::operator void (boost::spirit::impl::dummy::*)()() const
 boost::spirit::match<rcs_deltatext>::operator void (boost::spirit::impl::dummy::*)()
+#
+# Multi-dimensional arrays with qualifiers on the inner dimensions.
+--format=gnu-v3 --no-params
+_Z3fooIA6_KiEvA9_KT_rVPrS4_
+void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6])
+foo<int const [6]>
+#
+# From PR libstdc++/12736
+--format=gnu-v3 --no-params
+_Z3fooIA3_iEvRKT_
+void foo<int [3]>(int const (&) [3])
+foo<int [3]>
+#
+# Related to PR libstdc++/12736
+--format=gnu-v3 --no-params
+_Z3fooIPA3_iEvRKT_
+void foo<int (*) [3]>(int (* const&) [3])
+foo<int (*) [3]>
 #
 # Test GNU V3 constructor and destructor identification.
 # 0 means it is not a constructor/destructor.
Index: libstdc++-v3/include/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.73
diff -p -u -r1.73 Makefile.am
--- libstdc++-v3/include/Makefile.am	15 Dec 2003 21:08:02 -0000	1.73
+++ libstdc++-v3/include/Makefile.am	25 Feb 2004 05:28:22 -0000
@@ -103,7 +103,6 @@ bits_headers = \
 	${bits_srcdir}/concept_check.h \
 	${bits_srcdir}/concurrence.h \
 	${bits_srcdir}/cpp_type_traits.h \
-	${bits_srcdir}/demangle.h \
 	${bits_srcdir}/deque.tcc \
 	${bits_srcdir}/fstream.tcc \
 	${bits_srcdir}/functexcept.h \
Index: libstdc++-v3/libsupc++/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/Makefile.am,v
retrieving revision 1.48
diff -p -u -r1.48 Makefile.am
--- libstdc++-v3/libsupc++/Makefile.am	27 Aug 2003 21:29:42 -0000	1.48
+++ libstdc++-v3/libsupc++/Makefile.am	25 Feb 2004 05:28:23 -0000
@@ -1,6 +1,6 @@
 ## Makefile for the GNU C++ Support library.
 ##
-## Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 ##
 ## Process this file with automake to produce Makefile.in.
 ##
@@ -34,6 +34,9 @@ noinst_LTLIBRARIES = libsupc++convenienc
 headers = \
 	exception new typeinfo cxxabi.h exception_defines.h
 
+c_sources = \
+	cp-demangle.c 
+
 sources = \
 	del_op.cc \
 	del_opnt.cc \
@@ -62,8 +65,8 @@ sources = \
 	vec.cc \
 	vterminate.cc
 
-libsupc___la_SOURCES = $(sources)
-libsupc__convenience_la_SOURCES = $(sources)
+libsupc___la_SOURCES = $(sources) $(c_sources)
+libsupc__convenience_la_SOURCES = $(sources) $(c_sources)
 
 glibcxxinstalldir = $(gxx_include_dir)
 glibcxxinstall_HEADERS = $(headers)
@@ -82,6 +85,29 @@ AM_CXXFLAGS = \
 
 AM_MAKEFLAGS = \
 	"gxx_include_dir=$(gxx_include_dir)"
+
+
+# Use special rules for pulling things out of libiberty.  These
+# objects should be compiled with the "C" compiler, not the C++
+# compiler, and also should not use the C++ includes.
+C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include
+C_COMPILE = \
+	$(CC) $(DEFS) $(C_INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+# LTCOMPILE is copied from LTCXXCOMPILE below.
+LTCOMPILE = $(LIBTOOL) --tag CC --tag disable-shared --mode=compile $(CC) \
+	    $(DEFS) $(C_INCLUDES) $(LIBSUPCXX_PICFLAGS) \
+            $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+cp-demangle.c:
+	rm -f $@
+	$(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@
+cp-demangle.lo: cp-demangle.c
+	$(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+cp-demangle.o: cp-demangle.c
+	$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+
 
 # libstdc++ libtool notes
 
Index: libstdc++-v3/src/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.139
diff -p -u -r1.139 Makefile.am
--- libstdc++-v3/src/Makefile.am	7 Jan 2004 20:55:05 -0000	1.139
+++ libstdc++-v3/src/Makefile.am	25 Feb 2004 05:28:23 -0000
@@ -95,7 +95,6 @@ sources = \
 	complex_io.cc \
 	ctype.cc \
 	debug.cc \
-	demangle.cc \
 	functexcept.cc \
 	globals_locale.cc \
 	globals_io.cc \
Index: libstdc++-v3/testsuite/demangle/abi_examples/01.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/abi_examples/01.cc,v
retrieving revision 1.2
diff -p -u -r1.2 01.cc
--- libstdc++-v3/testsuite/demangle/abi_examples/01.cc	24 Jul 2003 21:08:01 -0000	1.2
+++ libstdc++-v3/testsuite/demangle/abi_examples/01.cc	25 Feb 2004 05:28:33 -0000
@@ -31,7 +31,7 @@ int main()
   // extern "C" function 
   // extern "C" float f(void) { };
   // T f
-  verify_demangle("f", "f");
+  verify_demangle("f", "error code = -2: invalid mangled name");
 
   return 0;
 }
Index: libstdc++-v3/testsuite/demangle/abi_examples/02.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/abi_examples/02.cc,v
retrieving revision 1.2
diff -p -u -r1.2 02.cc
--- libstdc++-v3/testsuite/demangle/abi_examples/02.cc	24 Jul 2003 21:08:01 -0000	1.2
+++ libstdc++-v3/testsuite/demangle/abi_examples/02.cc	25 Feb 2004 05:28:33 -0000
@@ -31,7 +31,7 @@ int main()
   // or variable "f" 
   // int f;
   // B f
-  verify_demangle("f", "f");  
+  verify_demangle("f", "error code = -2: invalid mangled name");
 
   return 0;
 }
Index: libstdc++-v3/testsuite/demangle/regression/cw-11.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/regression/cw-11.cc,v
retrieving revision 1.2
diff -p -u -r1.2 cw-11.cc
--- libstdc++-v3/testsuite/demangle/regression/cw-11.cc	24 Jul 2003 21:08:02 -0000	1.2
+++ libstdc++-v3/testsuite/demangle/regression/cw-11.cc	25 Feb 2004 05:28:33 -0000
@@ -28,7 +28,8 @@ int main()
   using namespace __gnu_test;
 
   // cplus-dem CORE
-  verify_demangle("_X11TransParseAddress", "_X11TransParseAddress");
+  verify_demangle("_X11TransParseAddress",
+		  "error code = -2: invalid mangled name");
 
   return 0;
 }
Index: libstdc++-v3/testsuite/demangle/regression/cw-16.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/demangle/regression/cw-16.cc,v
retrieving revision 1.4
diff -p -u -r1.4 cw-16.cc
--- libstdc++-v3/testsuite/demangle/regression/cw-16.cc	5 Dec 2003 02:40:53 -0000	1.4
+++ libstdc++-v3/testsuite/demangle/regression/cw-16.cc	25 Feb 2004 05:28:33 -0000
@@ -29,14 +29,14 @@ int main()
 
 // 2003/11/07, libstdc++/12736
 verify_demangle("_Z3fooIA6_KiEvA9_KT_rVPrS4_",
-		"void foo<int const [6]>(int const [9][6], int const restrict (* volatile restrict) [9][6])");
+		"void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6])");
 // 2003/11/12, libstdc++/12947
 verify_demangle("_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE",
                 "void f<5, A>(C<(((5) > (0))) ? (1) : (2)>::q)");
 verify_demangle("_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE",
                 "void f<5>(A<(int)((5) * (22))>::q)");
 verify_demangle("_Z1fPFYPFiiEiE",
-                "f(int (*(*) [extern \"C\"] (int))(int))");
+                "f(int (*(*)(int))(int))");
 verify_demangle("_Z1fI1XENT_1tES2_",
                 "X::t f<X>(X::t)");
 verify_demangle("_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE",


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