public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jiufu Guo <guojiufu@linux.ibm.com>
Cc: David Edelsohn <dje.gcc@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH]rs6000: avoid peeking eof after __vector keyword
Date: Tue, 22 Mar 2022 09:25:48 -0500	[thread overview]
Message-ID: <20220322142547.GX614@gate.crashing.org> (raw)
In-Reply-To: <h488rt2a634.fsf@genoa.aus.stglabs.ibm.com>

Hi!

On Tue, Mar 22, 2022 at 01:50:39PM +0800, Jiufu Guo wrote:
> Segher Boessenkool <segher@kernel.crashing.org> writes:
> > On Mon, Mar 21, 2022 at 02:14:08PM -0400, David Edelsohn wrote:
> >> On Mon, Mar 21, 2022 at 5:13 AM Jiufu Guo <guojiufu@linux.ibm.com> wrote:
> >> > There is a rare corner case: where __vector is followed only with ";"
> >> > and near the end of the file.
> >
> >> This is okay. Maybe a tweak to the comment, see below.
> >
> > This whole function could use some restructuring / rewriting to make
> > clearer what it actually does.  See the function comment:
> >
> > /* Called to decide whether a conditional macro should be expanded.
> >    Since we have exactly one such macro (i.e, 'vector'), we do not
> >    need to examine the 'tok' parameter.  */
> >
> > ... followed by 17 uses of "tok".  Yes, some of those overwrite the
> > function argument, but that doesn't make it any better!  :-P
> >
> > Some factoring would help, too, perhaps.
> 
> Thanks for your review!
> 
> I am also confused about it when I check this function for the first
> time. In the function, 'tok' is used directly at the beginning, and
> then it is overwritten by cpp_peek_token.
> >From the history of this function, the first version of this function
> contains this 'inconsistency' between comments and implementations. :-P
> 
> With check related code, it seems this function is used to predicate
> if a conditional macro should be expanded by peeking two or more
> tokens.

Yes, and the function comment should say that, that's what it's for :-)

> The context-sensitive macros are vector/bool/pixel.  Correponding
> keywords __vector/__bool/__pixel are unconditional.
> Based on those related codes, the behavior of function
> rs6000_macro_to_expand would be checking if the 'vector' token is
> followed by bool/__bool or pixel/__pixel.  To do this the 'tok' has to
> be 'examined'.
> 
> >From this understanding, we may just update the comment.
> While the patch does not cover this.

Yes, and it doesn't have to, probably it's best not to change the code
much in stage 4 anyway.  It is really hard to fix bugs in it, or to
review the resulting patches, without documentation what it is supposed
to do (especially if the code isn't clear, is inconsistent, and even
contradicts the little documentation that there is).

Oh well.


Segher

  reply	other threads:[~2022-03-22 14:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  9:13 Jiufu Guo
2022-03-21 18:14 ` David Edelsohn
2022-03-21 18:34   ` Segher Boessenkool
2022-03-22  5:50     ` Jiufu Guo
2022-03-22 14:25       ` Segher Boessenkool [this message]
2022-03-23  3:37         ` Jiufu Guo

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=20220322142547.GX614@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guojiufu@linux.ibm.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).