aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-10-09 08:25:50 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-10-09 08:25:50 +0000
commit84937de246b5aa038ef6cfcec3a20297a690bde0 (patch)
tree81f79418b200e4d8a6f9fe41ab6256b7781ea7ef /gcc/c
parent77ed39034fda4f949fea955bfadbdab36df5d94a (diff)
downloadgcc-84937de246b5aa038ef6cfcec3a20297a690bde0.zip
gcc-84937de246b5aa038ef6cfcec3a20297a690bde0.tar.gz
gcc-84937de246b5aa038ef6cfcec3a20297a690bde0.tar.bz2
re PR c/63480 (-Wmissing-field-initializers should not warn about intentionally empty initializers (or that should be a separate option))
PR c/63480 * c-typeck.c (pop_init_level): Don't warn about initializing with { }. * gcc.dg/pr63480.c: New test. From-SVN: r216031
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 3a09125..91ed9d2 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-09 Marek Polacek <polacek@redhat.com>
+
+ PR c/63480
+ * c-typeck.c (pop_init_level): Don't warn about initializing
+ with { }.
+
2014-10-07 Marek Polacek <polacek@redhat.com>
PR c/59717
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index b3b82bb..5c0697a 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -7436,7 +7436,11 @@ pop_init_level (location_t loc, int implicit,
}
}
- if (vec_safe_length (constructor_elements) != 1)
+ /* Initialization with { } counts as zeroinit. */
+ if (vec_safe_length (constructor_elements) == 0)
+ constructor_zeroinit = 1;
+ /* If the constructor has more than one element, it can't be { 0 }. */
+ else if (vec_safe_length (constructor_elements) != 1)
constructor_zeroinit = 0;
/* Warn when some structs are initialized with direct aggregation. */
@@ -7463,7 +7467,7 @@ pop_init_level (location_t loc, int implicit,
/* Do not warn if this level of the initializer uses member
designators; it is likely to be deliberate. */
&& !constructor_designated
- /* Do not warn about initializing with ` = {0}'. */
+ /* Do not warn about initializing with { 0 } or with { }. */
&& !constructor_zeroinit)
{
if (warning_at (input_location, OPT_Wmissing_field_initializers,