public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/94029] [9 Regression] gcc crash in coverage.c:655 since r9-4216-g390e529e2b98983d
Date: Tue, 07 Apr 2020 19:03:46 +0000	[thread overview]
Message-ID: <bug-94029-4-rFhCixrbAF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94029-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94029

--- Comment #20 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:827e5af19a214323c70ee5879dc8f14f4f44ad8d

commit r9-8466-g827e5af19a214323c70ee5879dc8f14f4f44ad8d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Mar 19 22:56:20 2020 +0100

    c: Fix up cfun->function_end_locus from the C FE [PR94029]

    On the following testcase we ICE because while
          DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus
            = c_parser_peek_token (parser)->location;
    and similarly DECL_SOURCE_LOCATION (fndecl) is set from some token's
    location, the end is set as:
      /* Store the end of the function, so that we get good line number
         info for the epilogue.  */
      cfun->function_end_locus = input_location;
    and the thing is that input_location is only very rarely set in the C FE
    (the primary spot that changes it is the cb_line_change/fe_file_change).
    Which means, e.g. for pretty much all C functions that are on a single
line,
    function_start_locus column is > than function_end_locus column, and the
    testcase even has smaller line in function_end_locus because cb_line_change
    isn't performed while parsing multi-line arguments of a function-like
macro.

    Attached are two possible fixes to achieve what the C++ FE does, in
    particular that cfun->function_end_locus is the locus of the closing } of
    the function.  The first one updates input_location when we see a closing }
    of a compound statement (though any, not just the function body) and thus
    input_location in the finish_function call is what we need.
    The second instead propagates the location_t from the parsing of the
    outermost compound statement (the function body) to finish_function.
    The second one is this version.

    2020-03-19  Jakub Jelinek  <jakub@redhat.com>

            PR gcov-profile/94029
            * c-tree.h (finish_function): Add location_t argument defaulted to
            input_location.
            * c-parser.c (c_parser_compound_statement): Add endlocp argument
and
            set it to the locus of closing } if non-NULL.
            (c_parser_compound_statement_nostart): Return locus of closing }.
            (c_parser_parse_rtl_body): Likewise.
            (c_parser_declaration_or_fndef): Propagate locus of closing } to
            finish_function.
            * c-decl.c (finish_function): Add end_loc argument, use it instead
of
            input_location to set function_end_locus.

            * gcc.misc-tests/gcov-pr94029.c: New test.

  parent reply	other threads:[~2020-04-07 19:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-94029-4@http.gcc.gnu.org/bugzilla/>
2020-03-12 11:58 ` [Bug gcov-profile/94029] [9/10 " jakub at gcc dot gnu.org
2020-03-17 16:23 ` marxin at gcc dot gnu.org
2020-03-17 16:43 ` marxin at gcc dot gnu.org
2020-03-18 12:40 ` jakub at gcc dot gnu.org
2020-03-18 12:51 ` marxin at gcc dot gnu.org
2020-03-18 13:04 ` jakub at gcc dot gnu.org
2020-03-19 21:57 ` cvs-commit at gcc dot gnu.org
2020-03-19 21:58 ` [Bug gcov-profile/94029] [9 " jakub at gcc dot gnu.org
2020-03-22  4:57 ` sandra at gcc dot gnu.org
2020-03-22  5:24 ` bernd.edlinger at hotmail dot de
2020-03-23 18:46 ` cvs-commit at gcc dot gnu.org
2020-03-24 22:29 ` sandra at gcc dot gnu.org
2020-03-25  0:00 ` bernd.edlinger at hotmail dot de
2020-04-07 19:03 ` cvs-commit at gcc dot gnu.org [this message]
2020-04-07 19:03 ` cvs-commit at gcc dot gnu.org
2020-04-07 20:00 ` jakub 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-94029-4-rFhCixrbAF@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: link
Be 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).