forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Explicitly) Templated lambdas have a different signature to implicitly templated lambdas -- '[]<template T> (T) {}' is not the same as '[](auto) {}'. This should be reflected in the mangling. The ABI captures this as itanium-cxx-abi/cxx-abi#31, and clang has implemented such additions. It's relatively straight forwards to write out the non-synthetic template parms, and note if we need to issue an ABI warning. gcc/cp/ * mangle.cc (write_closure_template_head): New. (write_closure_type_name): Call it. gcc/testsuite/ * g++.dg/abi/lambda-ctx1-18.C: Adjust. * g++.dg/abi/lambda-ctx1-18vs17.C: Adjust. * g++.dg/abi/lambda-tpl1-17.C: New. * g++.dg/abi/lambda-tpl1-18.C: New. * g++.dg/abi/lambda-tpl1-18vs17.C: New. * g++.dg/abi/lambda-tpl1.h: New.
- Loading branch information
Showing
7 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// { dg-do compile { target c++20 } } | ||
// { dg-options -fabi-version=17 } | ||
|
||
#include "lambda-tpl1.h" | ||
|
||
// { dg-final { scan-assembler {_ZNK6l_autoMUlT_E_clIiEEDaS_:} } } | ||
// { dg-final { scan-assembler {_ZNK5l_tplMUlT_E_clIiEEDaS_:} } } | ||
// { dg-final { scan-assembler {_ZNK10l_tpl_autoMUlT_T0_E_clIiiEEDaS_S0_:} } } | ||
// { dg-final { scan-assembler {_ZNK12l_tpl_nt_aryMUlRAT__iE_clILi2EEEDaS0_:} } } | ||
// { dg-final { scan-assembler {_ZNK13l_tpl_nt_autoMUlvE_clILi0EEEDav:} } } | ||
// { dg-final { scan-assembler {_ZNK9l_tpl_tplMUlR3TPLIT_EE_clI1UEEDaS2_:} } } | ||
// { dg-final { scan-assembler {_ZNK13l_tpl_tpl_tplMUlR6TPLTPLIT_EE_clI3TPLEEDaS2_:} } } | ||
// { dg-final { scan-assembler {_ZNK5l_varMUlDpT_E_clIJiiiEEEDaS0_:} } } | ||
|
||
// This mangling might not be correct, it is my best guess: | ||
// { FIXMEdg-final { scan-assembler {_ZNK6l_var2MUlDpRAT__iE_clIJLi2ELi2EEEEDaS1_:} } } | ||
|
||
// { dg-final { scan-assembler {_ZNK6l_var3MUlRT_IJXspT0_EEEE_clI1XJLi1ELi2ELi3EEEEDaS1_:} } } | ||
// { dg-final { scan-assembler {_ZNK6l_var4MUlR1YIJDpT_EEE_clIJ1US6_EEEDaS3_:} } } | ||
// { dg-final { scan-assembler {_ZZ2FnILi1EEvvENKUlT_E_clIiEEDaS0_:} } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// { dg-do compile { target c++20 } } | ||
|
||
#include "lambda-tpl1.h" | ||
|
||
// { dg-final { scan-assembler {_ZNK6l_autoMUlT_E_clIiEEDaS0_:} } } | ||
// { dg-final { scan-assembler {_ZNK5l_tplMUlTyT_E_clIiEEDaS0_:} } } | ||
// { dg-final { scan-assembler {_ZNK10l_tpl_autoMUlTyT_T0_E_clIiiEEDaS0_S1_:} } } | ||
// { dg-final { scan-assembler {_ZNK12l_tpl_nt_aryMUlTniRAT__iE_clILi2EEEDaS1_:} } } | ||
// { dg-final { scan-assembler {_ZNK13l_tpl_nt_autoMUlTnDavE_clILi0EEEDav:} } } | ||
// { dg-final { scan-assembler {_ZNK9l_tpl_tplMUlTtTyTnjER3TPLIT_EE_clI1UEEDaS3_:} } } | ||
// { dg-final { scan-assembler {_ZNK13l_tpl_tpl_tplMUlTtTtTyTnjEER6TPLTPLIT_EE_clI3TPLEEDaS3_:} } } | ||
// { dg-final { scan-assembler {_ZNK5l_varMUlTpTyDpT_E_clIJiiiEEEDaS1_:} } } | ||
|
||
// { FIXMEdg-final { scan-assembler {_ZNK6l_var2MUlTpTniDpRAT__iE_clIJLi2ELi2EEEEDaS2_:} } } | ||
|
||
// { dg-final { scan-assembler {_ZNK6l_var3MUlTtTpTniETpTniRT_IJXspT0_EEEE_clI1XJLi1ELi2ELi3EEEEDaS2_:} } } | ||
|
||
// { dg-final { scan-assembler {_ZNK6l_var4MUlTpTtTyTnjER1YIJDpT_EEE_clIJ1US7_EEEDaS4_:} } } | ||
// This is a different mangling to clang, which gets | ||
// _ZNK6l_var4MUlTpTtTyTnjER1YIJDpT_EEE_clIJ1US6_EEEDaS3_ | ||
// However, I think that is incorrect -- it doesn't demangle as | ||
// expected (using the llvm demangler). | ||
// https://github.com/llvm/llvm-project/issues/58631 | ||
|
||
// { dg-final { scan-assembler {_ZZ2FnILi1EEvvENKUlTyT_E_clIiEEDaS0_:} } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// { dg-do compile { target c++20 } } | ||
// { dg-options {-fabi-version=18 -Wabi=17} } | ||
|
||
#include "lambda-tpl1.h" | ||
|
||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZZ2FnILi1EEvvENKUlT_E_clIiEEDaS0_'\) and '-fabi-version=18' \('_ZZ2FnILi1EEvvENKUlTyT_E_clIiEEDaS0_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK6l_var4MUlR1YIJDpT_EEE_clIJ1US6_EEEDaS3_'\) and '-fabi-version=18' \('_ZNK6l_var4MUlTpTtTyTnjER1YIJDpT_EEE_clIJ1US7_EEEDaS4_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK6l_var3MUlRT_IJXspT0_EEEE_clI1XJLi1ELi2ELi3EEEEDaS1_'\) and '-fabi-version=18' \('_ZNK6l_var3MUlTtTpTniETpTniRT_IJXspT0_EEEE_clI1XJLi1ELi2ELi3EEEEDaS2_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK5l_varMUlDpT_E_clIJiiiEEEDaS0_'\) and '-fabi-version=18' \('_ZNK5l_varMUlTpTyDpT_E_clIJiiiEEEDaS1_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK13l_tpl_tpl_tplMUlR6TPLTPLIT_EE_clI3TPLEEDaS2_'\) and '-fabi-version=18' \('_ZNK13l_tpl_tpl_tplMUlTtTtTyTnjEER6TPLTPLIT_EE_clI3TPLEEDaS3_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK9l_tpl_tplMUlR3TPLIT_EE_clI1UEEDaS2_'\) and '-fabi-version=18' \('_ZNK9l_tpl_tplMUlTtTyTnjER3TPLIT_EE_clI1UEEDaS3_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK13l_tpl_nt_autoMUlvE_clILi0EEEDav'\) and '-fabi-version=18' \('_ZNK13l_tpl_nt_autoMUlTnDavE_clILi0EEEDav'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK12l_tpl_nt_aryMUlRAT__iE_clILi2EEEDaS0_'\) and '-fabi-version=18' \('_ZNK12l_tpl_nt_aryMUlTniRAT__iE_clILi2EEEDaS1_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK10l_tpl_autoMUlT_T0_E_clIiiEEDaS_S0_'\) and '-fabi-version=18' \('_ZNK10l_tpl_autoMUlTyT_T0_E_clIiiEEDaS0_S1_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK5l_tplMUlT_E_clIiEEDaS_'\) and '-fabi-version=18' \('_ZNK5l_tplMUlTyT_E_clIiEEDaS0_'\) [^\n]*\n} } | ||
// { dg-regexp {[^\n]*lambda-tpl1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK6l_autoMUlT_E_clIiEEDaS_'\) and '-fabi-version=18' \('_ZNK6l_autoMUlT_E_clIiEEDaS0_'\) [^\n]*\n} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
inline auto l_auto = [] (auto) {}; | ||
|
||
inline auto l_tpl = [] <typename T> (T) {}; | ||
|
||
inline auto l_tpl_auto = [] <typename T> (T, auto) {}; | ||
|
||
inline auto l_tpl_nt_ary = [] <int I> (int (&)[I]) {}; | ||
|
||
inline auto l_tpl_nt_auto = [] <auto I = 0> () {}; | ||
|
||
template<typename T, unsigned I> class U; | ||
|
||
template<template<typename, unsigned> typename> class TPL {}; | ||
inline auto l_tpl_tpl = [] <template<typename, unsigned> typename T> (TPL<T> &) {}; | ||
|
||
template<template<template<typename, unsigned> typename> typename> class TPLTPL {}; | ||
inline auto l_tpl_tpl_tpl = []<template<template<typename, unsigned> typename> typename T> (TPLTPL<T> &) {}; | ||
|
||
inline auto l_var = []<typename... Args> (Args...) {}; | ||
|
||
#if FIXME // we fail to parse (&...) correctly | ||
inline auto l_var2 = []<int... I> (int (&...)[I]) {}; | ||
#endif | ||
|
||
template<int...I> class X {}; | ||
inline auto l_var3 = []<template<int...> typename T, int...I> (T<I...> &a) {}; | ||
|
||
template<template<typename, unsigned> typename...T> class Y{}; | ||
inline auto l_var4 = []<template<typename, unsigned> typename... T> (Y<T...> &a) {}; | ||
|
||
template<int I> inline void Fn () | ||
{ | ||
auto l = []<typename T> (T) {}; | ||
l (1); | ||
} | ||
|
||
void f () | ||
{ | ||
l_auto (1); | ||
l_tpl (1); | ||
l_tpl_auto (1, 1); | ||
int ary[2]; | ||
l_tpl_nt_ary (ary); | ||
l_tpl_nt_auto (); | ||
TPL<U> v; | ||
l_tpl_tpl (v); | ||
TPLTPL<TPL> u; | ||
l_tpl_tpl_tpl (u); | ||
l_var (1, 2, 3); | ||
#if FIXME | ||
l_var2 (ary, ary); | ||
#endif | ||
X<1,2,3> x; | ||
l_var3 (x); | ||
Y<U,U> y; | ||
l_var4 (y); | ||
|
||
Fn<1> (); | ||
} |