[PATCH] D28705: [Sema] Fix bug in handling of designated initializer
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 13 18:53:41 PST 2017
ahatanak added a comment.
In https://reviews.llvm.org/D28705#646088, @rnk wrote:
> What happens with virtual bases?
>
> struct B { int x; };
> struct D : virtual B { int y; };
> void test() { D d = {1, .y = 2}; }
A class with virtual base is not considered an aggregate, so it doesn't go through aggregate initialization (and therefore it doesn't enter CheckDesignatedInitializer). Instead, in TryListInitialization, it tries to find a matching constructor of D and fails.
================
Comment at: test/SemaCXX/designated-initializers-base-class.cpp:1
+// RUN: %clang_cc1 %s -std=c++1z -ast-dump | FileCheck %s
+
----------------
rnk wrote:
> This might be less fragile as an IRGen test. Alternatively, this is a good expected-no-diagnostic test:
> void test() { D d = {1, .y = 2}; }
>
> Right now we emit `warning: initializer overrides prior initialization of this subobject`, which is obviously wrong.
good idea.
https://reviews.llvm.org/D28705
More information about the cfe-commits
mailing list