public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/64709] [5 Regression] Bogus -Wmissing-field-initializers warning Date: Wed, 21 Jan 2015 14:10:00 -0000 [thread overview] Message-ID: <bug-64709-4-ahXxjvOWCO@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-64709-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64709 --- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- BTW, untested patch (dg.exp passes). diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index f39dfdd..53d1a16 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -7556,20 +7556,28 @@ pop_init_level (location_t loc, int implicit, } } - /* 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; + switch (vec_safe_length (constructor_elements)) + { + case 0: + /* Initialization with { } counts as zeroinit. */ + constructor_zeroinit = 1; + break; + case 1: + /* This might be zeroinit as well. */ + if (integer_zerop ((*constructor_elements)[0].value)) + constructor_zeroinit = 1; + break; + default: + /* If the constructor has more than one element, it can't be { 0 }. */ + constructor_zeroinit = 0; + break; + } /* Warn when some structs are initialized with direct aggregation. */ if (!implicit && found_missing_braces && warn_missing_braces && !constructor_zeroinit) - { - warning_init (loc, OPT_Wmissing_braces, - "missing braces around initializer"); - } + warning_init (loc, OPT_Wmissing_braces, + "missing braces around initializer"); /* Warn when some struct elements are implicitly initialized to zero. */ if (warn_missing_field_initializers
next prev parent reply other threads:[~2015-01-21 14:10 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-64709-4@http.gcc.gnu.org/bugzilla/> 2015-01-21 12:32 ` [Bug c/64709] " mpolacek at gcc dot gnu.org 2015-01-21 12:49 ` [Bug c/64709] [5 Regression] " mpolacek at gcc dot gnu.org 2015-01-21 13:15 ` jakub at gcc dot gnu.org 2015-01-21 13:28 ` mpolacek at gcc dot gnu.org 2015-01-21 14:10 ` mpolacek at gcc dot gnu.org [this message] 2015-01-21 14:15 ` jakub at gcc dot gnu.org 2015-01-29 21:03 ` mpolacek at gcc dot gnu.org 2015-01-29 21:03 ` mpolacek at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-64709-4-ahXxjvOWCO@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).