Skip to content

Commit bb95f5d

Browse files
committed
[clang][Interp] Visit LabelStmt sub statements
1 parent f3ac55f commit bb95f5d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) {
292292
case Stmt::GCCAsmStmtClass:
293293
case Stmt::MSAsmStmtClass:
294294
case Stmt::GotoStmtClass:
295-
case Stmt::LabelStmtClass:
296295
return this->emitInvalid(S);
296+
case Stmt::LabelStmtClass:
297+
return this->visitStmt(cast<LabelStmt>(S)->getSubStmt());
297298
default: {
298299
if (auto *Exp = dyn_cast<Expr>(S))
299300
return this->discard(Exp);

clang/test/AST/Interp/cxx23.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,16 @@ namespace VirtualBases {
157157
D d;
158158
}
159159
}
160+
161+
namespace LabelGoto {
162+
constexpr int foo() { // all20-error {{never produces a constant expression}}
163+
a: // all20-warning {{use of this statement in a constexpr function is a C++23 extension}}
164+
goto a; // all20-note 2{{subexpression not valid in a constant expression}} \
165+
// ref23-note {{subexpression not valid in a constant expression}} \
166+
// expected23-note {{subexpression not valid in a constant expression}}
167+
168+
return 1;
169+
}
170+
static_assert(foo() == 1, ""); // all-error {{not an integral constant expression}} \
171+
// all-note {{in call to}}
172+
}

0 commit comments

Comments
 (0)