https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/165002
>From 8a8363afd0c19eec69db3d6f8e4207862a360b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 24 Oct 2025 17:38:16 +0200 Subject: [PATCH] [clang][bytecode] Don't diagnose defined functions that will have a body But don't have one, yet. That happens for class methods, which are "defined" but have no body, hence they willHaveBody. Fixes https://github.com/llvm/llvm-project/issues/164995 --- clang/lib/AST/ByteCode/Interp.cpp | 8 +++++--- clang/test/AST/ByteCode/records.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index a72282caf5e73..4a765db010c6b 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -994,10 +994,12 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) { S.checkingPotentialConstantExpression()) return false; - // If the declaration is defined, declared 'constexpr' _and_ has a body, - // the below diagnostic doesn't add anything useful. + // If the declaration is defined, declared 'constexpr' _and_ + // has (or will have) a body, the below diagnostic doesn't add anything + // useful. if (DiagDecl->isDefined() && DiagDecl->isConstexpr() && - DiagDecl->hasBody()) + (DiagDecl->doesThisDeclarationHaveABody() || + DiagDecl->willHaveBody())) return false; S.FFDiag(S.Current->getLocation(OpPC), diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index 00218ba02bb31..02dd26fa15394 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1861,3 +1861,12 @@ namespace PrimitiveInitializedByInitList { } c{ 17 }; static_assert(c.b == 17, ""); } + +namespace MethodWillHaveBody { + class A { + public: + static constexpr int get_value2() { return 1 + get_value(); } + static constexpr int get_value() { return 1; } + }; + static_assert(A::get_value2() == 2, ""); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
