From patchwork Thu Dec 1 04:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Longjun Luo X-Patchwork-Id: 28187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp69445wrr; Wed, 30 Nov 2022 20:33:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf6IfyFvFgC/wzoS3Ys587IgrqwMeutwUyW7Bu8qKhRaXMdwnPIZ67yIINRFQ+2miBsC1fjD X-Received: by 2002:a50:fe8d:0:b0:461:9183:834b with SMTP id d13-20020a50fe8d000000b004619183834bmr43436025edt.196.1669869184141; Wed, 30 Nov 2022 20:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669869184; cv=none; d=google.com; s=arc-20160816; b=x+cS1BcNsMXwtZlU5O7ZQ9HRHDlqlHjDlquetdYyYiZNFOkcwhr9HP5dehsOT0Nn7m TzCuQ0IDByPTCNTLm7dvwPZdhwRi697xFR8bma1UWcKt5akWIyGvAQPEHsnSxLPxDzuC UOCr4lu2nf8PL5wxbUfKvH0I4RDtp8iyPKZ7P3TiMEAOGYFtwr8n9qZ68+irIUg56P5t 5uc9AQcuqfS+fLIOGjGSESVYpUJRk7fCNBFGrjfPcKvTr+rTqEjzPXA/H7hT/RxGsOT1 rC3W8o9Ipj1c5Am5d0o8kdkns/tb5P0u2cjiVcQ0XefLTD2adysN7fwZeZ+sb4erL7Gr eNmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6CoFYjChysDI1m7h2Ql8IHg1LL1m6Rb/iBjxjKSg24k=; b=cc/rPh8JZw1ducl09E7HmXP6uPaupsHrphW6WOnAEPxqpa+EqNjmADUji/Em6EOOnu KYL2v1qM0JEDIaZJ/84aOHYNV/w0mSxlYi645Z/l++R2OjJ0XMrda/588CIWQSDsxT02 SLyI/InoGSWDWvPrJK1okrifOQYF7f5wW0Kgs33bZOzLH5iSjubOf57ZBqJ56+nkUbcQ YjLg8WhAGgDitXDszaFbwwOEcIQUz4XFvjRz18U3ry3mUbp19sVgcBaqkT2u3bANv3gJ 5QHUAM7iSu1Ao765SJ+rBUpgoTtrN54J1YivN+J5yFMoO7rDdTGJTSQcBKFcT6r9DVSw tNJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="f29l/KZ4"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o18-20020aa7c7d2000000b0046aeb223d08si2379878eds.450.2022.11.30.20.33.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 20:33:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="f29l/KZ4"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 06265385B184 for ; Thu, 1 Dec 2022 04:33:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06265385B184 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669869183; bh=6CoFYjChysDI1m7h2Ql8IHg1LL1m6Rb/iBjxjKSg24k=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=f29l/KZ4o+Y32RGN0iIEZMAhfGGMHtleS5WzwGj6PyIfWL+GuVE+3OKOBIhU10t9f UMIn8WMe+ql59FYtZD0/7co09quNZhOPxqm+UdJLCq/XVlSF0KoGjjJJFBfW4G7USR ki/4KnJEpo2FAp9rTWxvEMAze0z7QpLkMaqDM5/4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from longcc.localdomain (unknown [210.75.100.191]) by sourceware.org (Postfix) with ESMTPS id BE94F3858D37 for ; Thu, 1 Dec 2022 04:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE94F3858D37 Received: by longcc.localdomain (Postfix, from userid 1000) id E1554602805; Thu, 1 Dec 2022 12:32:10 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: luolongjuna@gmail.com, sangyan@huawei.com Subject: [PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__ Date: Thu, 1 Dec 2022 12:31:55 +0800 Message-Id: <20221201043155.9369-1-luolongjuna@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, NML_ADSP_CUSTOM_MED, NO_DNS_FOR_FROM, SPF_HELO_NONE, SPF_NONE, SPOOFED_FREEMAIL, SPOOFED_FREEMAIL_NO_RDNS, SPOOF_GMAIL_MID 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-Patchwork-Original-From: Longjun Luo via Gcc-patches From: Longjun Luo Reply-To: Longjun Luo Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750984749495302691?= X-GMAIL-MSGID: =?utf-8?q?1750984749495302691?= 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 Signed-off-by: Longjun Luo --- gcc/testsuite/gcc.dg/builtin-redefine.c | 1 - libcpp/init.cc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/builtin-redefine.c b/gcc/testsuite/gcc.dg/builtin-redefine.c index 882b2210992..9d5b42252ee 100644 --- a/gcc/testsuite/gcc.dg/builtin-redefine.c +++ b/gcc/testsuite/gcc.dg/builtin-redefine.c @@ -71,7 +71,6 @@ /* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */ #endif -#define __LINE__ 0 /* { dg-warning "-:\"__LINE__\" redef" } */ #define __INCLUDE_LEVEL__ 0 /* { dg-warning "-:\"__INCLUDE_LEVEL__\" redef" } */ #define __COUNTER__ 0 /* { dg-warning "-:\"__COUNTER__\" redef" } */ diff --git a/libcpp/init.cc b/libcpp/init.cc index 5f34e3515d2..2765b9838b7 100644 --- a/libcpp/init.cc +++ b/libcpp/init.cc @@ -421,7 +421,7 @@ static const struct builtin_macro builtin_array[] = B("__FILE__", BT_FILE, false), B("__FILE_NAME__", BT_FILE_NAME, false), B("__BASE_FILE__", BT_BASE_FILE, false), - B("__LINE__", BT_SPECLINE, true), + B("__LINE__", BT_SPECLINE, false), B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true), B("__COUNTER__", BT_COUNTER, true), /* Make sure to update the list of built-in