================ @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus %s + +#ifdef __ASSERT_FUNCTION +#undef __ASSERT_FUNCTION +#endif +extern "C" void __assert_fail(const char*, const char*, unsigned, const char*); + +#define assert(cond) \ + ((cond) ? (void)0 : __assert_fail(#cond, __FILE__, __LINE__, __func__)) + +consteval int square(int x) { + int result = x * x; + assert(result == 42); // expected-note {{assertion failed in consteval context: 'result == 42'}} ---------------- Fznamznon wrote:
Does the improvement also work for constexpr function, like ``` constexpr int square(int x) { int result = x * x; assert(result == 42); return result; } void test() { constexpr auto val = square(2); } ``` If yes (I would expect it to), should we the note say something like "assertion failed during constexpr evaluation"? https://github.com/llvm/llvm-project/pull/130458 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits