From e9c9d15ef9429257136564c5bab76dbe286e37c7 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 30 Jun 2010 00:54:29 +0000 Subject: Fix PR7402: We were creating implicit member initializers for every field in an anonymous union under the presumption that they didn't do anything. While this is true, our checks for redundant initialization of an anonymous union still fire when these overlap with explicit user initialization. A cleaner approach is to avoid initializing multiple members of a union altogether, but this still is in a rather fuzzy are especially when C++0x allows non-POD types into unions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107235 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaCXX/constructor-initializer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/SemaCXX/constructor-initializer.cpp') diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index 8e9e133d94..bf4b289a90 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -204,3 +204,20 @@ C f(C c) { } } + +// Don't build implicit initializers for anonymous union fields when we already +// have an explicit initializer for another field in the union. +namespace PR7402 { + struct S { + union { + void* ptr_; + struct { int i_; }; + }; + + template S(T) : ptr_(0) { } + }; + + void f() { + MyStruct s(3); + } +} -- cgit v1.2.3-70-g09d2