]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: mangling for CTAD placeholder
authorJason Merrill <jason@redhat.com>
Sat, 18 Nov 2023 02:57:52 +0000 (21:57 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 1 Dec 2023 21:08:35 +0000 (16:08 -0500)
Per https://github.com/itanium-cxx-abi/cxx-abi/issues/109 mangle a C++17
CTAD placeholder as its template.

gcc/cp/ChangeLog:

* mangle.cc (write_type): Mangle placeholder as its template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class4.C: Specify ABI v18.
* g++.dg/cpp2a/nontype-class4a.C: New test.

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

index 8a44b11bab693c5e7d9a5f8fb1442c918f338545..0684f0e60380fe6231b581b8ea72d340f60d5a3b 100644 (file)
@@ -2539,6 +2539,16 @@ write_type (tree type)
            case TEMPLATE_TYPE_PARM:
              if (is_auto (type))
                {
+                 if (template_placeholder_p (type)
+                     && abi_check (19))
+                   {
+                     /* ABI #109: placeholder is mangled as its template.  */
+                     type = CLASS_PLACEHOLDER_TEMPLATE (type);
+                     if (find_substitution (type))
+                       return;
+                     write_name (type, 0);
+                     break;
+                   }
                  if (AUTO_IS_DECLTYPE (type))
                    write_identifier ("Dc");
                  else
index 6235fc8f3f529330aee4353e1edb32b4b8c7c26d..5dd4b03e0ed565eb9bdfb95e72107df65620c465 100644 (file)
@@ -1,11 +1,12 @@
 // { dg-do compile { target c++20 } }
+// { dg-additional-options "-fabi-version=18 -fabi-compat-version=18 -Wabi=0" }
 
 template <class T>
 struct A {
   constexpr A(T) {}
   // auto operator<=> (const A&) = default;
 };
-template <A a> void f();
+template <A a> void f();       // { dg-warning "mangled name" }
 
 int main()
 {
diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class4a.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class4a.C
new file mode 100644 (file)
index 0000000..717876d
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile { target c++20 } }
+// { dg-additional-options "-fabi-version=0 -fabi-compat-version=0 -Wabi=18" }
+
+template <class T>
+struct A {
+  constexpr A(T) {}
+  // auto operator<=> (const A&) = default;
+};
+template <A a> void f();       // { dg-warning "mangled name" }
+
+int main()
+{
+  constexpr A a = 1;
+  f<a>();
+  f<1>();
+}
+
+// { dg-final { scan-assembler "_Z1fITn1AXtlS0_IiEEEEvv" } }