public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "Richard Henderson" <rth@redhat.com>,
	gcc-patches@gcc.gnu.org, "David Malcolm" <dmalcolm@redhat.com>,
	"Manuel López-Ibáñez" <lopezibanez@gmail.com>,
	"Patrick Palka" <patrick@parcs.ath.cx>,
	"Andreas Krebbel" <krebbel@linux.vnet.ibm.com>,
	"Bernd Schmidt" <bschmidt@redhat.com>
Subject: Re: [PATCH v2] [PR debug/67192] Fix C loops' back-jump location
Date: Thu, 29 Oct 2015 13:16:00 -0000	[thread overview]
Message-ID: <m3twp924tv.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <m3vb9yq73r.fsf@oc1027705133.ibm.com> (Andreas Arnez's message of	"Fri, 23 Oct 2015 11:14:48 +0200")

Ping:

  https://gcc.gnu.org/ml/gcc-patches/2015-10/msg02393.html

On Fri, Oct 23 2015, Andreas Arnez wrote:

> After parsing an unconditional "while"- or "for"-loop, the C front-end
> generates a backward-goto statement and implicitly sets its location to
> the current input_location.  But in some cases the parser peeks ahead
> first, such that input_location already points to the line after the
> loop and the generated backward-goto gets the wrong line number.
>
> One way this can occur is with a loop body consisting of an "if"
> statement, because then the parser peeks for an optional "else" before
> finishing the loop.
>
> Another way occurs since r223098 ("Implement -Wmisleading-indentation"),
> even with a loop body enclosed in braces.  This is because the check for
> misleading indentation always peeks ahead one token as well.
>
> This patch adds a new parameter to c_finish_loop that expclitly
> specifies the location to be used for the loop iteration.  All calls to
> c_finish_loop are adjusted accordingly.
>
> gcc/c/ChangeLog:
>
> 	PR debug/67192
> 	* c-typeck.c (c_finish_loop): Replace implicit use of
> 	input_location by new parameter iter_locus.
> 	* c-tree.h (c_finish_loop): Adjust prototype.
> 	* c-array-notation.c (fix_builtin_array_notation_fn): Explicitly
> 	pass input_location as the new parameter to c_finish_loop.
> 	(build_array_notation_expr): Likewise.
> 	(fix_conditional_array_notations_1): Likewise.
> 	(fix_array_notation_expr): Likewise.
> 	(fix_array_notation_call_expr): Likewise.
> 	* c-parser.c (c_parser_while_statement): Choose iter_locus
> 	depending on whether the loop body is enclosed in braces, and pass
> 	it to c_finish_loop.
> 	(c_parser_for_statement): Likewise.
> 	(c_parser_do_statement): Use the final semicolon's location for
> 	iter_locus and pass it to c_finish_loop.
>
> gcc/testsuite/ChangeLog:
>
> 	PR debug/67192
> 	* gcc.dg/guality/pr67192.c: New test.

  reply	other threads:[~2015-10-29 13:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  9:15 Andreas Arnez
2015-10-29 13:16 ` Andreas Arnez [this message]
2015-10-29 14:24 ` Bernd Schmidt
2015-10-29 19:20   ` Andreas Arnez
2015-11-04 14:53     ` Andreas Arnez

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=m3twp924tv.fsf@oc1027705133.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=bschmidt@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=krebbel@linux.vnet.ibm.com \
    --cc=lopezibanez@gmail.com \
    --cc=patrick@parcs.ath.cx \
    --cc=rth@redhat.com \
    /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).