Skip to content

Commit 8dd6f82

Browse files
committed
Enable fexperimental-new-constant-interpreter tests
1 parent 2ae72b4 commit 8dd6f82

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,6 +5104,16 @@ bool Compiler<Emitter>::visitCompoundStmt(const CompoundStmt *S) {
51045104
return Scope.destroyLocals();
51055105
}
51065106

5107+
template <class Emitter>
5108+
bool Compiler<Emitter>::emitDecompositionVarInit(const DecompositionDecl *DD) {
5109+
for (auto *BD : DD->bindings())
5110+
if (auto *KD = BD->getHoldingVar()) {
5111+
if (!this->visitVarDecl(KD))
5112+
return false;
5113+
}
5114+
return true;
5115+
}
5116+
51075117
template <class Emitter>
51085118
bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
51095119
for (const auto *D : DS->decls()) {
@@ -5118,12 +5128,10 @@ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
51185128
return false;
51195129

51205130
// Register decomposition decl holding vars.
5121-
if (const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
5122-
for (auto *BD : DD->bindings())
5123-
if (auto *KD = BD->getHoldingVar()) {
5124-
if (!this->visitVarDecl(KD))
5125-
return false;
5126-
}
5131+
if (const auto *DD = dyn_cast<DecompositionDecl>(VD);
5132+
DD && !DD->isDecisionVariable()) {
5133+
if (!this->emitDecompositionVarInit(DD))
5134+
return false;
51275135
}
51285136
}
51295137

@@ -5189,6 +5197,12 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
51895197
return false;
51905198
}
51915199

5200+
if (auto *DD =
5201+
dyn_cast_if_present<DecompositionDecl>(IS->getConditionVariable());
5202+
DD && DD->isDecisionVariable())
5203+
if (!this->emitDecompositionVarInit(DD))
5204+
return false;
5205+
51925206
if (const Stmt *Else = IS->getElse()) {
51935207
LabelTy LabelElse = this->getLabel();
51945208
LabelTy LabelEnd = this->getLabel();
@@ -5249,6 +5263,13 @@ bool Compiler<Emitter>::visitWhileStmt(const WhileStmt *S) {
52495263

52505264
if (!this->visitBool(Cond))
52515265
return false;
5266+
5267+
if (auto *DD =
5268+
dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable());
5269+
DD && DD->isDecisionVariable())
5270+
if (!this->emitDecompositionVarInit(DD))
5271+
return false;
5272+
52525273
if (!this->jumpFalse(EndLabel))
52535274
return false;
52545275

@@ -5330,6 +5351,12 @@ bool Compiler<Emitter>::visitForStmt(const ForStmt *S) {
53305351
return false;
53315352
}
53325353

5354+
if (auto *DD =
5355+
dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable());
5356+
DD && DD->isDecisionVariable())
5357+
if (!this->emitDecompositionVarInit(DD))
5358+
return false;
5359+
53335360
if (Body && !this->visitStmt(Body))
53345361
return false;
53355362

@@ -5452,6 +5479,12 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
54525479
if (!this->emitSetLocal(CondT, CondVar, S))
54535480
return false;
54545481

5482+
if (auto *DD =
5483+
dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable());
5484+
DD && DD->isDecisionVariable())
5485+
if (!this->emitDecompositionVarInit(DD))
5486+
return false;
5487+
54555488
CaseMap CaseLabels;
54565489
// Create labels and comparison ops for all case statements.
54575490
for (const SwitchCase *SC = S->getSwitchCaseList(); SC;

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
386386
bool compileUnionAssignmentOperator(const CXXMethodDecl *MD);
387387

388388
bool checkLiteralType(const Expr *E);
389+
bool emitDecompositionVarInit(const DecompositionDecl *DD);
389390

390391
protected:
391392
/// Variable to storage mapping.

clang/test/CodeGen/p0963r3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -std=c++2c -verify -emit-llvm -triple=x86_64-pc-linux-gnu %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -std=c++2c -verify -fsyntax-only -fexperimental-new-constant-interpreter -triple=x86_64-pc-linux-gnu %s
23
// expected-no-diagnostics
34

45
namespace std {

0 commit comments

Comments
 (0)