forked from OSchip/llvm-project
[AST][RecoveryExpr] Populate the dependence bits from CompoundStmt result expr to StmtExpr.
Summary: We lost errorBit for StmtExpr if a recoveryExpr is the result expr of a CompoundStmt, which will lead to crashes. ``` // `-StmtExpr // `-CompoundStmt // `-RecoveryExp ({ invalid(); }); ``` Reviewers: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81154
This commit is contained in:
parent
9456bbdd08
commit
28ccd09d70
|
@ -128,15 +128,19 @@ ExprDependence clang::computeDependence(BinaryConditionalOperator *E) {
|
|||
}
|
||||
|
||||
ExprDependence clang::computeDependence(StmtExpr *E, unsigned TemplateDepth) {
|
||||
// FIXME: why is unexpanded-pack not propagated?
|
||||
auto D = toExprDependence(E->getType()->getDependence()) &
|
||||
~ExprDependence::UnexpandedPack;
|
||||
auto D = toExprDependence(E->getType()->getDependence());
|
||||
// Propagate dependence of the result.
|
||||
if (const auto *CompoundExprResult =
|
||||
dyn_cast_or_null<ValueStmt>(E->getSubStmt()->getStmtExprResult()))
|
||||
if (const Expr *ResultExpr = CompoundExprResult->getExprStmt())
|
||||
D |= ResultExpr->getDependence();
|
||||
// Note: we treat a statement-expression in a dependent context as always
|
||||
// being value- and instantiation-dependent. This matches the behavior of
|
||||
// lambda-expressions and GCC.
|
||||
if (TemplateDepth)
|
||||
D |= ExprDependence::ValueInstantiation;
|
||||
return D;
|
||||
// A param pack cannot be expanded over stmtexpr boundaries.
|
||||
return D & ~ExprDependence::UnexpandedPack;
|
||||
}
|
||||
|
||||
ExprDependence clang::computeDependence(ConvertVectorExpr *E) {
|
||||
|
|
|
@ -14,6 +14,12 @@ struct X2 {
|
|||
constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
|
||||
};
|
||||
|
||||
struct X3 {
|
||||
int Y;
|
||||
constexpr X3() // expected-error {{constexpr constructor never produces}}
|
||||
: Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}}
|
||||
};
|
||||
|
||||
struct CycleDelegate {
|
||||
int Y;
|
||||
CycleDelegate(int)
|
||||
|
|
Loading…
Reference in New Issue