From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 5278A385115F for ; Thu, 15 Sep 2022 22:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5278A385115F 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-lf1-x129.google.com with SMTP id s6so21445672lfo.7 for ; Thu, 15 Sep 2022 15:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=yJpcL4VWqzxFk39gdYSdRIa43N+/wdTD1KLfoGmjjHM=; b=hQVtIjjuDRrcRZOblCZX5fs10naEM5MCZ7O7Fkrp61fB2kKgAfI5522uQaA9gyz0vQ /+l6Yn3TBSAS4UGY5PGF87jU6xKrvXqwU1YYSYnhIiASieZ0wjgyeVLAlH9ztV4yYuin l4x6/QV19ASt+6nGbF0nIGQISbbgFVrrRp5xrTEvHXsuumbnlJ3h6pU5FzuSdvgVnEgk X8+UxJkfQ/plrg0UJVSSviVqeEELlZGdh8XkXzUq54B/9G2iCn3uiZ9WIb3LscYeiy2v Fj7P9VvxijPQiEJIQp8XZTZ1z4Abeg5oIGsL2qR46BEr9L4O9qJ8tZN7Loii/s6mySiN RyFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=yJpcL4VWqzxFk39gdYSdRIa43N+/wdTD1KLfoGmjjHM=; b=ZGKepuCFmzgr6gE1IC6cWeVuwuxNcHOPHlerUdi2OIUOjOVhLzXt3vrlcBEEo1IMyw MvSNfv9RPb44ugoq+21Bx5RVM1kGwdq09NvITwh5Stpb0TGfB3FIIH/ad80Pwgts+cN3 G5l449KGsfOtsmpvv7g6ZZC7DNNH9tzlWTiINpoUpTSmC72RorWW9i6PxytVNdChL8DT 8ArGm22fFG6KdT4u5qAfbL3KCjqDze4VgMB2yZyQzalGLK26uMfXH8ZZTr6YD885kdTA AnEybX38yvLxTDn+PlqxvErUkfPvY29B9NQ7J3wKzuBcQXPeYsVT0d76muLw7qgG4/GB mrIA== X-Gm-Message-State: ACrzQf0xBr/0T1fq4snsgtfigjVjD7gGzzRkfFPKEolfXfg5u/FcTJA3 ovZWbdfqDJjE4D7DJJ94aVdSEj3Bo5Yf0iRXYVcD35VQxjM= X-Google-Smtp-Source: AMsMyM5+cM+9ThFZ26CHMzo0J3SCwR1+MwLBwHPGCFhv6Dzf7S0MPexVqFCWror1Bj/7xwMrqRLzfJvWsMZPaCgjHB8= X-Received: by 2002:a05:6512:10c1:b0:492:a27d:ff44 with SMTP id k1-20020a05651210c100b00492a27dff44mr637073lfg.405.1663281113526; Thu, 15 Sep 2022 15:31:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Lewis Hyatt Date: Thu, 15 Sep 2022 18:31:42 -0400 Message-ID: Subject: Ping: [PATCH] libcpp: Improve location for macro names [PR66290] To: 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,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: 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 wrote: > > > When libcpp reports diagnostics whose locus is a macro name (such as for > -Wunused-macros), it uses the location in the cpp_macro object that was > stored by _cpp_new_macro. This is currently set to pfile->directive_line, > which contains the line number only and no column information. This 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 argument. > * internal.h (_cpp_create_definition): Adjust prototype. > * directives.cc (do_define): Pass new location argument to > _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 information > 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=66290) 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 wanted to also > address a second point brought up in the PR comments, namely that we do not > include column information when emitting diagnostics for macro names, such as > is done for -Wunused-macros. The attached patch updates the location 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 testsuite changes is > that I have updated all tests explicitly looking for the columnless diagnostics > (with the "-:" syntax to dg-warning et al) so that they expect 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 >