public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/aoliva/heads/testme)] final: accept markers at line 0
Date: Fri, 25 Dec 2020 01:45:28 +0000 (GMT)	[thread overview]
Message-ID: <20201225014528.A7DB63858001@sourceware.org> (raw)

https://gcc.gnu.org/g:a2d338747aad26cef0f99cbf8799dbad4fc60e43

commit a2d338747aad26cef0f99cbf8799dbad4fc60e43
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Thu Dec 24 22:43:00 2020 -0300

    final: accept markers at line 0
    
    Back when I introduced debug markers, I seem to have been under the
    impression that location line 0 would only ever occur for unknown and
    builtin locations.
    
    Though line 0 never comes up in normal processing of source files, and
    debug info formats often cannot represent them, I suppose there's no
    need to preemptively discard them during final.
    
    
    for  gcc/ChangeLog
    
            PR debug/97714
            * final.c (notice_source_line): Narrow down the condition to
            skip a line-0 marker.
    
    for  gcc/testsuite/ChangeLog
    
            PR debug/97714
            * gcc.dg/pr97714.c: New.

Diff:
---
 gcc/final.c                          | 11 +++++------
 gcc/testsuite/gcc.dg/debug/pr97714.c | 11 +++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/gcc/final.c b/gcc/final.c
index fc9a05e335f..45f7f39f088 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -3250,12 +3250,11 @@ notice_source_line (rtx_insn *insn, bool *is_stmt)
     {
       location_t loc = NOTE_MARKER_LOCATION (insn);
       expanded_location xloc = expand_location (loc);
-      if (xloc.line == 0)
-	{
-	  gcc_checking_assert (LOCATION_LOCUS (loc) == UNKNOWN_LOCATION
-			       || LOCATION_LOCUS (loc) == BUILTINS_LOCATION);
-	  return false;
-	}
+      if (xloc.line == 0
+	  && (LOCATION_LOCUS (loc) == UNKNOWN_LOCATION
+	      || LOCATION_LOCUS (loc) == BUILTINS_LOCATION))
+	return false;
+
       filename = xloc.file;
       linenum = xloc.line;
       columnnum = xloc.column;
diff --git a/gcc/testsuite/gcc.dg/debug/pr97714.c b/gcc/testsuite/gcc.dg/debug/pr97714.c
new file mode 100644
index 00000000000..dba17831d69
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/pr97714.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -g" } */
+
+void
+function ()
+{
+  if (0)
+    {
+#line 0 "whatever"
+    }
+}


             reply	other threads:[~2020-12-25  1:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-25  1:45 Alexandre Oliva [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-01-01  5:22 Alexandre Oliva
2021-01-01  1:29 Alexandre Oliva
2020-12-18 14:46 Alexandre Oliva

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=20201225014528.A7DB63858001@sourceware.org \
    --to=aoliva@gcc.gnu.org \
    --cc=gcc-cvs@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).