]> granicus.if.org Git - clang/commitdiff
Fix implementation of the likely resolution of core issue 253 to support class
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Oct 2016 19:11:18 +0000 (19:11 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Oct 2016 19:11:18 +0000 (19:11 +0000)
based arrays. Patch by Ian Tessier!

Differential Review: https://reviews.llvm.org/D25974

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285430 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/SemaCXX/constexpr-value-init.cpp

index 5ca5d856638421db2ce08d2df61fb999928cf613..6df15b07a509f8fa284cf1ba833274a1a4c94087 100644 (file)
@@ -739,7 +739,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
     }
 
     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 {
index 3528fdcd8816e2e0d0d4c2f5c9c2293bbe949447..3c969e2af49f28df4d53fed44a31a22f0558090b 100644 (file)
@@ -35,3 +35,12 @@ template<typename T> struct Z : T {
   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, "");