public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Gary Funck <gary@intrepid.com>
Cc: Gcc Patches <gcc-patches@gcc.gnu.org>,
	       Nenad Vukicevic <nenad@intrepid.com>,
	Jason Merrill <jason@redhat.com>,
	       Joseph Myers <joseph@codesourcery.com>
Subject: Re: c-family/c-pretty-print.c - fix for 'restrict' quliafiers
Date: Mon, 17 Aug 2015 13:12:00 -0000	[thread overview]
Message-ID: <20150817124612.GG2093@redhat.com> (raw)
In-Reply-To: <20150817100608.GE2093@redhat.com>

On Mon, Aug 17, 2015 at 12:06:08PM +0200, Marek Polacek wrote:
> On Sun, Aug 16, 2015 at 06:14:18PM -0700, Gary Funck wrote:
> > 
> > While reviewing some code, I noticed that the logic for
> > pretty-printing 'restrict' qualifiers is likely missing a
> > statement that sets 'previous'.
> > 
> > OK to commit?
> > 
> > 2015-08-l6  Gary Funck  <gary@intrepid.com>
> > 
> >         * c-pretty-print.c (pp_c_cv_qualifiers):
> >         Set 'previous' for restrict qualifiers.
> > 
> > Index: c-pretty-print.c
> > ===================================================================
> > --- c-pretty-print.c    (revision 226928)
> > +++ c-pretty-print.c    (working copy)
> > @@ -207,16 +207,17 @@ pp_c_cv_qualifiers (c_pretty_printer *pp
> >      }
> >  
> >    if (qualifiers & TYPE_QUAL_RESTRICT)
> >      {
> >        if (previous)
> >          pp_c_whitespace (pp);
> >        pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx ()
> >                            ? "restrict" : "__restrict__"));
> > +      previous = true;
> 
> No, I don't think this assignment is missing here.  The restrict qualifier
> is printed last so we don't need to mark that we've printed something.
> 
> Actually, the whole "previous" flag seems to be redundant; pp_c_ws_string
> calls pp_c_maybe_whitespace so it prints a whitespace if necessary.
> 
> So I suggest the following instead (haven't tested it yet).

Now regtested/bootstrapped on x86_64-linux.  Jason/Joseph, ok?

> 2015-08-17  Marek Polacek  <polacek@redhat.com>
> 
> 	* c-pretty-print.c (pp_c_cv_qualifiers): Remove code dealing
> 	with whitespaces before qualifier names.
> 
> diff --git gcc/c-family/c-pretty-print.c gcc/c-family/c-pretty-print.c
> index 90f8c3d..e2809cf 100644
> --- gcc/c-family/c-pretty-print.c
> +++ gcc/c-family/c-pretty-print.c
> @@ -173,7 +173,6 @@ void
>  pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type)
>  {
>    const char *p = pp_last_position_in_text (pp);
> -  bool previous = false;
>  
>    if (!qualifiers)
>      return;
> @@ -185,34 +184,14 @@ pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type)
>      pp_c_whitespace (pp);
>  
>    if (qualifiers & TYPE_QUAL_ATOMIC)
> -    {
> -      pp_c_ws_string (pp, "_Atomic");
> -      previous = true;
> -    }
> -
> +    pp_c_ws_string (pp, "_Atomic");
>    if (qualifiers & TYPE_QUAL_CONST)
> -    {
> -      if (previous)
> -        pp_c_whitespace (pp);
> -      pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const");
> -      previous = true;
> -    }
> -
> +    pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const");
>    if (qualifiers & TYPE_QUAL_VOLATILE)
> -    {
> -      if (previous)
> -        pp_c_whitespace (pp);
> -      pp_c_ws_string (pp, func_type ? "__attribute__((noreturn))" : "volatile");
> -      previous = true;
> -    }
> -
> +    pp_c_ws_string (pp, func_type ? "__attribute__((noreturn))" : "volatile");
>    if (qualifiers & TYPE_QUAL_RESTRICT)
> -    {
> -      if (previous)
> -        pp_c_whitespace (pp);
> -      pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx ()
> -			   ? "restrict" : "__restrict__"));
> -    }
> +    pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx ()
> +			 ? "restrict" : "__restrict__"));
>  }
>  
>  /* Pretty-print T using the type-cast notation '( type-name )'.  */
> 
> 	Marek

	Marek

  parent reply	other threads:[~2015-08-17 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17  2:35 Gary Funck
2015-08-17 10:49 ` Marek Polacek
2015-08-17 12:46   ` Gary Funck
2015-08-17 13:12   ` Marek Polacek [this message]
2015-08-17 14:14     ` Jason Merrill

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=20150817124612.GG2093@redhat.com \
    --to=polacek@redhat.com \
    --cc=gary@intrepid.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nenad@intrepid.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).