[cfe-commits] r106320 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/missing-field-initializers.c

Douglas Gregor dgregor at apple.com
Fri Jun 18 14:43:11 PDT 2010


Author: dgregor
Date: Fri Jun 18 16:43:10 2010
New Revision: 106320

URL: http://llvm.org/viewvc/llvm-project?rev=106320&view=rev
Log:
Don't complain about missing field initializers when the initializer
list is completely empty, from Lasse Kärkkäinen! Fixes PR7413.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/Sema/missing-field-initializers.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=106320&r1=106319&r2=106320&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Jun 18 16:43:10 2010
@@ -1114,7 +1114,7 @@
   }
 
   // Emit warnings for missing struct field initializers.
-  if (CheckForMissingFields && Field != FieldEnd && 
+  if (InitializedSomething && CheckForMissingFields && Field != FieldEnd && 
       !Field->getType()->isIncompleteArrayType() && !DeclType->isUnionType()) {
     // It is possible we have one or more unnamed bitfields remaining.
     // Find first (if any) named field and emit warning.

Modified: cfe/trunk/test/Sema/missing-field-initializers.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/missing-field-initializers.c?rev=106320&r1=106319&r2=106320&view=diff
==============================================================================
--- cfe/trunk/test/Sema/missing-field-initializers.c (original)
+++ cfe/trunk/test/Sema/missing-field-initializers.c Fri Jun 18 16:43:10 2010
@@ -20,6 +20,8 @@
   1
 }; // expected-warning {{missing field 'b' initializer}}
 
+struct Foo bar2[] = { {}, {}, {} };
+
 struct One { int a; int b; };
 struct Two { float c; float d; float e; };
 





More information about the cfe-commits mailing list