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) {
|
ExprDependence clang::computeDependence(StmtExpr *E, unsigned TemplateDepth) {
|
||||||
// FIXME: why is unexpanded-pack not propagated?
|
auto D = toExprDependence(E->getType()->getDependence());
|
||||||
auto D = toExprDependence(E->getType()->getDependence()) &
|
// Propagate dependence of the result.
|
||||||
~ExprDependence::UnexpandedPack;
|
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
|
// Note: we treat a statement-expression in a dependent context as always
|
||||||
// being value- and instantiation-dependent. This matches the behavior of
|
// being value- and instantiation-dependent. This matches the behavior of
|
||||||
// lambda-expressions and GCC.
|
// lambda-expressions and GCC.
|
||||||
if (TemplateDepth)
|
if (TemplateDepth)
|
||||||
D |= ExprDependence::ValueInstantiation;
|
D |= ExprDependence::ValueInstantiation;
|
||||||
return D;
|
// A param pack cannot be expanded over stmtexpr boundaries.
|
||||||
|
return D & ~ExprDependence::UnexpandedPack;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprDependence clang::computeDependence(ConvertVectorExpr *E) {
|
ExprDependence clang::computeDependence(ConvertVectorExpr *E) {
|
||||||
|
|
|
@ -14,6 +14,12 @@ struct X2 {
|
||||||
constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
|
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 {
|
struct CycleDelegate {
|
||||||
int Y;
|
int Y;
|
||||||
CycleDelegate(int)
|
CycleDelegate(int)
|
||||||
|
|
Loading…
Reference in New Issue