From ea306a14f41811ba528f3c85ff8ec7a3b5afb8d2 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 25 Mar 2013 23:28:23 +0000 Subject: [PATCH] Don't crash when attempting to redundantly initialize a member of an anonymous union. llvm-svn: 177941 --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- clang/test/SemaCXX/class-base-member-init.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 52ed28afb937..cc0aadeec29f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3436,7 +3436,7 @@ bool CheckRedundantInit(Sema &S, return false; } - if (FieldDecl *Field = Init->getMember()) + if (FieldDecl *Field = Init->getAnyMember()) S.Diag(Init->getSourceLocation(), diag::err_multiple_mem_initialization) << Field->getDeclName() diff --git a/clang/test/SemaCXX/class-base-member-init.cpp b/clang/test/SemaCXX/class-base-member-init.cpp index e84e57b7471b..2cdca829ffb9 100644 --- a/clang/test/SemaCXX/class-base-member-init.cpp +++ b/clang/test/SemaCXX/class-base-member-init.cpp @@ -90,3 +90,11 @@ namespace test5 { } }; } + +namespace rdar13185264 { + class X { + X() : a(), // expected-note{{previous initialization is here}} + a() { } // expected-error{{multiple initializations given for non-static member 'a'}} + union { void *a; }; + }; +}