[PATCH] D25974: Fix implementation of the likely resolution of core issue 253 to support class based arrays.
Ian Tessier via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 25 18:25:10 PDT 2016
itessier created this revision.
itessier added a subscriber: cfe-commits.
https://reviews.llvm.org/D16552 implemented the likely resolution of core issue 253, but didn't include support for class based array fields. E.g.:
struct A {
}
struct B {
A a[2];
}
const B b; // Fails, but should pass.
https://reviews.llvm.org/D25974
Files:
lib/AST/DeclCXX.cpp
test/SemaCXX/constexpr-value-init.cpp
Index: test/SemaCXX/constexpr-value-init.cpp
===================================================================
--- test/SemaCXX/constexpr-value-init.cpp
+++ test/SemaCXX/constexpr-value-init.cpp
@@ -35,3 +35,12 @@
constexpr Z() : V() {}
};
constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
+
+struct E {
+ A a[2];
+};
+constexpr E e; // ok
+static_assert(e.a[0].a == 1, "");
+static_assert(e.a[0].b == 2, "");
+static_assert(e.a[1].a == 1, "");
+static_assert(e.a[1].b == 2, "");
Index: lib/AST/DeclCXX.cpp
===================================================================
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -739,7 +739,7 @@
}
if (!Field->hasInClassInitializer() && !Field->isMutable()) {
- if (CXXRecordDecl *FieldType = Field->getType()->getAsCXXRecordDecl()) {
+ if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
data().HasUninitializedFields = true;
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25974.75821.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161026/092dbbc0/attachment.bin>
More information about the cfe-commits
mailing list