Skip to content

Commit bdbc434

Browse files
authored
[clang][bytecode] Ignore function calls with depth > 0... (llvm#129887)
... when checking for a potential constant expression. This is also what the current interpreter does.
1 parent e122483 commit bdbc434

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
714714
return false;
715715
}
716716

717+
if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0)
718+
return false;
719+
717720
if (F->isConstexpr() && F->hasBody() &&
718721
(F->getDecl()->isConstexpr() || F->getDecl()->hasAttr<MSConstexprAttr>()))
719722
return true;

clang/test/AST/ByteCode/functions.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,16 @@ namespace StableAddress {
681681
static_assert(sum<str{"$hello $world."}>() == 1234, "");
682682
}
683683
#endif
684+
685+
namespace NoDiags {
686+
void huh();
687+
template <unsigned>
688+
constexpr void hd_fun() {
689+
huh();
690+
}
691+
692+
constexpr bool foo() {
693+
hd_fun<1>();
694+
return true;
695+
}
696+
}

0 commit comments

Comments
 (0)