* c-typeck.c (pop_init_level): Warn about implicit zero initialization
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 1998 22:27:35 +0000 (22:27 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 1998 22:27:35 +0000 (22:27 +0000)
        of struct members.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@20614 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c

index b93e2d1..376f35a 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jun 19 23:22:42 1998  Bruno Haible  <bruno@linuix.mathematik.uni-karlsruhe.de>
+
+       * c-typeck.c (pop_init_level): Warn about implicit zero initialization
+       of struct members.
+
 Fri Jun 19 23:06:33 1998  Jason Merrill  <jason@yorick.cygnus.com>
 
        * varasm.c (assemble_start_function): Add weak_global_object_name.
index ea2fea8..4ccc1a3 100644 (file)
@@ -5619,6 +5619,17 @@ pop_init_level (implicit)
   if (constructor_type != 0)
     size = int_size_in_bytes (constructor_type);
 
+  /* Warn when some struct elements are implicitly initialized to zero.  */
+  if (extra_warnings
+      && constructor_type
+      && TREE_CODE (constructor_type) == RECORD_TYPE
+      && constructor_unfilled_fields)
+    {
+      push_member_name (constructor_unfilled_fields);
+      warning_init ("missing initializer%s", " for `%s'", NULL);
+      RESTORE_SPELLING_DEPTH (constructor_depth);
+    }
+
   /* Now output all pending elements.  */
   output_pending_init_elements (1);