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]

cp-demangle PATCH for user-defined literal operator demangling


The discussion of 52521 also noted that the demangler doesn't support literal operators yet.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit ee622f8167f66b6ae9fff1526688a2dfdd84a8be
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Mar 7 17:50:19 2012 -0500

    	* cp-demangle.c (cplus_demangle_operators): Add li.
    	(d_unqualified_name): Handle it specially.

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 18b84a1..2b3d182 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1419,7 +1419,12 @@ d_unqualified_name (struct d_info *di)
 
       ret = d_operator_name (di);
       if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR)
-	di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2;
+	{
+	  di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2;
+	  if (!strcmp (ret->u.s_operator.op->code, "li"))
+	    ret = d_make_comp (di, DEMANGLE_COMPONENT_UNARY, ret,
+			       d_source_name (di));
+	}
       return ret;
     }
   else if (peek == 'C' || peek == 'D')
@@ -1596,6 +1601,7 @@ const struct demangle_operator_info cplus_demangle_operators[] =
   { "ix", NL ("[]"),        2 },
   { "lS", NL ("<<="),       2 },
   { "le", NL ("<="),        2 },
+  { "li", NL ("operator\"\" "), 1 },
   { "ls", NL ("<<"),        2 },
   { "lt", NL ("<"),         2 },
   { "mI", NL ("-="),        2 },
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 408c4f4..036c481 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4072,6 +4072,9 @@ decltype (g({parm#1}, {})) f1<int>(int)
 --format=gnu-v3
 _Z2f1IiEDTnw_T_ilEES0_
 decltype (new int{}) f1<int>(int)
+--format=gnu-v3
+_Zli2_wPKc
+operator"" _w(char const*)
 #
 # Ada (GNAT) tests.
 #

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