On 2/26/22 19:55, Roger Sayle wrote:

This is a fix for PR c++/39751 which is an ICE-on-invalid regression in
the C++ parser after encountering the end of file.  The one line change
is to check that the tokens cached in DECL_PENDING_INLINE_INFO haven't
been purged before processing them in cp_parser_late_parsing_for_member.

Alas in addition to the one line fix (and new test case), I've also
taken the opportunity to silence the -Wmissing-field-initializers
warnings compiling this source file, by replacing the " = { };" with
explicit calls to memset to initialize/reset structures.

This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
and make -k check with no new (unexpected) failures.  Ok for mainline?


2022-02-26  Roger Sayle  <ro...@nextmovesoftware.com>

gcc/cp/ChangeLog
        PR c++/39751
        * parser.cc (cp_parser_late_parsing_for_member): Confirm the token
        stream hasn't been purged before processing DECL_PENDING_INLINE.

This is OK.

        (cp_parser_handle_statement_omp_attributes): Silence compilation
        warnings using memset to initialize structure.
        (cp_parser_late_parsing_omp_declare_simd): Likewise.

These are not; I don't want to uglify the code to satisfy a broken warning. The warning is documented to allow this pattern:

     Likewise, in C++ this option does not warn about the empty { }
     initializer, for example:

          struct s { int f, g, h; };
          s x = { };

So all the instances you changed indicate a bug in the warning that should be fixed rather than worked around.

Even if this were OK, it's completely unrelated to PR39751, so should have been a separate patch.

+++ b/gcc/testsuite/g++.dg/pr39751.C

Should go in g++.dg/parse/

+/* { dg-options "-O2" } */

Unneeded.

Jason

Reply via email to