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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits