libiberty: d-demangle: write distinguishable variadics on demangled symbol

Message ID 20211013155915.180150-1-contact@lsferreira.net
State New
Headers show
Series
  • libiberty: d-demangle: write distinguishable variadics on demangled symbol
Related show

Commit Message

Luís Ferreira Oct. 13, 2021, 3:59 p.m.
Currently _D8demangle4testFYv and _D8demangle4testFXv report the same demangled
symbol and they are not the same. The official demangler reports
"demangle.test(, ...)", which is the distinguishable way to do it.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>


libiberty/ChangeLog:

	* d-demangle.c (dlang_function_args): change Y variadic to always
	  report ", ...".
	* testsuite/d-demangle-expected: change test for Y variadic and add a
	  missing test for X variadic.
---
 libiberty/d-demangle.c                  | 4 +---
 libiberty/testsuite/d-demangle-expected | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.33.0

Patch

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 880f2ec85a4..4ec94316dad 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -690,9 +690,7 @@  dlang_function_args (string *decl, const char *mangled, struct dlang_info *info)
 	  return mangled;
 	case 'Y': /* (variadic T t, ...) style.  */
 	  mangled++;
-	  if (n != 0)
-	    string_append (decl, ", ");
-	  string_append (decl, "...");
+	  string_append (decl, ", ...");
 	  return mangled;
 	case 'Z': /* Normal function.  */
 	  mangled++;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 44a3649c429..ec481d27dbe 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -359,6 +359,10 @@  demangle.test(char, char, ...)
 #
 --format=dlang
 _D8demangle4testFYv
+demangle.test(, ...)
+#
+--format=dlang
+_D8demangle4testFXv
 demangle.test(...)
 #
 --format=dlang