[1/3] cp-demangle.c: Make `options' a parameter
diff mbox

Message ID 20110602141532.GB15093@host1.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil June 2, 2011, 2:15 p.m. UTC
Hi,

this patch makes no functionality change, it only reshuffles the code.

After printing the toplevel function type we want to disable DMGL_RET_POSTFIX
for any inner types.  Without such DMGL_RET_POSTFIX disabling for inner types
the new testcase would:

FAIL at line 3973, options --format=gnu-v3 --ret-postfix:
in:  _Z5outerIsEcPFilE
out: outer<short>((*)(long)int)char
exp: outer<short>(int (*)(long))char

At least I believe the "exp" form is what a user expects.

As so far DMGL_RET_POSTFIX was used (at least in GDB) only with DMGL_JAVA and
Java does not support pointers to methods it just was not needed so far.


Thanks,
Jan


libiberty/
2011-05-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-demangle.c (struct d_print_info): Remove field options.
	(d_print_init): Remove parameter options.
	(cplus_demangle_print_callback): Update all the callers.
	(d_print_comp, d_print_mod_list, d_print_mod, d_print_function_type)
	(d_print_array_type, d_print_expr_op, d_print_cast, d_print_subexpr):
	Add parameter options, update all the callers.

Comments

Ian Taylor June 13, 2011, 6:06 p.m. UTC | #1
On Thu, Jun 2, 2011 at 7:15 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
>
> libiberty/
> 2011-05-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * cp-demangle.c (struct d_print_info): Remove field options.
>        (d_print_init): Remove parameter options.
>        (cplus_demangle_print_callback): Update all the callers.
>        (d_print_comp, d_print_mod_list, d_print_mod, d_print_function_type)
>        (d_print_array_type, d_print_expr_op, d_print_cast, d_print_subexpr):
>        Add parameter options, update all the callers.

>  static void
> -d_print_comp (struct d_print_info *, const struct demangle_component *);
> +d_print_comp (struct d_print_info *, const struct demangle_component *, int);

The new options parameter should be the second parameter, not the last.

>  static void
> -d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
> +d_print_mod_list (struct d_print_info *, struct d_print_mod *, int, int);

Likewise.

>  static void
> -d_print_mod (struct d_print_info *, const struct demangle_component *);
> +d_print_mod (struct d_print_info *, const struct demangle_component *, int);

Likewise.

>  static void
>  d_print_function_type (struct d_print_info *,
>                        const struct demangle_component *,
> -                       struct d_print_mod *);
> +                       struct d_print_mod *, int);

Likewise.

>  static void
>  d_print_array_type (struct d_print_info *,
>                     const struct demangle_component *,
> -                    struct d_print_mod *);
> +                    struct d_print_mod *, int);

Likewise.

>  static void
> -d_print_expr_op (struct d_print_info *, const struct demangle_component *);
> +d_print_expr_op (struct d_print_info *, const struct demangle_component *, int);

Likewise.

>  static void
> -d_print_cast (struct d_print_info *, const struct demangle_component *);
> +d_print_cast (struct d_print_info *, const struct demangle_component *, int);

Likewise.

You will have to change the function definitions and calls accordingly.

This is OK with those changes.

Thanks.

Ian

Patch
diff mbox

--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -278,8 +278,6 @@  struct d_growable_string
 enum { D_PRINT_BUFFER_LENGTH = 256 };
 struct d_print_info
 {
-  /* The options passed to the demangler.  */
-  int options;
   /* Fixed-length allocated buffer for demangled data, flushed to the
      callback with a NUL termination once full.  */
   char buf[D_PRINT_BUFFER_LENGTH];
@@ -436,7 +434,7 @@  static void
 d_growable_string_callback_adapter (const char *, size_t, void *);
 
 static void
-d_print_init (struct d_print_info *, int, demangle_callbackref, void *);
+d_print_init (struct d_print_info *, demangle_callbackref, void *);
 
 static inline void d_print_error (struct d_print_info *);
 
@@ -454,32 +452,32 @@  static inline void d_append_string (struct d_print_info *, const char *);
 static inline char d_last_char (struct d_print_info *);
 
 static void
-d_print_comp (struct d_print_info *, const struct demangle_component *);
+d_print_comp (struct d_print_info *, const struct demangle_component *, int);
 
 static void
 d_print_java_identifier (struct d_print_info *, const char *, int);
 
 static void
-d_print_mod_list (struct d_print_info *, struct d_print_mod *, int);
+d_print_mod_list (struct d_print_info *, struct d_print_mod *, int, int);
 
 static void
-d_print_mod (struct d_print_info *, const struct demangle_component *);
+d_print_mod (struct d_print_info *, const struct demangle_component *, int);
 
 static void
 d_print_function_type (struct d_print_info *,
                        const struct demangle_component *,
-                       struct d_print_mod *);
+                       struct d_print_mod *, int);
 
 static void
 d_print_array_type (struct d_print_info *,
                     const struct demangle_component *,
-                    struct d_print_mod *);
+                    struct d_print_mod *, int);
 
 static void
-d_print_expr_op (struct d_print_info *, const struct demangle_component *);
+d_print_expr_op (struct d_print_info *, const struct demangle_component *, int);
 
 static void
-d_print_cast (struct d_print_info *, const struct demangle_component *);
+d_print_cast (struct d_print_info *, const struct demangle_component *, int);
 
 static int d_demangle_callback (const char *, int,
                                 demangle_callbackref, void *);
@@ -3293,10 +3291,9 @@  d_growable_string_callback_adapter (const char *s, size_t l, void *opaque)
 /* Initialize a print information structure.  */
 
 static void
-d_print_init (struct d_print_info *dpi, int options,
-              demangle_callbackref callback, void *opaque)
+d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
+	      void *opaque)
 {
-  dpi->options = options;
   dpi->len = 0;
   dpi->last_char = '\0';
   dpi->templates = NULL;
@@ -3392,9 +3389,9 @@  cplus_demangle_print_callback (int options,
 {
   struct d_print_info dpi;
 
-  d_print_init (&dpi, options, callback, opaque);
+  d_print_init (&dpi, callback, opaque);
 
-  d_print_comp (&dpi, dc);
+  d_print_comp (&dpi, dc, options);
 
   d_print_flush (&dpi);
 
@@ -3537,8 +3534,8 @@  d_pack_length (const struct demangle_component *dc)
    if needed.  */
 
 static void
-d_print_subexpr (struct d_print_info *dpi,
-		 const struct demangle_component *dc)
+d_print_subexpr (struct d_print_info *dpi, const struct demangle_component *dc,
+		 int options)
 {
   int simple = 0;
   if (dc->type == DEMANGLE_COMPONENT_NAME
@@ -3546,7 +3543,7 @@  d_print_subexpr (struct d_print_info *dpi,
     simple = 1;
   if (!simple)
     d_append_char (dpi, '(');
-  d_print_comp (dpi, dc);
+  d_print_comp (dpi, dc, options);
   if (!simple)
     d_append_char (dpi, ')');
 }
@@ -3554,8 +3551,8 @@  d_print_subexpr (struct d_print_info *dpi,
 /* Subroutine to handle components.  */
 
 static void
-d_print_comp (struct d_print_info *dpi,
-              const struct demangle_component *dc)
+d_print_comp (struct d_print_info *dpi, const struct demangle_component *dc,
+	      int options)
 {
   if (dc == NULL)
     {
@@ -3568,7 +3565,7 @@  d_print_comp (struct d_print_info *dpi,
   switch (dc->type)
     {
     case DEMANGLE_COMPONENT_NAME:
-      if ((dpi->options & DMGL_JAVA) == 0)
+      if ((options & DMGL_JAVA) == 0)
 	d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len);
       else
 	d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len);
@@ -3576,12 +3573,12 @@  d_print_comp (struct d_print_info *dpi,
 
     case DEMANGLE_COMPONENT_QUAL_NAME:
     case DEMANGLE_COMPONENT_LOCAL_NAME:
-      d_print_comp (dpi, d_left (dc));
-      if ((dpi->options & DMGL_JAVA) == 0)
+      d_print_comp (dpi, d_left (dc), options);
+      if ((options & DMGL_JAVA) == 0)
 	d_append_string (dpi, "::");
       else
 	d_append_char (dpi, '.');
-      d_print_comp (dpi, d_right (dc));
+      d_print_comp (dpi, d_right (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_TYPED_NAME:
@@ -3671,7 +3668,7 @@  d_print_comp (struct d_print_info *dpi,
 	      }
 	  }
 
-	d_print_comp (dpi, d_right (dc));
+	d_print_comp (dpi, d_right (dc), options);
 
 	if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE)
 	  dpi->templates = dpt.next;
@@ -3684,7 +3681,7 @@  d_print_comp (struct d_print_info *dpi,
 	    if (! adpm[i].printed)
 	      {
 		d_append_char (dpi, ' ');
-		d_print_mod (dpi, adpm[i].mod);
+		d_print_mod (dpi, adpm[i].mod, options);
 	      }
 	  }
 
@@ -3707,7 +3704,7 @@  d_print_comp (struct d_print_info *dpi,
 
         dcl = d_left (dc);
 
-        if ((dpi->options & DMGL_JAVA) != 0
+        if ((options & DMGL_JAVA) != 0
             && dcl->type == DEMANGLE_COMPONENT_NAME
             && dcl->u.s_name.len == 6
             && strncmp (dcl->u.s_name.s, "JArray", 6) == 0)
@@ -3715,16 +3712,16 @@  d_print_comp (struct d_print_info *dpi,
             /* Special-case Java arrays, so that JArray<TYPE> appears
                instead as TYPE[].  */
 
-            d_print_comp (dpi, d_right (dc));
+            d_print_comp (dpi, d_right (dc), options);
             d_append_string (dpi, "[]");
           }
         else
           {
-	    d_print_comp (dpi, dcl);
+	    d_print_comp (dpi, dcl, options);
 	    if (d_last_char (dpi) == '<')
 	      d_append_char (dpi, ' ');
 	    d_append_char (dpi, '<');
-	    d_print_comp (dpi, d_right (dc));
+	    d_print_comp (dpi, d_right (dc), options);
 	    /* Avoid generating two consecutive '>' characters, to avoid
 	       the C++ syntactic ambiguity.  */
 	    if (d_last_char (dpi) == '>')
@@ -3759,7 +3756,7 @@  d_print_comp (struct d_print_info *dpi,
 	hold_dpt = dpi->templates;
 	dpi->templates = hold_dpt->next;
 
-	d_print_comp (dpi, a);
+	d_print_comp (dpi, a, options);
 
 	dpi->templates = hold_dpt;
 
@@ -3767,79 +3764,79 @@  d_print_comp (struct d_print_info *dpi,
       }
 
     case DEMANGLE_COMPONENT_CTOR:
-      d_print_comp (dpi, dc->u.s_ctor.name);
+      d_print_comp (dpi, dc->u.s_ctor.name, options);
       return;
 
     case DEMANGLE_COMPONENT_DTOR:
       d_append_char (dpi, '~');
-      d_print_comp (dpi, dc->u.s_dtor.name);
+      d_print_comp (dpi, dc->u.s_dtor.name, options);
       return;
 
     case DEMANGLE_COMPONENT_VTABLE:
       d_append_string (dpi, "vtable for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_VTT:
       d_append_string (dpi, "VTT for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:
       d_append_string (dpi, "construction vtable for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       d_append_string (dpi, "-in-");
-      d_print_comp (dpi, d_right (dc));
+      d_print_comp (dpi, d_right (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_TYPEINFO:
       d_append_string (dpi, "typeinfo for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_TYPEINFO_NAME:
       d_append_string (dpi, "typeinfo name for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_TYPEINFO_FN:
       d_append_string (dpi, "typeinfo fn for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_THUNK:
       d_append_string (dpi, "non-virtual thunk to ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_VIRTUAL_THUNK:
       d_append_string (dpi, "virtual thunk to ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_COVARIANT_THUNK:
       d_append_string (dpi, "covariant return thunk to ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_JAVA_CLASS:
       d_append_string (dpi, "java Class for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_GUARD:
       d_append_string (dpi, "guard variable for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_REFTEMP:
       d_append_string (dpi, "reference temporary for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
       d_append_string (dpi, "hidden alias for ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_SUB_STD:
@@ -3866,7 +3863,7 @@  d_print_comp (struct d_print_info *dpi,
 		  break;
 		if (pdpm->mod->type == dc->type)
 		  {
-		    d_print_comp (dpi, d_left (dc));
+		    d_print_comp (dpi, d_left (dc), options);
 		    return;
 		  }
 	      }
@@ -3892,12 +3889,12 @@  d_print_comp (struct d_print_info *dpi,
 	dpm.printed = 0;
 	dpm.templates = dpi->templates;
 
-	d_print_comp (dpi, d_left (dc));
+	d_print_comp (dpi, d_left (dc), options);
 
 	/* If the modifier didn't get printed by the type, print it
 	   now.  */
 	if (! dpm.printed)
-	  d_print_mod (dpi, dc);
+	  d_print_mod (dpi, dc, options);
 
 	dpi->modifiers = dpm.next;
 
@@ -3905,7 +3902,7 @@  d_print_comp (struct d_print_info *dpi,
       }
 
     case DEMANGLE_COMPONENT_BUILTIN_TYPE:
-      if ((dpi->options & DMGL_JAVA) == 0)
+      if ((options & DMGL_JAVA) == 0)
 	d_append_buffer (dpi, dc->u.s_builtin.type->name,
 			 dc->u.s_builtin.type->len);
       else
@@ -3914,13 +3911,13 @@  d_print_comp (struct d_print_info *dpi,
       return;
 
     case DEMANGLE_COMPONENT_VENDOR_TYPE:
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_FUNCTION_TYPE:
       {
-	if ((dpi->options & DMGL_RET_POSTFIX) != 0)
-	  d_print_function_type (dpi, dc, dpi->modifiers);
+	if ((options & DMGL_RET_POSTFIX) != 0)
+	  d_print_function_type (dpi, dc, dpi->modifiers, options);
 
 	/* Print return type if present */
 	if (d_left (dc) != NULL)
@@ -3935,7 +3932,7 @@  d_print_comp (struct d_print_info *dpi,
 	    dpm.printed = 0;
 	    dpm.templates = dpi->templates;
 
-	    d_print_comp (dpi, d_left (dc));
+	    d_print_comp (dpi, d_left (dc), options);
 
 	    dpi->modifiers = dpm.next;
 
@@ -3944,12 +3941,12 @@  d_print_comp (struct d_print_info *dpi,
 
 	    /* In standard prefix notation, there is a space between the
 	       return type and the function signature.  */
-	    if ((dpi->options & DMGL_RET_POSTFIX) == 0)
+	    if ((options & DMGL_RET_POSTFIX) == 0)
 	      d_append_char (dpi, ' ');
 	  }
 
-	if ((dpi->options & DMGL_RET_POSTFIX) == 0) 
-	  d_print_function_type (dpi, dc, dpi->modifiers);
+	if ((options & DMGL_RET_POSTFIX) == 0)
+	  d_print_function_type (dpi, dc, dpi->modifiers, options);
 
 	return;
       }
@@ -4002,7 +3999,7 @@  d_print_comp (struct d_print_info *dpi,
 	    pdpm = pdpm->next;
 	  }
 
-	d_print_comp (dpi, d_right (dc));
+	d_print_comp (dpi, d_right (dc), options);
 
 	dpi->modifiers = hold_modifiers;
 
@@ -4012,10 +4009,10 @@  d_print_comp (struct d_print_info *dpi,
 	while (i > 1)
 	  {
 	    --i;
-	    d_print_mod (dpi, adpm[i].mod);
+	    d_print_mod (dpi, adpm[i].mod, options);
 	  }
 
-	d_print_array_type (dpi, dc, dpi->modifiers);
+	d_print_array_type (dpi, dc, dpi->modifiers, options);
 
 	return;
       }
@@ -4031,12 +4028,12 @@  d_print_comp (struct d_print_info *dpi,
 	dpm.printed = 0;
 	dpm.templates = dpi->templates;
 
-	d_print_comp (dpi, d_right (dc));
+	d_print_comp (dpi, d_right (dc), options);
 
 	/* If the modifier didn't get printed by the type, print it
 	   now.  */
 	if (! dpm.printed)
-	  d_print_mod (dpi, dc);
+	  d_print_mod (dpi, dc, options);
 
 	dpi->modifiers = dpm.next;
 
@@ -4050,7 +4047,7 @@  d_print_comp (struct d_print_info *dpi,
       if (dc->u.s_fixed.length->u.s_builtin.type
 	  != &cplus_demangle_builtin_types['i'-'a'])
 	{
-	  d_print_comp (dpi, dc->u.s_fixed.length);
+	  d_print_comp (dpi, dc->u.s_fixed.length, options);
 	  d_append_char (dpi, ' ');
 	}
       if (dc->u.s_fixed.accum)
@@ -4062,7 +4059,7 @@  d_print_comp (struct d_print_info *dpi,
     case DEMANGLE_COMPONENT_ARGLIST:
     case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:
       if (d_left (dc) != NULL)
-	d_print_comp (dpi, d_left (dc));
+	d_print_comp (dpi, d_left (dc), options);
       if (d_right (dc) != NULL)
 	{
 	  size_t len;
@@ -4074,7 +4071,7 @@  d_print_comp (struct d_print_info *dpi,
 	  d_append_string (dpi, ", ");
 	  len = dpi->len;
 	  flush_count = dpi->flush_count;
-	  d_print_comp (dpi, d_right (dc));
+	  d_print_comp (dpi, d_right (dc), options);
 	  /* If that didn't print anything (which can happen with empty
 	     template argument packs), remove the comma and space.  */
 	  if (dpi->flush_count == flush_count && dpi->len == len)
@@ -4097,24 +4094,24 @@  d_print_comp (struct d_print_info *dpi,
 
     case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:
       d_append_string (dpi, "operator ");
-      d_print_comp (dpi, dc->u.s_extended_operator.name);
+      d_print_comp (dpi, dc->u.s_extended_operator.name, options);
       return;
 
     case DEMANGLE_COMPONENT_CAST:
       d_append_string (dpi, "operator ");
-      d_print_cast (dpi, dc);
+      d_print_cast (dpi, dc, options);
       return;
 
     case DEMANGLE_COMPONENT_UNARY:
       if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST)
-	d_print_expr_op (dpi, d_left (dc));
+	d_print_expr_op (dpi, d_left (dc), options);
       else
 	{
 	  d_append_char (dpi, '(');
-	  d_print_cast (dpi, d_left (dc));
+	  d_print_cast (dpi, d_left (dc), options);
 	  d_append_char (dpi, ')');
 	}
-      d_print_subexpr (dpi, d_right (dc));
+      d_print_subexpr (dpi, d_right (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_BINARY:
@@ -4132,18 +4129,18 @@  d_print_comp (struct d_print_info *dpi,
 	  && d_left (dc)->u.s_operator.op->name[0] == '>')
 	d_append_char (dpi, '(');
 
-      d_print_subexpr (dpi, d_left (d_right (dc)));
+      d_print_subexpr (dpi, d_left (d_right (dc)), options);
       if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0)
 	{
 	  d_append_char (dpi, '[');
-	  d_print_comp (dpi, d_right (d_right (dc)));
+	  d_print_comp (dpi, d_right (d_right (dc)), options);
 	  d_append_char (dpi, ']');
 	}
       else
 	{
 	  if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0)
-	    d_print_expr_op (dpi, d_left (dc));
-	  d_print_subexpr (dpi, d_right (d_right (dc)));
+	    d_print_expr_op (dpi, d_left (dc), options);
+	  d_print_subexpr (dpi, d_right (d_right (dc)), options);
 	}
 
       if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
@@ -4165,11 +4162,11 @@  d_print_comp (struct d_print_info *dpi,
 	  d_print_error (dpi);
 	  return;
 	}
-      d_print_subexpr (dpi, d_left (d_right (dc)));
-      d_print_expr_op (dpi, d_left (dc));
-      d_print_subexpr (dpi, d_left (d_right (d_right (dc))));
+      d_print_subexpr (dpi, d_left (d_right (dc)), options);
+      d_print_expr_op (dpi, d_left (dc), options);
+      d_print_subexpr (dpi, d_left (d_right (d_right (dc))), options);
       d_append_string (dpi, " : ");
-      d_print_subexpr (dpi, d_right (d_right (d_right (dc))));
+      d_print_subexpr (dpi, d_right (d_right (d_right (dc))), options);
       return;
 
     case DEMANGLE_COMPONENT_TRINARY_ARG1:
@@ -4200,7 +4197,7 @@  d_print_comp (struct d_print_info *dpi,
 		  {
 		    if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
 		      d_append_char (dpi, '-');
-		    d_print_comp (dpi, d_right (dc));
+		    d_print_comp (dpi, d_right (dc), options);
 		    switch (tp)
 		      {
 		      default:
@@ -4250,13 +4247,13 @@  d_print_comp (struct d_print_info *dpi,
 	  }
 
 	d_append_char (dpi, '(');
-	d_print_comp (dpi, d_left (dc));
+	d_print_comp (dpi, d_left (dc), options);
 	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));
+	d_print_comp (dpi, d_right (dc), options);
 	if (tp == D_PRINT_FLOAT)
 	  d_append_char (dpi, ']');
       }
@@ -4268,12 +4265,12 @@  d_print_comp (struct d_print_info *dpi,
 
     case DEMANGLE_COMPONENT_JAVA_RESOURCE:
       d_append_string (dpi, "java resource ");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_COMPOUND_NAME:
-      d_print_comp (dpi, d_left (dc));
-      d_print_comp (dpi, d_right (dc));
+      d_print_comp (dpi, d_left (dc), options);
+      d_print_comp (dpi, d_right (dc), options);
       return;
 
     case DEMANGLE_COMPONENT_CHARACTER:
@@ -4282,7 +4279,7 @@  d_print_comp (struct d_print_info *dpi,
 
     case DEMANGLE_COMPONENT_DECLTYPE:
       d_append_string (dpi, "decltype (");
-      d_print_comp (dpi, d_left (dc));
+      d_print_comp (dpi, d_left (dc), options);
       d_append_char (dpi, ')');
       return;
 
@@ -4296,7 +4293,7 @@  d_print_comp (struct d_print_info *dpi,
 	    /* d_find_pack won't find anything if the only packs involved
 	       in this expansion are function parameter packs; in that
 	       case, just print the pattern and "...".  */
-	    d_print_subexpr (dpi, d_left (dc));
+	    d_print_subexpr (dpi, d_left (dc), options);
 	    d_append_string (dpi, "...");
 	    return;
 	  }
@@ -4306,7 +4303,7 @@  d_print_comp (struct d_print_info *dpi,
 	for (i = 0; i < len; ++i)
 	  {
 	    dpi->pack_index = i;
-	    d_print_comp (dpi, dc);
+	    d_print_comp (dpi, dc, options);
 	    if (i < len-1)
 	      d_append_string (dpi, ", ");
 	  }
@@ -4321,17 +4318,17 @@  d_print_comp (struct d_print_info *dpi,
 
     case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
       d_append_string (dpi, "global constructors keyed to ");
-      d_print_comp (dpi, dc->u.s_binary.left);
+      d_print_comp (dpi, dc->u.s_binary.left, options);
       return;
 
     case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
       d_append_string (dpi, "global destructors keyed to ");
-      d_print_comp (dpi, dc->u.s_binary.left);
+      d_print_comp (dpi, dc->u.s_binary.left, options);
       return;
 
     case DEMANGLE_COMPONENT_LAMBDA:
       d_append_string (dpi, "{lambda(");
-      d_print_comp (dpi, dc->u.s_unary_num.sub);
+      d_print_comp (dpi, dc->u.s_unary_num.sub, options);
       d_append_string (dpi, ")#");
       d_append_num (dpi, dc->u.s_unary_num.num + 1);
       d_append_char (dpi, '}');
@@ -4405,8 +4402,8 @@  d_print_java_identifier (struct d_print_info *dpi, const char *name, int len)
    qualifiers on this after printing a function.  */
 
 static void
-d_print_mod_list (struct d_print_info *dpi,
-                  struct d_print_mod *mods, int suffix)
+d_print_mod_list (struct d_print_info *dpi, struct d_print_mod *mods,
+		  int suffix, int options)
 {
   struct d_print_template *hold_dpt;
 
@@ -4419,7 +4416,7 @@  d_print_mod_list (struct d_print_info *dpi,
 	      || mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS
 	      || mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS)))
     {
-      d_print_mod_list (dpi, mods->next, suffix);
+      d_print_mod_list (dpi, mods->next, suffix, options);
       return;
     }
 
@@ -4430,13 +4427,13 @@  d_print_mod_list (struct d_print_info *dpi,
 
   if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
     {
-      d_print_function_type (dpi, mods->mod, mods->next);
+      d_print_function_type (dpi, mods->mod, mods->next, options);
       dpi->templates = hold_dpt;
       return;
     }
   else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE)
     {
-      d_print_array_type (dpi, mods->mod, mods->next);
+      d_print_array_type (dpi, mods->mod, mods->next, options);
       dpi->templates = hold_dpt;
       return;
     }
@@ -4452,10 +4449,10 @@  d_print_mod_list (struct d_print_info *dpi,
 
       hold_modifiers = dpi->modifiers;
       dpi->modifiers = NULL;
-      d_print_comp (dpi, d_left (mods->mod));
+      d_print_comp (dpi, d_left (mods->mod), options);
       dpi->modifiers = hold_modifiers;
 
-      if ((dpi->options & DMGL_JAVA) == 0)
+      if ((options & DMGL_JAVA) == 0)
 	d_append_string (dpi, "::");
       else
 	d_append_char (dpi, '.');
@@ -4475,24 +4472,24 @@  d_print_mod_list (struct d_print_info *dpi,
 	     || dc->type == DEMANGLE_COMPONENT_CONST_THIS)
 	dc = d_left (dc);
 
-      d_print_comp (dpi, dc);
+      d_print_comp (dpi, dc, options);
 
       dpi->templates = hold_dpt;
       return;
     }
 
-  d_print_mod (dpi, mods->mod);
+  d_print_mod (dpi, mods->mod, options);
 
   dpi->templates = hold_dpt;
 
-  d_print_mod_list (dpi, mods->next, suffix);
+  d_print_mod_list (dpi, mods->next, suffix, options);
 }
 
 /* Print a modifier.  */
 
 static void
-d_print_mod (struct d_print_info *dpi,
-             const struct demangle_component *mod)
+d_print_mod (struct d_print_info *dpi, const struct demangle_component *mod,
+	     int options)
 {
   switch (mod->type)
     {
@@ -4510,11 +4507,11 @@  d_print_mod (struct d_print_info *dpi,
       return;
     case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
       d_append_char (dpi, ' ');
-      d_print_comp (dpi, d_right (mod));
+      d_print_comp (dpi, d_right (mod), options);
       return;
     case DEMANGLE_COMPONENT_POINTER:
       /* There is no pointer symbol in Java.  */
-      if ((dpi->options & DMGL_JAVA) == 0)
+      if ((options & DMGL_JAVA) == 0)
 	d_append_char (dpi, '*');
       return;
     case DEMANGLE_COMPONENT_REFERENCE:
@@ -4532,22 +4529,22 @@  d_print_mod (struct d_print_info *dpi,
     case DEMANGLE_COMPONENT_PTRMEM_TYPE:
       if (d_last_char (dpi) != '(')
 	d_append_char (dpi, ' ');
-      d_print_comp (dpi, d_left (mod));
+      d_print_comp (dpi, d_left (mod), options);
       d_append_string (dpi, "::*");
       return;
     case DEMANGLE_COMPONENT_TYPED_NAME:
-      d_print_comp (dpi, d_left (mod));
+      d_print_comp (dpi, d_left (mod), options);
       return;
     case DEMANGLE_COMPONENT_VECTOR_TYPE:
       d_append_string (dpi, " __vector(");
-      d_print_comp (dpi, d_left (mod));
+      d_print_comp (dpi, d_left (mod), options);
       d_append_char (dpi, ')');
       return;
 
     default:
       /* Otherwise, we have something that won't go back on the
 	 modifier stack, so we can just print it.  */
-      d_print_comp (dpi, mod);
+      d_print_comp (dpi, mod, options);
       return;
     }
 }
@@ -4557,7 +4554,7 @@  d_print_mod (struct d_print_info *dpi,
 static void
 d_print_function_type (struct d_print_info *dpi,
                        const struct demangle_component *dc,
-                       struct d_print_mod *mods)
+                       struct d_print_mod *mods, int options)
 {
   int need_paren;
   int need_space;
@@ -4615,7 +4612,7 @@  d_print_function_type (struct d_print_info *dpi,
   hold_modifiers = dpi->modifiers;
   dpi->modifiers = NULL;
 
-  d_print_mod_list (dpi, mods, 0);
+  d_print_mod_list (dpi, mods, 0, options);
 
   if (need_paren)
     d_append_char (dpi, ')');
@@ -4623,11 +4620,11 @@  d_print_function_type (struct d_print_info *dpi,
   d_append_char (dpi, '(');
 
   if (d_right (dc) != NULL)
-    d_print_comp (dpi, d_right (dc));
+    d_print_comp (dpi, d_right (dc), options);
 
   d_append_char (dpi, ')');
 
-  d_print_mod_list (dpi, mods, 1);
+  d_print_mod_list (dpi, mods, 1, options);
 
   dpi->modifiers = hold_modifiers;
 }
@@ -4637,7 +4634,7 @@  d_print_function_type (struct d_print_info *dpi,
 static void
 d_print_array_type (struct d_print_info *dpi,
                     const struct demangle_component *dc,
-                    struct d_print_mod *mods)
+                    struct d_print_mod *mods, int options)
 {
   int need_space;
 
@@ -4669,7 +4666,7 @@  d_print_array_type (struct d_print_info *dpi,
       if (need_paren)
 	d_append_string (dpi, " (");
 
-      d_print_mod_list (dpi, mods, 0);
+      d_print_mod_list (dpi, mods, 0, options);
 
       if (need_paren)
 	d_append_char (dpi, ')');
@@ -4681,7 +4678,7 @@  d_print_array_type (struct d_print_info *dpi,
   d_append_char (dpi, '[');
 
   if (d_left (dc) != NULL)
-    d_print_comp (dpi, d_left (dc));
+    d_print_comp (dpi, d_left (dc), options);
 
   d_append_char (dpi, ']');
 }
@@ -4690,23 +4687,23 @@  d_print_array_type (struct d_print_info *dpi,
 
 static void
 d_print_expr_op (struct d_print_info *dpi,
-                 const struct demangle_component *dc)
+                 const struct demangle_component *dc, int options)
 {
   if (dc->type == DEMANGLE_COMPONENT_OPERATOR)
     d_append_buffer (dpi, dc->u.s_operator.op->name,
 		     dc->u.s_operator.op->len);
   else
-    d_print_comp (dpi, dc);
+    d_print_comp (dpi, dc, options);
 }
 
 /* Print a cast.  */
 
 static void
-d_print_cast (struct d_print_info *dpi,
-              const struct demangle_component *dc)
+d_print_cast (struct d_print_info *dpi, const struct demangle_component *dc,
+	      int options)
 {
   if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE)
-    d_print_comp (dpi, d_left (dc));
+    d_print_comp (dpi, d_left (dc), options);
   else
     {
       struct d_print_mod *hold_dpm;
@@ -4724,14 +4721,14 @@  d_print_cast (struct d_print_info *dpi,
       dpi->templates = &dpt;
       dpt.template_decl = d_left (dc);
 
-      d_print_comp (dpi, d_left (d_left (dc)));
+      d_print_comp (dpi, d_left (d_left (dc)), options);
 
       dpi->templates = dpt.next;
 
       if (d_last_char (dpi) == '<')
 	d_append_char (dpi, ' ');
       d_append_char (dpi, '<');
-      d_print_comp (dpi, d_right (d_left (dc)));
+      d_print_comp (dpi, d_right (d_left (dc)), options);
       /* Avoid generating two consecutive '>' characters, to avoid
 	 the C++ syntactic ambiguity.  */
       if (d_last_char (dpi) == '>')