From 3c3ccdbe73cb43bdf39a9102f5f7eb842fb71952 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sat, 10 Apr 2010 09:28:51 +0000 Subject: Diagnose more cases of initializing distinct members of an anonymous union member. Use a better diagnostic for this case. Also fix a bug with nested anonymous structs/unions for -Wreorder; this last was PR6575. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100923 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaCXX/class-base-member-init.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/SemaCXX/class-base-member-init.cpp') diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp index 7095d92d68..ca9f045416 100644 --- a/test/SemaCXX/class-base-member-init.cpp +++ b/test/SemaCXX/class-base-member-init.cpp @@ -51,3 +51,26 @@ namespace Test3 { t(2) { } // expected-error {{multiple initializations given for non-static member 't'}} }; } + +namespace test4 { + class A { + union { + struct { + int a; + int b; + }; + + int c; + + union { + int d; + int e; + }; + }; + + A(char _) : a(0), b(0) {} + A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}} + A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}} + A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}} + }; +} -- cgit v1.2.1