Skip to content

Commit ff32dd7

Browse files
committed
[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 #164995
1 parent 750a583 commit ff32dd7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ static bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
997997
// If the declaration is defined, declared 'constexpr' _and_ has a body,
998998
// the below diagnostic doesn't add anything useful.
999999
if (DiagDecl->isDefined() && DiagDecl->isConstexpr() &&
1000-
DiagDecl->hasBody())
1000+
(DiagDecl->hasBody() || DiagDecl->willHaveBody()))
10011001
return false;
10021002

10031003
S.FFDiag(S.Current->getLocation(OpPC),

clang/test/AST/ByteCode/records.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,3 +1861,12 @@ namespace PrimitiveInitializedByInitList {
18611861
} c{ 17 };
18621862
static_assert(c.b == 17, "");
18631863
}
1864+
1865+
namespace MethodWillHaveBody {
1866+
class A {
1867+
public:
1868+
static constexpr int get_value2() { return 1 + get_value(); }
1869+
static constexpr int get_value() { return 1; }
1870+
};
1871+
static_assert(A::get_value2() == 2, "");
1872+
}

0 commit comments

Comments
 (0)