[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
Fri Jul 28 03:45:33 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7010a4f14e0b: [clang][Interp] Don't assume throw stmts have a subexpr (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156503/new/
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
@@ -1000,7 +1000,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.545090.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230728/21f8bafb/attachment-0001.bin>
More information about the cfe-commits
mailing list