diff options
author | John McCall <rjmccall@apple.com> | 2010-04-10 09:28:51 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-04-10 09:28:51 +0000 |
commit | 23eebd9c1ee86e29efc84eccca21880993e8ce8e (patch) | |
tree | 5622a80934bdbf354ad46d93eef3778de42c265c /clang/test/SemaCXX/class-base-member-init.cpp | |
parent | bb7b658ab5d0e46a7a5af11bfdba8cac80173307 (diff) | |
download | bcm5719-llvm-23eebd9c1ee86e29efc84eccca21880993e8ce8e.tar.gz bcm5719-llvm-23eebd9c1ee86e29efc84eccca21880993e8ce8e.zip |
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.
llvm-svn: 100923
Diffstat (limited to 'clang/test/SemaCXX/class-base-member-init.cpp')
-rw-r--r-- | clang/test/SemaCXX/class-base-member-init.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/class-base-member-init.cpp b/clang/test/SemaCXX/class-base-member-init.cpp index 7095d92d685..ca9f0454163 100644 --- a/clang/test/SemaCXX/class-base-member-init.cpp +++ b/clang/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}} + }; +} |