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

llvm-svn: 285430

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

index 5ca5d85..6df15b0 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 3528fdc..3c969e2 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, "");