From: Richard Smith Date: Fri, 28 Oct 2016 19:11:18 +0000 (+0000) Subject: Fix implementation of the likely resolution of core issue 253 to support class X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c29c0303fda1f619ff27df21e21212a09e539ec6;p=clang Fix implementation of the likely resolution of core issue 253 to support class 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 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 5ca5d85663..6df15b07a5 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -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 { diff --git a/test/SemaCXX/constexpr-value-init.cpp b/test/SemaCXX/constexpr-value-init.cpp index 3528fdcd88..3c969e2af4 100644 --- a/test/SemaCXX/constexpr-value-init.cpp +++ b/test/SemaCXX/constexpr-value-init.cpp @@ -35,3 +35,12 @@ template struct Z : T { constexpr Z() : V() {} }; constexpr int n = Z().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, "");