r285430 - Fix implementation of the likely resolution of core issue 253 to support class
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 28 12:11:18 PDT 2016
Author: rsmith
Date: Fri Oct 28 14:11:18 2016
New Revision: 285430
URL: http://llvm.org/viewvc/llvm-project?rev=285430&view=rev
Log:
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
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=285430&r1=285429&r2=285430&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Oct 28 14:11:18 2016
@@ -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 {
Modified: cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-value-init.cpp?rev=285430&r1=285429&r2=285430&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constexpr-value-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-value-init.cpp Fri Oct 28 14:11:18 2016
@@ -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, "");
More information about the cfe-commits
mailing list