[clang] 0b262bb - [clang][Interp] Properly reject StmtExprs with Stmt result
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 23 10:47:32 PDT 2024
Author: Timm Bäder
Date: 2024-07-23T19:46:15+02:00
New Revision: 0b262bbb5713ebfdf66f40021711307e9c8d4bf5
URL: https://github.com/llvm/llvm-project/commit/0b262bbb5713ebfdf66f40021711307e9c8d4bf5
DIFF: https://github.com/llvm/llvm-project/commit/0b262bbb5713ebfdf66f40021711307e9c8d4bf5.diff
LOG: [clang][Interp] Properly reject StmtExprs with Stmt result
Added:
Modified:
clang/lib/AST/Interp/Compiler.cpp
clang/test/AST/Interp/literals.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp
index 0fc93c14131e6..dbd2686b17f09 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3194,13 +3194,9 @@ bool Compiler<Emitter>::VisitStmtExpr(const StmtExpr *E) {
}
assert(S == Result);
- if (const Expr *ResultExpr = dyn_cast<Expr>(S)) {
- if (DiscardResult)
- return this->discard(ResultExpr);
+ if (const Expr *ResultExpr = dyn_cast<Expr>(S))
return this->delegate(ResultExpr);
- }
-
- return this->visitStmt(S);
+ return this->emitUnsupported(E);
}
return BS.destroyLocals();
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index 9cd65462a0af3..9c828afdef18b 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -1214,6 +1214,10 @@ namespace StmtExprs {
return 76;
}
static_assert(foo() == 76, "");
+
+ namespace CrossFuncLabelDiff {
+ constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); }
+ }
}
#endif
More information about the cfe-commits
mailing list