diff --git a/include/cpp2util.h b/include/cpp2util.h index 43f5d7d6b9..6c4f8b41f1 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -27,7 +27,7 @@ // 2) Entities in namespace cpp2::impl::, and macros // // These should not be used by the program. They form the language -// support library intended to be called only from generated Cpp2 code. +// support library intended to be called only from generated code. // // For example, if a Cpp2 function leaves a local variable // uninitialized, cppfront will generate uses of impl::deferred_init<> @@ -887,6 +887,7 @@ class out { #endif #endif +#define CPP2_UFCS_EMPTY(...) #define CPP2_UFCS_IDENTITY(...) __VA_ARGS__ #define CPP2_UFCS_REMPARENS(...) __VA_ARGS__ @@ -937,7 +938,9 @@ class out { #define CPP2_UFCS_CONSTRAINT_ARG(...) IsViable #endif -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +template struct dependent_false : std::false_type {}; + +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ [LAMBDADEFCAPT]< \ typename Obj, typename... Params \ CPP2_UFCS_IS_NOTHROW_PARAM(MVFWD,QUALID,TEMPKW,__VA_ARGS__) \ @@ -945,22 +948,39 @@ class out { > \ CPP2_LAMBDA_NO_DISCARD (Obj&& obj, Params&& ...params) CPP2_FORCE_INLINE_LAMBDA_CLANG \ noexcept(CPP2_UFCS_IS_NOTHROW_ARG(MVFWD,QUALID,TEMPKW,__VA_ARGS__)) CPP2_FORCE_INLINE_LAMBDA -> decltype(auto) \ - requires CPP2_UFCS_CONSTRAINT_ARG(MVFWD,QUALID,TEMPKW,__VA_ARGS__) { \ - if constexpr (requires{ CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); }) { \ - return CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); \ - } else { \ - return MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); \ + SFINAE( requires CPP2_UFCS_CONSTRAINT_ARG(MVFWD,QUALID,TEMPKW,__VA_ARGS__) ) \ + { \ + if constexpr (requires{ CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); }) { \ + return CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); \ } \ -} - -#define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -#define CPP2_UFCS_MOVE(...) CPP2_UFCS_(&,std::move,(),,__VA_ARGS__) -#define CPP2_UFCS_FORWARD(...) CPP2_UFCS_(&,CPP2_FORWARD,(),,__VA_ARGS__) -#define CPP2_UFCS_TEMPLATE(...) CPP2_UFCS_(&,CPP2_UFCS_IDENTITY,(),template,__VA_ARGS__) -#define CPP2_UFCS_QUALIFIED_TEMPLATE(QUALID,...) CPP2_UFCS_(&,CPP2_UFCS_IDENTITY,QUALID,template,__VA_ARGS__) -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) -#define CPP2_UFCS_TEMPLATE_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),template,__VA_ARGS__) -#define CPP2_UFCS_QUALIFIED_TEMPLATE_NONLOCAL(QUALID,...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,QUALID,template,__VA_ARGS__) + else if constexpr (requires{ MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); }) { \ + return MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); \ + } \ + else if constexpr (requires{ obj.CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); }) { \ + static_assert( cpp2::impl::dependent_false::value, "this function call syntax tries 'obj.func(...)', then 'func(obj,...);' - both failed, but the first would have succeeded if obj were an lvalue - the likely problem is that this is a definite last use of the object (which automatically treats it as an rvalue / move candidate), and the function cannot accept an rvalue" ); \ + CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); \ + MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); \ + } \ + else if constexpr (requires{ MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(obj, CPP2_FORWARD(params)...); }) { \ + static_assert( cpp2::impl::dependent_false::value, "this function call syntax tries 'obj.func(...)', then 'func(obj,...);' - both failed, but the second would have succeeded if obj were an lvalue - the likely problem is that this is a definite last use of the object, (which automatically treats it as an rvalue / move candidate) and the function cannot accept an rvalue" ); \ + CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); \ + MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); \ + } \ + else { \ + static_assert( cpp2::impl::dependent_false::value, "this function call syntax tries 'obj.func(...)', then 'func(obj,...);' - both failed, did you spell the function name correctly?" ); \ + CPP2_FORWARD(obj).CPP2_UFCS_REMPARENS QUALID TEMPKW __VA_ARGS__(CPP2_FORWARD(params)...); \ + MVFWD(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__)(CPP2_FORWARD(obj), CPP2_FORWARD(params)...); \ + } \ + } + +#define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +#define CPP2_UFCS_MOVE(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,std::move,(),,__VA_ARGS__) +#define CPP2_UFCS_FORWARD(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_FORWARD,(),,__VA_ARGS__) +#define CPP2_UFCS_TEMPLATE(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,(),template,__VA_ARGS__) +#define CPP2_UFCS_QUALIFIED_TEMPLATE(QUALID,...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,QUALID,template,__VA_ARGS__) +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +#define CPP2_UFCS_TEMPLATE_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),template,__VA_ARGS__) +#define CPP2_UFCS_QUALIFIED_TEMPLATE_NONLOCAL(QUALID,...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,QUALID,template,__VA_ARGS__) } // impl diff --git a/regression-tests/test-results/clang-12/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/clang-12/mixed-bugfix-for-ufcs-non-local.cpp.output index 04a76d3411..bfae96a7d7 100644 --- a/regression-tests/test-results/clang-12/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/clang-12/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,118 +1,118 @@ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_1> bool inline constexpr v0 = false;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:15:3: error: a lambda expression cannot appear in this context t inline constexpr v1 = t();// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_2> auto g() -> void; ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context auto g([[maybe_unused]] cpp2::impl::in> unnamed_param_1) -> void; ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context [[nodiscard]] auto h() -> t; ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_3> using a = bool;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_4> auto inline constexpr b = false;// Fails on GCC ([GCC109781][]). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:35:13: error: a lambda expression cannot appear in this context using c = t;// Fails on Clang 12 (lambda in unevaluated context) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:37:29: error: a lambda expression cannot appear in this context auto inline constexpr d = t();// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_2> auto g() -> void{}// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context auto g([[maybe_unused]] cpp2::impl::in> unnamed_param_1) -> void{}// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context [[nodiscard]] auto h() -> t { return o; }// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ mixed-bugfix-for-ufcs-non-local.cpp2:41:85: error: lambda expression in an unevaluated operand inline CPP2_CONSTEXPR bool u::c = [](cpp2::impl::in> x) mutable -> auto { return x; }(true);// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ 13 errors generated. diff --git a/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-noexcept.cpp.output b/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-noexcept.cpp.output index ccf7f600a6..f81af5a072 100644 --- a/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-noexcept.cpp.output +++ b/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-noexcept.cpp.output @@ -1,10 +1,10 @@ pure2-bugfix-for-ufcs-noexcept.cpp2:5:26: error: lambda expression in an unevaluated operand static_assert(noexcept(CPP2_UFCS(swap)(t(), t())));// Fails on Clang 12 (lambda in unevaluated context) and GCC 10 (static assertion failed) ^ -../../../include/cpp2util.h:956:59: note: expanded from macro 'CPP2_UFCS' -#define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:976:59: note: expanded from macro 'CPP2_UFCS' +#define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ 1 error generated. diff --git a/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-sfinae.cpp.output b/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-sfinae.cpp.output index 765ae4ecb1..62ed68b0b0 100644 --- a/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-sfinae.cpp.output +++ b/regression-tests/test-results/clang-12/pure2-bugfix-for-ufcs-sfinae.cpp.output @@ -1,19 +1,19 @@ pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand template [[nodiscard]] auto f() -> std::type_identity_t; ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand template [[nodiscard]] auto f() -> std::type_identity_t{}// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:961:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' -#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) - ^ -../../../include/cpp2util.h:940:59: note: expanded from macro 'CPP2_UFCS_' -#define CPP2_UFCS_(LAMBDADEFCAPT,MVFWD,QUALID,TEMPKW,...) \ +../../../include/cpp2util.h:981:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ +../../../include/cpp2util.h:943:66: note: expanded from macro 'CPP2_UFCS_' +#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ + ^ 2 errors generated. diff --git a/regression-tests/test-results/gcc-13/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-13/mixed-bugfix-for-ufcs-non-local.cpp.output index f6a3160867..c8083515c5 100644 --- a/regression-tests/test-results/gcc-13/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-13/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: -../../../include/cpp2util.h:941:1: error: lambda-expression in template parameter type - 941 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:944:1: error: lambda-expression in template parameter type + 944 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:961:59: note: in expansion of macro ‘CPP2_UFCS_’ - 961 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:981:59: note: in expansion of macro ‘CPP2_UFCS_’ + 981 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid -../../../include/cpp2util.h:941:1: error: lambda-expression in template parameter type - 941 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:944:1: error: lambda-expression in template parameter type + 944 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:961:59: note: in expansion of macro ‘CPP2_UFCS_’ - 961 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:981:59: note: in expansion of macro ‘CPP2_UFCS_’ + 981 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid -../../../include/cpp2util.h:941:1: error: lambda-expression in template parameter type - 941 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:944:1: error: lambda-expression in template parameter type + 944 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:961:59: note: in expansion of macro ‘CPP2_UFCS_’ - 961 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:981:59: note: in expansion of macro ‘CPP2_UFCS_’ + 981 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid -../../../include/cpp2util.h:941:1: error: lambda-expression in template parameter type - 941 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:944:1: error: lambda-expression in template parameter type + 944 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:961:59: note: in expansion of macro ‘CPP2_UFCS_’ - 961 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:981:59: note: in expansion of macro ‘CPP2_UFCS_’ + 981 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid -../../../include/cpp2util.h:941:1: error: lambda-expression in template parameter type - 941 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:944:1: error: lambda-expression in template parameter type + 944 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:961:59: note: in expansion of macro ‘CPP2_UFCS_’ - 961 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:981:59: note: in expansion of macro ‘CPP2_UFCS_’ + 981 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid