[PATCH] D28705: [Sema] Fix bug in handling of designated initializer
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 17 11:47:03 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292245: [Sema] Fix bug in handling of designated initializer. (authored by ahatanak).
Changed prior to commit:
https://reviews.llvm.org/D28705?vs=84418&id=84714#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28705
Files:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -2237,6 +2237,10 @@
}
unsigned FieldIndex = 0;
+
+ if (auto *CXXRD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
+ FieldIndex = CXXRD->getNumBases();
+
for (auto *FI : RT->getDecl()->fields()) {
if (FI->isUnnamedBitfield())
continue;
Index: cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp
+++ cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides
+// expected-no-diagnostics
+
+struct B {
+ int x;
+};
+
+struct D : B {
+ int y;
+};
+
+void test() { D d = {1, .y = 2}; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28705.84714.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170117/a5198bd4/attachment.bin>
More information about the cfe-commits
mailing list