From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1668 invoked by alias); 17 Aug 2015 12:46:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1656 invoked by uid 89); 17 Aug 2015 12:46:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 17 Aug 2015 12:46:19 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BE2CE8E911; Mon, 17 Aug 2015 12:46:18 +0000 (UTC) Received: from redhat.com (ovpn-204-54.brq.redhat.com [10.40.204.54]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7HCkE7j012052 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 17 Aug 2015 08:46:16 -0400 Date: Mon, 17 Aug 2015 13:12:00 -0000 From: Marek Polacek To: Gary Funck Cc: Gcc Patches , Nenad Vukicevic , Jason Merrill , Joseph Myers Subject: Re: c-family/c-pretty-print.c - fix for 'restrict' quliafiers Message-ID: <20150817124612.GG2093@redhat.com> References: <20150817011418.GD9735@intrepid.com> <20150817100608.GE2093@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150817100608.GE2093@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-08/txt/msg00896.txt.bz2 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 > > > > * 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 > > * 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