https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/165002

>From 9cb14470e1fafa52e964822b0777934c163d3538 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   | 2 +-
 clang/test/AST/ByteCode/records.cpp | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index a72282caf5e73..06dcf447cae62 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -997,7 +997,7 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, 
const Function *F) {
       // If the declaration is defined, declared 'constexpr' _and_ has a body,
       // the below diagnostic doesn't add anything useful.
       if (DiagDecl->isDefined() && DiagDecl->isConstexpr() &&
-          DiagDecl->hasBody())
+          DiagDecl->doesThisDeclarationHaveABody())
         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

Reply via email to