[PATCH] D156503: [clang][Interp] Don't assume throw stmts have a subexpr
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 27 22:37:07 PDT 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156503
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/invalid.cpp
Index: clang/test/AST/Interp/invalid.cpp
===================================================================
--- clang/test/AST/Interp/invalid.cpp
+++ clang/test/AST/Interp/invalid.cpp
@@ -23,6 +23,17 @@
// ref-note {{subexpression not valid in a constant expression}}
return 0;
}
+
+ constexpr int NoSubExpr() { // ref-error {{never produces a constant expression}} \
+ // expected-error {{never produces a constant expression}}
+ throw; // ref-note 2{{subexpression not valid}} \
+ // expected-note 2{{subexpression not valid}}
+ return 0;
+ }
+ static_assert(NoSubExpr() == 0, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{in call to}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{in call to}}
}
namespace Asm {
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1363,7 +1363,7 @@
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitCXXThrowExpr(const CXXThrowExpr *E) {
- if (!this->discard(E->getSubExpr()))
+ if (E->getSubExpr() && !this->discard(E->getSubExpr()))
return false;
return this->emitInvalid(E);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156503.545018.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230728/bddd8338/attachment-0001.bin>
More information about the cfe-commits
mailing list