On Sun, Apr 30, 2023 at 4:15 PM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 4/30/23 12:30, Jeff Law wrote:
> >
> >
> > On 1/12/23 09:02, Longjun Luo via Gcc-patches wrote:
> >>  From 0821df518b264e754d698d399f98be1a62945e32 Mon Sep 17 00:00:00 2001
> >> From: Longjun Luo <luolongj...@gmail.com>
> >> Date: Thu, 12 Jan 2023 23:59:54 +0800
> >> Subject: [PATCH] libcpp: suppress builtin macro redefined warnings for
> >>   __LINE__
> >>
> >> As implied in
> >> gcc.gnu.org/legacy-ml/gcc-patches/2008-09/msg00076.html,
> >> gcc provides -Wno-builtin-macro-redefined to suppress warning when
> >> redefining builtin macro. However, at that time, there was no
> >> scenario for __LINE__ macro.
> >>
> >> But, when we try to build a live-patch, we compare sections by using
> >> -ffunction-sections. Some same functions are considered changed because
> >> of __LINE__ macro.
> >>
> >> At present, to detect such a changed caused by __LINE__ macro, we
> >> have to analyse code and maintain a function list. For example,
> >> in kpatch, check this commit
> >> github.com/dynup/kpatch/commit/0e1b95edeafa36edb7bcf11da6d1c00f76d7e03d.
> >>
> >> So, in this scenario, when we try to compared sections, it would
> >> be better to support suppress builtin macro redefined warnings for
> >> __LINE__ macro.
> >>
> >> Signed-off-by: Longjun Luo <luolongj...@gmail.com>
> >> ---
> >>   gcc/testsuite/gcc.dg/builtin-redefine-1.c | 49 +++++++++++++++++++++++
> >>   gcc/testsuite/gcc.dg/builtin-redefine.c   | 24 +++++++++--
> >>   libcpp/init.cc                            |  2 +-
> >>   3 files changed, 70 insertions(+), 5 deletions(-)
> >>   create mode 100755 gcc/testsuite/gcc.dg/builtin-redefine-1.c
> > Thanks.  I added a suitable ChangeLog and pushed this to the trunk.
> This is causing regressions on various targets for a few tests:
>
> lm32-sim: c-c++-common/cpp/pr92296-2.c  -Wc++-compat   (test for
> warnings, line 41)
> lm32-sim: gcc.dg/cpp/undef2.c  (test for warnings, line 9)
> lm32-sim: gcc.dg/cpp/undef2.c (test for excess errors)
>
> I have reverted this patch from the trunk.  Please address the
> regressions and resubmit.

>From c-c++-common/cpp/pr92296-2.c (line 40):
#pragma push_macro("__LINE__")
#undef __LINE__         /* { dg-warning "undefining" } */

gcc.dg/cpp/undef2.c (line 9):
#undef __LINE__         /* { dg-warning "undefining \"__LINE__\"" } */


These testcases are specifically testing #undef of __LINE__ ...

Should we be still warning for this case or not?

Thanks,
Andrew Pinski


>
> Thanks,
> Jeff
>

Reply via email to