]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: mangling template-id of unknown template [PR110524]
authorPatrick Palka <ppalka@redhat.com>
Sat, 15 Jul 2023 13:47:36 +0000 (09:47 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 15 Jul 2023 13:47:36 +0000 (09:47 -0400)
This fixes a crash when mangling an ADL-enabled call to a template-id
naming an unknown template (as per P0846R0).

PR c++/110524

gcc/cp/ChangeLog:

* mangle.cc (write_expression): Handle TEMPLATE_ID_EXPR
whose template is already an IDENTIFIER_NODE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/fn-template26.C: New test.

gcc/cp/mangle.cc
gcc/testsuite/g++.dg/cpp2a/fn-template26.C [new file with mode: 0644]

index 7dab4e62bc9ee983e6a36b0b488b435855d9a6c9..bef0fda6d2291e4ca40b141b721012798a8aff6e 100644 (file)
@@ -3312,7 +3312,8 @@ write_expression (tree expr)
   else if (TREE_CODE (expr) == TEMPLATE_ID_EXPR)
     {
       tree fn = TREE_OPERAND (expr, 0);
-      fn = OVL_NAME (fn);
+      if (!identifier_p (fn))
+       fn = OVL_NAME (fn);
       if (IDENTIFIER_ANY_OP_P (fn))
        write_string ("on");
       write_unqualified_id (fn);
diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template26.C b/gcc/testsuite/g++.dg/cpp2a/fn-template26.C
new file mode 100644 (file)
index 0000000..d4a17eb
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/110524
+// { dg-do compile { target c++20 } }
+
+template<class T>
+auto f(T t) -> decltype(g<T>(t));
+
+namespace N {
+  struct A { };
+  template<class T> void g(T);
+};
+
+int main() {
+  f(N::A{});
+}
+
+// { dg-final { scan-assembler "_Z1fIN1N1AEEDTcl1gIT_Efp_EES2_" } }