Patchwork RFC: PATCH to add abi_tag attribute

login
register
mail settings
Submitter Jason Merrill
Date Nov. 11, 2012, 2:13 a.m.
Message ID <509F09C2.3010901@redhat.com>
Download mbox | patch
Permalink /patch/198230/
State New
Headers show

Comments

Jason Merrill - Nov. 11, 2012, 2:13 a.m.
The demangler change was handling the tags in the wrong place; I'm 
writing them out with unqualified names, so the demangler should expect 
them in the same place.

Tested x86_64-pc-linux-gnu, applied to trunk.

Patch

commit 75eef303e5494f27a6d9bbef68aaf3200978a8f1
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Nov 10 13:10:24 2012 -0500

    	* cp-demangle.c (d_unqualified_name): Handle abi tags here.
    	(d_name): Not here.

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 86c7747..913d4bf 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1246,17 +1246,14 @@  d_name (struct d_info *di)
   switch (peek)
     {
     case 'N':
-      dc = d_nested_name (di);
-      break;
+      return d_nested_name (di);
 
     case 'Z':
-      dc = d_local_name (di);
-      break;
+      return d_local_name (di);
 
     case 'L':
     case 'U':
-      dc = d_unqualified_name (di);
-      break;
+      return d_unqualified_name (di);
 
     case 'S':
       {
@@ -1298,7 +1295,7 @@  d_name (struct d_info *di)
 			      d_template_args (di));
 	  }
 
-	break;
+	return dc;
       }
 
     default:
@@ -1313,12 +1310,8 @@  d_name (struct d_info *di)
 	  dc = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, dc,
 			    d_template_args (di));
 	}
-      break;
+      return dc;
     }
-
-  if (d_peek_char (di) == 'B')
-    dc = d_abi_tags (di, dc);
-  return dc;
 }
 
 /* <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
@@ -1446,15 +1439,14 @@  d_prefix (struct d_info *di)
 static struct demangle_component *
 d_unqualified_name (struct d_info *di)
 {
+  struct demangle_component *ret;
   char peek;
 
   peek = d_peek_char (di);
   if (IS_DIGIT (peek))
-    return d_source_name (di);
+    ret = d_source_name (di);
   else if (IS_LOWER (peek))
     {
-      struct demangle_component *ret;
-
       ret = d_operator_name (di);
       if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR)
 	{
@@ -1463,14 +1455,11 @@  d_unqualified_name (struct d_info *di)
 	    ret = d_make_comp (di, DEMANGLE_COMPONENT_UNARY, ret,
 			       d_source_name (di));
 	}
-      return ret;
     }
   else if (peek == 'C' || peek == 'D')
-    return d_ctor_dtor_name (di);
+    ret = d_ctor_dtor_name (di);
   else if (peek == 'L')
     {
-      struct demangle_component * ret;
-
       d_advance (di, 1);
 
       ret = d_source_name (di);
@@ -1478,22 +1467,27 @@  d_unqualified_name (struct d_info *di)
 	return NULL;
       if (! d_discriminator (di))
 	return NULL;
-      return ret;
     }
   else if (peek == 'U')
     {
       switch (d_peek_next_char (di))
 	{
 	case 'l':
-	  return d_lambda (di);
+	  ret = d_lambda (di);
+	  break;
 	case 't':
-	  return d_unnamed_type (di);
+	  ret = d_unnamed_type (di);
+	  break;
 	default:
 	  return NULL;
 	}
     }
   else
     return NULL;
+
+  if (d_peek_char (di) == 'B')
+    ret = d_abi_tags (di, ret);
+  return ret;
 }
 
 /* <source-name> ::= <(positive length) number> <identifier>  */
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 6b55d30..5b41b03 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4084,6 +4084,9 @@  auto& f<int>(int const&, int)
 --format=gnu-v3
 _Z1gILi1EEvR1AIXT_EER1BIXscbT_EE
 void g<1>(A<1>&, B<static_cast<bool>(1)>&)
+--format=gnu-v3
+_ZNKSt7complexIiE4realB5cxx11Ev
+std::complex<int>::real[abi:cxx11]() const
 #
 # Ada (GNAT) tests.
 #