From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id C30D1385840A for ; Wed, 6 Jul 2022 19:41:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C30D1385840A Received: by mail-lj1-x22b.google.com with SMTP id s14so19743504ljs.3 for ; Wed, 06 Jul 2022 12:41:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LpsQ3YxAtb5Cqvb5ECi5plSgnpbzwyh+w4o3HA/Lu40=; b=AKlLkK4vBZCUX1k4ts4li7wMsMZ8q7nH188P9OFyUFwDEDwOfPOKUlXIQQTNpIyzKG J03XdhRHnU7c3dYV9Fz0At6JJsJPxLfHe5OOgAFj0Rp1IT37el353yzF8EvphFLvMajn /3Jsp4sBtr20ZJVsCTMReJhTAOPzfUHR4nDIBklfBE7jYVAbGBFF8BIeVMbl2gtv23k5 /b4u6o8JHZi/1CsVOv3p6hyrnPxFbO4OrC8Nan3XSB8Y3zWxjD34mOcgSmahHZls17eo 6lwCTBhyfmwFs+4eYgwg6I6wshxYxPRsGF1A42h70quVp23oFrQoJ9mQxOkwlrizqNUc ZcxA== X-Gm-Message-State: AJIora/zmv14H/p+NdpmIjjEGJyEJTZHREpjZuWBl/q6VmE9H7v3TRcB mm2NcIZpxai8ImAAKyLO9A9U/m7cOjVnJfDniu4mOtUu X-Google-Smtp-Source: AGRyM1tZu1ytGkURqjC3hoz2S/14j/n+xqElAFCA7fw2m6XxKp57xhpuD2yuC0NImpDwYB3kOL8TSKEN+5aP90nQBEE= X-Received: by 2002:a2e:b892:0:b0:25b:ce73:675f with SMTP id r18-20020a2eb892000000b0025bce73675fmr22878547ljp.67.1657136481199; Wed, 06 Jul 2022 12:41:21 -0700 (PDT) MIME-Version: 1.0 References: <0b17242b-1077-dc34-f7a1-cc93f854d004@redhat.com> <20220706142310.GA36515@ldh-imac.local> In-Reply-To: From: Lewis Hyatt Date: Wed, 6 Jul 2022 15:41:09 -0400 Message-ID: Subject: Re: Ping^2: [PATCH v2] diagnostics: Honor #pragma GCC diagnostic in the preprocessor [PR53431] To: Jason Merrill Cc: gcc-patches List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3029.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 19:41:24 -0000 On Wed, Jul 6, 2022 at 2:17 PM Jason Merrill wrote: >> On 7/6/22 10:23, Lewis Hyatt wrote: > > Here is an updated patch addressing all your comments, thanks again for the > > review. Regarding the idea about rewinding tokens, it seems potentially > > problematic to try to make use of libcpp's backup token feature. I think there > > can be pragmas which allow macro expansion, and then libcpp is not able to > > step back through the expansion AFAIK. It would work fine for `#pragma GCC > > diagnostic' but would break if a similar approach was added for some other > > pragma allowing expansion in the future, and I think potentially also for > > _Pragma. But it seems pretty tenable to handle this case just by providing an > > interface in c-ppoutput.c to ask it to stream a given token that you have > > lexed external to the token streaming process. That's how I set it up here, > > it's much better than my first way IMHO, hopefully it looks OK? > > > > I also attached a diff of this version vs the previous version in case that > > makes it easier to review. The C++ parts were not touched other than adding > > the comment you suggested, the changes in this version are mostly in > > c-ppoutput.cc and c-pragma.cc. > > > > +/* When preprocessing only, pragma_lex() is not available, so obtain the tokens > > + directly from libcpp. We also need to inform the token streamer about all > > + tokens we lex ourselves here, so it outputs them too; this is done by calling > > + c_pp_stream_token () for each. */ > > Let's add to this comment > > ??? If we need to support more pragmas in the future, maybe initialize > this_parser with the pragma tokens and call pragma_lex? > > OK with that change. > Thank you very much, done. -Lewis