[PATCH] D81154: [AST][RecoveryExpr] Populate the dependence bits from CompoundStmt result expr to StmtExpr.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 06:32:27 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28ccd09d7003: [AST][RecoveryExpr] Populate the dependence bits from CompoundStmt result expr… (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81154/new/
https://reviews.llvm.org/D81154
Files:
clang/lib/AST/ComputeDependence.cpp
clang/test/SemaCXX/invalid-constructor-init.cpp
Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===================================================================
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -14,6 +14,12 @@
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)
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -128,15 +128,19 @@
}
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81154.269200.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200608/29f0d893/attachment-0001.bin>
More information about the cfe-commits
mailing list