[09/10] Allow function types as template parameters in name canonicalizer

Message ID 20240421-canon-fixes-v1-9-4dc4791d270d@tromey.com
State New
Headers
Series Fix some C++ name canonicalizer problems |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey April 21, 2024, 5 p.m. UTC
  This adds function types as template parameters in the C++ name
canonicalizer.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11907
---
 gdb/cp-name-parser.y | 4 ++++
 gdb/cp-support.c     | 7 -------
 2 files changed, 4 insertions(+), 7 deletions(-)
  

Comments

John Baldwin April 22, 2024, 5:30 p.m. UTC | #1
On 4/21/24 10:00 AM, Tom Tromey wrote:
> This adds function types as template parameters in the C++ name
> canonicalizer.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11907

Approved-By: John Baldwin <jhb@FreeBSD.org>
  

Patch

diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 3c5dea2de1c..e820faa2db9 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -596,6 +596,7 @@  template_arg	:	typespec_2
 		|	'&' '(' start ')'
 			{ $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY, state->make_operator ("&", 1), $3); }
 		|	exp
+		|	function
 		;
 
 function_args	:	typespec_2
@@ -2066,6 +2067,9 @@  canonicalize_tests ()
   should_be_the_same ("x::y::z<0b111>", "x::y::z<0D7>");
 
   should_be_the_same ("x::y::z<0xff'ff>", "x::y::z<65535>");
+
+  should_be_the_same ("something<void ()>", "something<  void()  >");
+  should_be_the_same ("something<void ()>", "something<void (void)>");
 }
 
 #endif
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 4c64e4963e4..74a1b61ed68 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -2186,15 +2186,8 @@  test_cp_remove_params ()
   CHECK_INCOMPL ("A::foo<(anonymous namespace)::B",
 		 "A::foo");
 
-  /* Shouldn't this parse?  Looks like a bug in
-     cp_demangled_name_to_comp.  See PR c++/22411.  */
-#if 0
   CHECK ("A::foo<void(int)>::func(int)",
 	 "A::foo<void(int)>::func");
-#else
-  CHECK_INCOMPL ("A::foo<void(int)>::func(int)",
-		 "A::foo");
-#endif
 
   CHECK_INCOMPL ("A::foo<void(int",
 		 "A::foo");