public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Bernd Schmidt <bschmidt@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v3 1/2] [PR debug/67192] Fix C loops' back-jump location
Date: Thu, 05 Nov 2015 15:30:00 -0000	[thread overview]
Message-ID: <m3oaf8zcp0.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <563B446E.9060000@redhat.com> (Bernd Schmidt's message of "Thu, 5	Nov 2015 12:58:38 +0100")

On Thu, Nov 05 2015, Bernd Schmidt wrote:

> On 11/05/2015 12:33 PM, Andreas Arnez wrote:
>
>> Thanks again for reviewing.  Are you going to look at patch #2 as well?
>
> Yeah, still thinking about that one.
>
>>> Does C++ have similar issues?
>>
>> Not this particular issue, AFAIK.  But I've just looked at how C++ fares
>> with the enhanced version of pr67192.c from patch #2.  There I see the
>> following:
>>
>>    Breakpoint 2, f4 () at pr67192.cc:54
>>    (gdb) p cnt
>>    $1 = 16
>>
>> I.e., when breaking on "while (1)" the first loop iteration has already
>> executed.  This is because the C++ parser assigns the backward-goto to
>> the 'while' token.  It's the same issue you pointed at with version 2 of
>> my patch.
>>
>> Shall I open a bug for that?
>
> I'd obviously prefer if you'd manage to get the two frontends behave
> identically. The alternative would be to open a bug.

OK, I guess it depends on whether we want to go the route of patch #2.
If so, it seems we can do the same for the C++ parser, like in the patch
below.  Note that I've not tested this very much.

-- >8 --
Subject: [PATCH] C++: Fix location of loop statement

---
 gcc/cp/cp-gimplify.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index e4b50e5..d9bb708 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -266,7 +266,12 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
 	loop = stmt_list;
     }
   else
-    loop = build1_loc (start_locus, LOOP_EXPR, void_type_node, stmt_list);
+    {
+      location_t loc = EXPR_LOCATION (expr_first (body));
+      if (loc == UNKNOWN_LOCATION)
+	loc = start_locus;
+      loop = build1_loc (loc, LOOP_EXPR, void_type_node, stmt_list);
+    }
 
   stmt_list = NULL;
   append_to_statement_list (loop, &stmt_list);
-- 
2.3.0

  reply	other threads:[~2015-11-05 15:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 16:15 [PATCH v3 0/2] " Andreas Arnez
2015-11-04 16:18 ` [PATCH v3 2/2] [PR debug/67192] Further fix " Andreas Arnez
2015-11-07  5:15   ` Jeff Law
2015-11-09 17:59     ` Andreas Arnez
2015-11-09 15:36   ` Andreas Krebbel
2015-11-04 16:18 ` [PATCH v3 1/2] [PR debug/67192] Fix " Andreas Arnez
2015-11-05  9:21   ` Bernd Schmidt
2015-11-05 11:33     ` Andreas Arnez
2015-11-05 11:58       ` Bernd Schmidt
2015-11-05 15:30         ` Andreas Arnez [this message]
2015-11-07  5:13   ` Jeff Law
2015-11-09 15:36   ` Andreas Krebbel

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=m3oaf8zcp0.fsf@oc1027705133.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@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).