r177941 - <rdar://problem/13185264> Don't crash when attempting to redundantly initialize a member of an anonymous union.

Douglas Gregor dgregor at apple.com
Mon Mar 25 16:28:23 PDT 2013


Author: dgregor
Date: Mon Mar 25 18:28:23 2013
New Revision: 177941

URL: http://llvm.org/viewvc/llvm-project?rev=177941&view=rev
Log:
<rdar://problem/13185264> Don't crash when attempting to redundantly initialize a member of an anonymous union.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/class-base-member-init.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=177941&r1=177940&r2=177941&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Mar 25 18:28:23 2013
@@ -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()

Modified: cfe/trunk/test/SemaCXX/class-base-member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class-base-member-init.cpp?rev=177941&r1=177940&r2=177941&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/class-base-member-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/class-base-member-init.cpp Mon Mar 25 18:28:23 2013
@@ -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; };
+  };
+}





More information about the cfe-commits mailing list