From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 006DB3858CDA for ; Mon, 19 Jun 2023 14:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 006DB3858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2b470330145so22498141fa.3 for ; Mon, 19 Jun 2023 07:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687184441; x=1689776441; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Fu6TO6EGIeaAVBA69g3F37hnFH9vqpy5EaFv+Hd9oAc=; b=byOHvii2TeAiFfYt6kcjgU1MwQnxRChextDMC/kXXub5AWn0nj7aRe3AVpzjPldT4N 1QimopWcHEFS8t10R+eLalXWiFHSQCyzszBKJF2wF33+YH0zCz9JdRnCS0nHeN+xyebj knmjgZxZXpRZJ3SinNAoBxUZASwsZzK+fTHepwNwisT6CUDe30LISqGDWyTYmvD41VaH JPygt+2UHSeqUWnBxUGTDmCRh7JELCn1uddKtLNY8heXdIqxLr2dEjN7K50GGzE4HdA+ 6lVKx3pEfEdhQ8KDDunbfLoHBPsjbe5XP+USGuthTOz5BriOaD4cfKJjKlyrNBxbe9ul +yhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687184441; x=1689776441; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fu6TO6EGIeaAVBA69g3F37hnFH9vqpy5EaFv+Hd9oAc=; b=AcSNJaXyuL1ttq9WA3+tRiTMVqIc1KLCWVTzTME901zBDNxlcYmlkNMiGOhPHAUnvy 9GbzztZ8wXN6IVpELDMo+gludwfLlrKZ4zVZlyAFAs0eWgLgzd8Ti7vC5zza+YH4EQOk jQAKoXbgeqETR2+EORdTQ/2FfZi4eobjRndjvng9Q91woTo7poWOq0Zg+yUGOZiIVZIE vz9AuW2toQOrglPcsSKS7a7WcYLmJntQ73Ydhyn7Oac+xHJrzM5t1iatt+tsODgHLt3V 9s0cZMxFKiqTtT1eOnPPUwH+R8dqShMllyckGumKlXBr6igqjfMu9cYKZ0SurZ0BLQLM URLg== X-Gm-Message-State: AC+VfDx3ZBwEkLQ/AKWlixPRD5SvAjlLJChefxtoBxY3BlZQ2wZPvHvH 8xbPimUoQkB8sSVCcQtUbCESfRHok2b4JZpZ0kY9XEuBD6g= X-Google-Smtp-Source: ACHHUZ44cnEFYIMZGKD2zVdZKo/z6opzc/cc1xYcWB44HLp9agjerwTb9TdG1zWH+q0wmq2H8AYRk8ryQ55rqfIDBx0= X-Received: by 2002:a2e:9bd8:0:b0:2b4:5cad:f240 with SMTP id w24-20020a2e9bd8000000b002b45cadf240mr4895573ljj.6.1687184441044; Mon, 19 Jun 2023 07:20:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Lewis Hyatt Date: Mon, 19 Jun 2023 10:20:29 -0400 Message-ID: Subject: Re: ping: [PATCH] libcpp: Improve location for macro names [PR66290] To: gcc-patches List Cc: Jakub Jelinek , Joseph Myers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3029.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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 List-Id: May I please ping this one? FWIW, it's 10 months old now without any feedba= ck. https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607647.html Most of the changes are just adapting the testsuite to look for the improved diagnostic location. Otherwise it's a handful of lines in libcpp and it just changes this: t.cpp:1: warning: macro "X" is not used [-Wunused-macros] 1 | #define X 1 | to this: t.cpp:1:9: warning: macro "X" is not used [-Wunused-macros] 1 | #define X 1 | ^ which closes out PR66290. Thank you! -Lewis On Thu, Jan 12, 2023 at 6:31=E2=80=AFPM Lewis Hyatt wrot= e: > > https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607647.html > May I please ping this one again? It will enable closing out the PR. Than= ks! > > -Lewis > > On Thu, Dec 1, 2022 at 9:22 AM Lewis Hyatt wrote: > > > > Hello- > > > > https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599397.html > > > > May I please ping this one? Thanks! > > I have also re-attached the rebased patch here. > > > > -Lewis > > > > On Wed, Oct 12, 2022 at 06:37:50PM -0400, Lewis Hyatt wrote: > > > Hello- > > > > > > https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599397.html > > > > > > Since Jeff was kind enough to ack one of my other preprocessor patche= s > > > today, I have become emboldened to ping this one again too :). Would > > > anyone have some time to take a look at it please? Thanks! > > > > > > -Lewis > > > > > > On Thu, Sep 15, 2022 at 6:31 PM Lewis Hyatt wrote: > > > > > > > > Hello- > > > > > > > > https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599397.html > > > > May I please ping this patch? Thank you. > > > > > > > > -Lewis > > > > > > > > On Fri, Aug 5, 2022 at 12:14 PM Lewis Hyatt wrot= e: > > > > > > > > > > > > > > > When libcpp reports diagnostics whose locus is a macro name (such= as for > > > > > -Wunused-macros), it uses the location in the cpp_macro object th= at was > > > > > stored by _cpp_new_macro. This is currently set to pfile->directi= ve_line, > > > > > which contains the line number only and no column information. Th= is patch > > > > > changes the stored location to the src_loc for the token defining= the macro > > > > > name, which includes the location and range information. > > > > > > > > > > libcpp/ChangeLog: > > > > > > > > > > PR c++/66290 > > > > > * macro.cc (_cpp_create_definition): Add location argumen= t. > > > > > * internal.h (_cpp_create_definition): Adjust prototype. > > > > > * directives.cc (do_define): Pass new location argument t= o > > > > > _cpp_create_definition. > > > > > (do_undef): Stop passing inferior location to cpp_warning= _with_line; > > > > > the default from cpp_warning is better. > > > > > (cpp_pop_definition): Pass new location argument to > > > > > _cpp_create_definition. > > > > > * pch.cc (cpp_read_state): Likewise. > > > > > > > > > > gcc/testsuite/ChangeLog: > > > > > > > > > > PR c++/66290 > > > > > * c-c++-common/cpp/macro-ranges.c: New test. > > > > > * c-c++-common/cpp/line-2.c: Adapt to check for column in= formation > > > > > on macro-related libcpp warnings. > > > > > * c-c++-common/cpp/line-3.c: Likewise. > > > > > * c-c++-common/cpp/macro-arg-count-1.c: Likewise. > > > > > * c-c++-common/cpp/pr58844-1.c: Likewise. > > > > > * c-c++-common/cpp/pr58844-2.c: Likewise. > > > > > * c-c++-common/cpp/warning-zero-location.c: Likewise. > > > > > * c-c++-common/pragma-diag-14.c: Likewise. > > > > > * c-c++-common/pragma-diag-15.c: Likewise. > > > > > * g++.dg/modules/macro-2_d.C: Likewise. > > > > > * g++.dg/modules/macro-4_d.C: Likewise. > > > > > * g++.dg/modules/macro-4_e.C: Likewise. > > > > > * g++.dg/spellcheck-macro-ordering.C: Likewise. > > > > > * gcc.dg/builtin-redefine.c: Likewise. > > > > > * gcc.dg/cpp/Wunused.c: Likewise. > > > > > * gcc.dg/cpp/redef2.c: Likewise. > > > > > * gcc.dg/cpp/redef3.c: Likewise. > > > > > * gcc.dg/cpp/redef4.c: Likewise. > > > > > * gcc.dg/cpp/ucnid-11-utf8.c: Likewise. > > > > > * gcc.dg/cpp/ucnid-11.c: Likewise. > > > > > * gcc.dg/cpp/undef2.c: Likewise. > > > > > * gcc.dg/cpp/warn-redefined-2.c: Likewise. > > > > > * gcc.dg/cpp/warn-redefined.c: Likewise. > > > > > * gcc.dg/cpp/warn-unused-macros-2.c: Likewise. > > > > > * gcc.dg/cpp/warn-unused-macros.c: Likewise. > > > > > --- > > > > > > > > > > Notes: > > > > > Hello- > > > > > > > > > > The PR (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66290)= was originally > > > > > about the entirely wrong location for -Wunused-macros in C++ = mode, which > > > > > behavior was fixed by r13-1903, but before closing it out I w= anted to also > > > > > address a second point brought up in the PR comments, namely = that we do not > > > > > include column information when emitting diagnostics for macr= o names, such as > > > > > is done for -Wunused-macros. The attached patch updates the l= ocation stored in > > > > > the cpp_macro object so that it includes the column and range= information for > > > > > the token comprising the macro name; previously, the location= was just the > > > > > generic one pointing to the whole line. > > > > > > > > > > The change to libcpp is very small, the reason for all the te= stsuite changes is > > > > > that I have updated all tests explicitly looking for the colu= mnless diagnostics > > > > > (with the "-:" syntax to dg-warning et al) so that they expec= t a column > > > > > instead. I also added a new test which verifies the expected = range information > > > > > in diagnostics with carets. > > > > > > > > > > Bootstrap + regtest on x86-64 Linux looks good. Please let me= know if it looks > > > > > OK? Thanks! > > > > > > > > > > -Lewis > > > > > > > > > > libcpp/directives.cc | 13 +- > > > > > libcpp/internal.h | 2 +- > > > > > libcpp/macro.cc | 12 +- > > > > > libcpp/pch.cc | 2 +- > > > > > gcc/testsuite/c-c++-common/cpp/line-2.c | 2 +- > > > > > gcc/testsuite/c-c++-common/cpp/line-3.c | 2 +- > > > > > .../c-c++-common/cpp/macro-arg-count-1.c | 4 +- > > > > > gcc/testsuite/c-c++-common/cpp/macro-ranges.c | 52 ++ > > > > > gcc/testsuite/c-c++-common/cpp/pr58844-1.c | 4 +- > > > > > gcc/testsuite/c-c++-common/cpp/pr58844-2.c | 4 +- > > > > > .../c-c++-common/cpp/warning-zero-location.c | 2 +- > > > > > gcc/testsuite/c-c++-common/pragma-diag-14.c | 2 +- > > > > > gcc/testsuite/c-c++-common/pragma-diag-15.c | 2 +- > > > > > gcc/testsuite/g++.dg/modules/macro-2_d.C | 4 +- > > > > > gcc/testsuite/g++.dg/modules/macro-4_d.C | 4 +- > > > > > gcc/testsuite/g++.dg/modules/macro-4_e.C | 2 +- > > > > > .../g++.dg/spellcheck-macro-ordering.C | 2 +- > > > > > gcc/testsuite/gcc.dg/builtin-redefine.c | 18 +- > > > > > gcc/testsuite/gcc.dg/cpp/Wunused.c | 6 +- > > > > > gcc/testsuite/gcc.dg/cpp/redef2.c | 20 +- > > > > > gcc/testsuite/gcc.dg/cpp/redef3.c | 14 +- > > > > > gcc/testsuite/gcc.dg/cpp/redef4.c | 520 +++++++++---= ------ > > > > > gcc/testsuite/gcc.dg/cpp/ucnid-11-utf8.c | 12 +- > > > > > gcc/testsuite/gcc.dg/cpp/ucnid-11.c | 12 +- > > > > > gcc/testsuite/gcc.dg/cpp/undef2.c | 6 +- > > > > > gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c | 10 +- > > > > > gcc/testsuite/gcc.dg/cpp/warn-redefined.c | 10 +- > > > > > .../gcc.dg/cpp/warn-unused-macros-2.c | 2 +- > > > > > gcc/testsuite/gcc.dg/cpp/warn-unused-macros.c | 2 +- > > > > > 29 files changed, 405 insertions(+), 342 deletions(-) > > > > > create mode 100644 gcc/testsuite/c-c++-common/cpp/macro-ranges.c > > > > >