[PATCH] D87382: [AST] Fix dependence-bits for CXXDefaultInitExpr.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 20 23:47:33 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8f1e5fb39d2: [AST] Fix dependence-bits for CXXDefaultInitExpr. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87382/new/
https://reviews.llvm.org/D87382
Files:
clang/include/clang/AST/ComputeDependence.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/ExprCXX.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
@@ -9,8 +9,7 @@
constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}}
struct X2 {
- int Y = foo(); // expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant expression}}
+ int Y = foo(); // expected-error {{use of undeclared identifier 'foo'}}
constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
};
@@ -27,3 +26,9 @@
// no bogus "delegation cycle" diagnostic
CycleDelegate(float) : CycleDelegate(1) {}
};
+
+struct X4 {
+ int* p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}
Index: clang/lib/AST/ExprCXX.cpp
===================================================================
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -959,7 +959,7 @@
CXXDefaultInitExprBits.Loc = Loc;
assert(Field->hasInClassInitializer());
- setDependence(ExprDependence::None);
+ setDependence(computeDependence(this));
}
CXXTemporary *CXXTemporary::Create(const ASTContext &C,
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -694,6 +694,10 @@
return D;
}
+ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) {
+ return E->getExpr()->getDependence();
+}
+
ExprDependence clang::computeDependence(LambdaExpr *E,
bool ContainsUnexpandedParameterPack) {
auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ComputeDependence.h
===================================================================
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -70,6 +70,7 @@
class OverloadExpr;
class DependentScopeDeclRefExpr;
class CXXConstructExpr;
+class CXXDefaultInitExpr;
class LambdaExpr;
class CXXUnresolvedConstructExpr;
class CXXDependentScopeMemberExpr;
@@ -153,6 +154,7 @@
bool KnownContainsUnexpandedParameterPack);
ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
ExprDependence computeDependence(CXXConstructExpr *E);
+ExprDependence computeDependence(CXXDefaultInitExpr *E);
ExprDependence computeDependence(LambdaExpr *E,
bool ContainsUnexpandedParameterPack);
ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87382.293081.patch
Type: text/x-patch
Size: 2910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200921/365ef191/attachment.bin>
More information about the cfe-commits
mailing list