From: Jason Merrill Date: Sat, 18 Nov 2023 02:57:52 +0000 (-0500) Subject: c++: mangling for CTAD placeholder X-Git-Tag: basepoints/gcc-15~4074 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37e6c9bd99575752b7122c5d76aa2cf021deb93c;p=thirdparty%2Fgcc.git c++: mangling for CTAD placeholder 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. --- diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index 8a44b11bab69..0684f0e60380 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -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 diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class4.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class4.C index 6235fc8f3f52..5dd4b03e0ed5 100644 --- a/gcc/testsuite/g++.dg/cpp2a/nontype-class4.C +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class4.C @@ -1,11 +1,12 @@ // { dg-do compile { target c++20 } } +// { dg-additional-options "-fabi-version=18 -fabi-compat-version=18 -Wabi=0" } template struct A { constexpr A(T) {} // auto operator<=> (const A&) = default; }; -template void f(); +template 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 index 000000000000..717876d07ed6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class4a.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++20 } } +// { dg-additional-options "-fabi-version=0 -fabi-compat-version=0 -Wabi=18" } + +template +struct A { + constexpr A(T) {} + // auto operator<=> (const A&) = default; +}; +template void f(); // { dg-warning "mangled name" } + +int main() +{ + constexpr A a = 1; + f(); + f<1>(); +} + +// { dg-final { scan-assembler "_Z1fITn1AXtlS0_IiEEEEvv" } }