Patchwork PATCH COMMITTED: Fix PR 46332: no extra parens for function types

login
register
mail settings
Submitter Ian Taylor
Date Nov. 13, 2010, 1:21 a.m.
Message ID <mcry68yhvcj.fsf@google.com>
Download mbox | patch
Permalink /patch/71035/
State New
Headers show

Comments

Ian Taylor - Nov. 13, 2010, 1:21 a.m.
PR 46332 points out that the demangler currently print extra parentheses
for function types.  Note that function types are a relatively unusual
case for the demangler; pointer to function types are more common.  This
patch fixes the demangler for this case, and adjusts one libstdc++ test
case accordingly.

Bootstrapped on x86_64-unknown-linux-gnu.  Ran the g++ and libstdc++
testsuites.  Committed to mainline.

Ian


libiberty/:

2010-11-12  Ian Lance Taylor  <iant@google.com>                                 
                                                                                
	PR other/46332								
	* cp-demangle.c (d_print_function_type): Don't print parentheses
	if there are no modifiers to print.
	* testsuite/demangle-expected: Tweak one test case, add another.

libstdc++/:

2010-11-12  Ian Lance Taylor  <iant@google.com>

        PR other/46332
        * testsuite/abi/demangle/abi_examples/14.cc (main): Change
        expected demangling.

Patch

Index: libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc
===================================================================
--- libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc	(revision 166684)
+++ libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc	(working copy)
@@ -33,7 +33,7 @@  int main()
     template void foo<int, fun, int>();
   */
   //demangle("_Z3fooIiPFidEiEvv", "void foo<int, int (*)(double), int>(void)");
-  verify_demangle("_Z3fooIiFvdEiEvv", "void foo<int, void ()(double), int>()");
+  verify_demangle("_Z3fooIiFvdEiEvv", "void foo<int, void (double), int>()");
 
   return 0;
 }
Index: libiberty/testsuite/demangle-expected
===================================================================
--- libiberty/testsuite/demangle-expected	(revision 166684)
+++ libiberty/testsuite/demangle-expected	(working copy)
@@ -3325,8 +3325,13 @@  first<Duo>
 #
 --format=gnu-v3 --no-params
 _Z3fooIiFvdEiEvv
-void foo<int, void ()(double), int>()
-foo<int, void ()(double), int>
+void foo<int, void (double), int>()
+foo<int, void (double), int>
+#
+--format=gnu-v3 --no-params
+_Z1fIFvvEEvv
+void f<void ()>()
+f<void ()>
 #
 --format=gnu-v3 --no-params
 _ZN1N1fE
Index: libiberty/cp-demangle.c
===================================================================
--- libiberty/cp-demangle.c	(revision 166684)
+++ libiberty/cp-demangle.c	(working copy)
@@ -4546,20 +4546,17 @@  d_print_function_type (struct d_print_in
                        struct d_print_mod *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)
 	break;
 
-      saw_mod = 1;
       switch (p->mod->type)
 	{
 	case DEMANGLE_COMPONENT_POINTER:
@@ -4588,9 +4585,6 @@  d_print_function_type (struct d_print_in
 	break;
     }
 
-  if (d_left (dc) != NULL && ! saw_mod)
-    need_paren = 1;
-
   if (need_paren)
     {
       if (! need_space)