diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index a2090f3e85e08..1107c0c32792f 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -714,6 +714,9 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) { return false; } + if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0) + return false; + if (F->isConstexpr() && F->hasBody() && (F->getDecl()->isConstexpr() || F->getDecl()->hasAttr())) return true; diff --git a/clang/test/AST/ByteCode/functions.cpp b/clang/test/AST/ByteCode/functions.cpp index a7c8836eac6b8..a767d104b3c8a 100644 --- a/clang/test/AST/ByteCode/functions.cpp +++ b/clang/test/AST/ByteCode/functions.cpp @@ -681,3 +681,16 @@ namespace StableAddress { static_assert(sum() == 1234, ""); } #endif + +namespace NoDiags { + void huh(); + template + constexpr void hd_fun() { + huh(); + } + + constexpr bool foo() { + hd_fun<1>(); + return true; + } +}