[clang] bb95f5d - [clang][Interp] Visit LabelStmt sub statements
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 30 04:44:00 PDT 2024
Author: Timm Bäder
Date: 2024-04-30T13:42:55+02:00
New Revision: bb95f5df732d9188b27c7cd34814ead8b2c4d4ce
URL: https://github.com/llvm/llvm-project/commit/bb95f5df732d9188b27c7cd34814ead8b2c4d4ce
DIFF: https://github.com/llvm/llvm-project/commit/bb95f5df732d9188b27c7cd34814ead8b2c4d4ce.diff
LOG: [clang][Interp] Visit LabelStmt sub statements
Added:
Modified:
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/cxx23.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index ff91baf595f1b1..ff92bc117f9efb 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -292,8 +292,9 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) {
case Stmt::GCCAsmStmtClass:
case Stmt::MSAsmStmtClass:
case Stmt::GotoStmtClass:
- case Stmt::LabelStmtClass:
return this->emitInvalid(S);
+ case Stmt::LabelStmtClass:
+ return this->visitStmt(cast<LabelStmt>(S)->getSubStmt());
default: {
if (auto *Exp = dyn_cast<Expr>(S))
return this->discard(Exp);
diff --git a/clang/test/AST/Interp/cxx23.cpp b/clang/test/AST/Interp/cxx23.cpp
index 13cc9f43febc74..d1ec93e99803e5 100644
--- a/clang/test/AST/Interp/cxx23.cpp
+++ b/clang/test/AST/Interp/cxx23.cpp
@@ -157,3 +157,16 @@ namespace VirtualBases {
D d;
}
}
+
+namespace LabelGoto {
+ constexpr int foo() { // all20-error {{never produces a constant expression}}
+ a: // all20-warning {{use of this statement in a constexpr function is a C++23 extension}}
+ goto a; // all20-note 2{{subexpression not valid in a constant expression}} \
+ // ref23-note {{subexpression not valid in a constant expression}} \
+ // expected23-note {{subexpression not valid in a constant expression}}
+
+ return 1;
+ }
+ static_assert(foo() == 1, ""); // all-error {{not an integral constant expression}} \
+ // all-note {{in call to}}
+}
More information about the cfe-commits
mailing list