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-Tag: llvmorg-4.0.0-rc1~6009 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b18217992dbd2e42776ba0cfc925d07f6f88f66;p=platform%2Fupstream%2Fllvm.git 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 llvm-svn: 285430 --- diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 5ca5d85..6df15b0 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/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/clang/test/SemaCXX/constexpr-value-init.cpp b/clang/test/SemaCXX/constexpr-value-init.cpp index 3528fdc..3c969e2 100644 --- a/clang/test/SemaCXX/constexpr-value-init.cpp +++ b/clang/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, "");