/* Change flag_abi_version to be the actual current ABI level, for the
benefit of c_cpp_builtins, and to make comparison simpler. */
- const int latest_abi_version = 17;
+ const int latest_abi_version = 18;
/* Generate compatibility aliases for ABI v13 (8.2) by default. */
const int abi_compat_default = 13;
; member initializers in C++14 and up.
; Default in G++ 12.
;
+; 18: Corrects errors in mangling of lambdas with additional context.
+; Default in G++ 13.
+;
; Additional positive integers will be assigned as new versions of
; the ABI become the default version of the ABI.
fabi-version=
{
/* <data-member-prefix> := <member source-name> M */
write_char ('M');
- return;
+
+ /* Before ABI 18, we did not count these as substitution
+ candidates. This leads to incorrect demanglings (and
+ ABI divergence to other compilers). */
+ if (abi_warn_or_compat_version_crosses (18))
+ G.need_abi_warning = true;
+ if (!abi_version_at_least (18))
+ return;
}
}
that inherit from aggregate classes with default member initializers
in C++14 and up.
+Version 18, which first appeard in G++ 13, fixes manglings of lambdas
+that have additional context.
+
See also @option{-Wabi}.
@item -fabi-compat-version=@var{n}
--- /dev/null
+// { dg-do compile { target c++20 } }
+// { dg-options -fabi-version=17 }
+
+#include "lambda-ctx1.h"
+
+// These demangle incorrectly, due to a missed substitution candidate
+// { dg-final { scan-assembler {_ZNK1C1fMUlT_E_clIMS_iEEDaS0_:} } }
+// { dg-final { scan-assembler {_ZNK2L2MUlT_T0_E_clIifEEvS_S0_:} } }
+// { dg-final { scan-assembler {_ZNK1B2L3MUlT_T0_E_clIjdEEvS0_S1_:} } }
+// { dg-final { scan-assembler {_Z3fooIN1qMUlvE_EN1qMUlvE0_EEiOT_OT0_:} } }
--- /dev/null
+// { dg-do compile { target c++20 } }
+// { dg-options -fabi-version=18 }
+
+#include "lambda-ctx1.h"
+
+// These correctly include the lambda's extra context as a
+// substitution candidate, and thus demangle as expected
+// { dg-final { scan-assembler {_ZNK1C1fMUlT_E_clIMS_iEEDaS1_:} } }
+// { dg-final { scan-assembler {_ZNK2L2MUlT_T0_E_clIifEEvS0_S1_:} } }
+// { dg-final { scan-assembler {_ZNK1B2L3MUlT_T0_E_clIjdEEvS1_S2_:} } }
+// { dg-final { scan-assembler {_Z3fooIN1qMUlvE_ENS0_UlvE0_EEiOT_OT0_:} } }
--- /dev/null
+// { dg-do compile { target c++20 } }
+// { dg-options {-fabi-version=18 -Wabi=17} }
+
+#include "lambda-ctx1.h"
+
+// { dg-regexp {[^\n]*lambda-ctx1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK1B2L3MUlT_T0_E_clIjdEEvS0_S1_'\) and '-fabi-version=18' \('_ZNK1B2L3MUlT_T0_E_clIjdEEvS1_S2_'\) [^\n]*\n} }
+// { dg-regexp {[^\n]*lambda-ctx1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK2L2MUlT_T0_E_clIifEEvS_S0_'\) and '-fabi-version=18' \('_ZNK2L2MUlT_T0_E_clIifEEvS0_S1_'\) [^\n]*\n} }
+// { dg-regexp {[^\n]*lambda-ctx1.h:[:0-9]* warning: the mangled name [^\n]* \('_ZNK1C1fMUlT_E_clIMS_iEEDaS0_'\) and '-fabi-version=18' \('_ZNK1C1fMUlT_E_clIMS_iEEDaS1_'\) [^\n]*\n} }
+// { dg-regexp {[^\n]*lambda-ctx1.h:[:0-9]* warning: the mangled name [^\n]* \('_Z3fooIN1qMUlvE_EN1qMUlvE0_EEiOT_OT0_'\) and '-fabi-version=18' \('_Z3fooIN1qMUlvE_ENS0_UlvE0_EEiOT_OT0_'\) [^\n]*\n} }
--- /dev/null
+inline auto L2 = [] <typename T, typename U> (T, U) -> void {};
+namespace B
+{
+ inline auto L3 = [] <typename T, typename U> (T, U) -> void {};
+}
+
+struct C
+{
+ int f = [] (auto){ return 1;}(&C::f);
+ C ();
+};
+
+C::C ()
+{
+ L2 (1, 1.2f);
+ B::L3 (1u, 1.2);
+}
+
+template <typename A, typename B> int foo (A&&, B&&) {return 0;}
+inline int q = foo ([](){}, [](){});
inline int ivar = ifoo (capture ([]{}));
-// { dg-final { scan-assembler {_?_Z7captureINL4svarMUlvE_EE7WrapperIT_EOS2_:} } }
-// { dg-final { scan-assembler {_?_Z7captureIN4gvarMUlvE_EE7WrapperIT_EOS2_:} } }
-// { dg-final { scan-assembler {_?_Z7captureIN4ivarMUlvE_EE7WrapperIT_EOS2_:} } }
+// These manglings change between ABIs 17 and 18 (the final
+// substitution number).
+// { dg-final { scan-assembler {_?_Z7captureINL4svarMUlvE_EE7WrapperIT_EOS3_:} } }
+// { dg-final { scan-assembler {_?_Z7captureIN4gvarMUlvE_EE7WrapperIT_EOS3_:} } }
+// { dg-final { scan-assembler {_?_Z7captureIN4ivarMUlvE_EE7WrapperIT_EOS3_:} } }
// Calls to the foos are emitted.
// { dg-final { scan-assembler {call[ \t]*_?_Z4sfooI7WrapperINL4svarMUlvE_EEEiT_} { target { i?86-*-* x86_64-*-* } } } }
// This testcase will need to be kept in sync with c_common_post_options.
// { dg-options "-fabi-version=0" }
-#if __GXX_ABI_VERSION != 1017
+#if __GXX_ABI_VERSION != 1018
#error "Incorrect value of __GXX_ABI_VERSION"
#endif