[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
Thu Jun 4 05:57:24 PDT 2020
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
We lost errorBit for StmtExpr if a recoveryExpr is the result
expr of a CompoundStmt, which will lead to crashes.
// `-StmtExpr
// `-CompoundStmt
// `-RecoveryExp
({ invalid(); });
Repository:
rG LLVM Github Monorepo
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
@@ -136,6 +136,13 @@
// lambda-expressions and GCC.
if (TemplateDepth)
D |= ExprDependence::ValueInstantiation;
+
+ // Populate dependence bits from the expr that consider to be the result
+ // of the compound statements.
+ if (const auto *CompoundExprResult =
+ dyn_cast_or_null<ValueStmt>(E->getSubStmt()->getStmtExprResult()))
+ if (const Expr *ResultExpr = CompoundExprResult->getExprStmt())
+ D |= ResultExpr->getDependence();
return D;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81154.268444.patch
Type: text/x-patch
Size: 1271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200604/90cccfc8/attachment.bin>
More information about the cfe-commits
mailing list