From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 395E03858C20 for ; Thu, 1 Dec 2022 19:51:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 395E03858C20 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-pg1-x52a.google.com with SMTP id q71so2536779pgq.8 for ; Thu, 01 Dec 2022 11:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=hasmLpCklDhgHcANa+1KKT3GstBp9d5VhjD62ncuC+I=; b=hNJ5Wapp8PTG5r9h9Q08ey3gG7QrobAN40l5Cs1eH8IsHLvrYvqe5D42KedsuqvQ2L eXBLf2bYW4Wh+skKxllUDdXqaiAnTJoYo3eNAClOSiU4FiZPZm+W9j4Xs3QhUmlanOL5 SDuf0ljTjBxNI+/7D783AjgWZ5xhJ2g9x2IuoKIu2U8dmbCaEeCObnaeTN8SRf7zn+Re FmcWXaSgDC8A3N0FXxKH0ivqZk0rMd/WaHeZrusqkHTw1P6h4EtWn+aQW238ySmcw1aV 1nPtW0prcpeWZt+o+xOcgOZ1B+e/R/qQo1rm0xriBvbzoiPMUvnkYlJlxlwiq5nfUt9N Xpsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=hasmLpCklDhgHcANa+1KKT3GstBp9d5VhjD62ncuC+I=; b=HreWfouAmzQbjwoMYLAj4caz8FLZMQqgqImWShEjZUlVWQ8/fnv7IU5Gl72+RIlBbH 8JkAmKicGermdLxrMz3Y3Sx9thUKHiVtshUPr92AsOammgejsRiBPLcMyLJd+zPbszr6 ELXuLPOX/pLTYnWJN0bnehil1bLgtvEu0u2XX5h9yy2ZNDbKLFO3aD80o1teVYxlqji9 TAH7dbEnI4eBK2TG+KY/vN+wMdORLn3linSAotfrZN6dExPFaw6XHf3pDKNMfl9vpt2Y BsFKN+e3IkUEqU5+1u8C8qs2zsW4MRZxhBMTXAystIMHi0HOAEmcG6D5sRHVgHbCvtu4 gi4g== X-Gm-Message-State: ANoB5pmtb/i31gvDTx0ponG3dzlphibt8w8qz672BY1owgupOFDduqjk bZM06N/mJd7fRFhTzB26Ljk= X-Google-Smtp-Source: AA0mqf67TxJ2qO+gGMFLhFNWRFs8mR+iZ3ptiYzwkDeGSFSCCGKCQQRqoESgTLsh1cQzqkw0poakXQ== X-Received: by 2002:a05:6a00:216e:b0:56e:7b62:bba with SMTP id r14-20020a056a00216e00b0056e7b620bbamr48811131pff.55.1669924295952; Thu, 01 Dec 2022 11:51:35 -0800 (PST) Received: from [0.0.0.0] ([2401:c080:1c01:981:ab82:f84e:7dce:d795]) by smtp.gmail.com with ESMTPSA id a1-20020a63cd41000000b0045dc85c4a5fsm2869212pgj.44.2022.12.01.11.51.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 11:51:35 -0800 (PST) Message-ID: Date: Fri, 2 Dec 2022 03:51:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__ To: Joseph Myers Cc: gcc-patches@gcc.gnu.org, sangyan@huawei.com References: <20221201043155.9369-1-luolongjuna@gmail.com> <8767c6bc-5b37-ca10-1176-e341081c555f@gmail.com> <587de9c9-e46f-b69e-84d8-7356a19db74@codesourcery.com> From: Longjun Luo In-Reply-To: <587de9c9-e46f-b69e-84d8-7356a19db74@codesourcery.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,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: On 12/2/2022 3:07 AM, Joseph Myers wrote: > On Fri, 2 Dec 2022, Longjun Luo via Gcc-patches wrote: > >> On 12/2/2022 1:01 AM, Joseph Myers wrote: >>> On Thu, 1 Dec 2022, Longjun Luo via Gcc-patches wrote: >>> >>>> 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" } >>>> */ >>> Is there some existing test that verifies that this redefinition is still >>> diagnosed by default (in the absence of -Wno-builtin-macro-redefined)? >> I am not sure I have fully understood your meaning. The problem here is that >> if I try to redefine __LINE__ macro in the situation that projects use the >> option '-Werror', the compile will fail. > There are two cases: > > (a) Is redefinition of __LINE__ diagnosed *without* > -Wno-builtin-macro-redefined? > > (b) Is redefinition of __LINE__ diagnosed *with* > -Wno-builtin-macro-redefined? > > My understanding is that both (a) and (b) have answer "yes" at present, > and your patch would change the answer to (b) to "no", without changing > the answer to (a). > > My question is about whether there is a test verifying the answer to (a). > If not, I think the patch should add one. After some check for the source code, two similiar exist test cases for the situation (a). They are ./gcc/testsuite/gcc.dg/cpp/warn-redefined.c and ./gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c These two cases redefine the __TIME__ macro when using the option '-Wbuiltin-macro-redefined'. I think I shoud add a test to verify __LINE__ macro in these two cases. I will write a complete test for situation (a) and situation (b). But I need a little time to be familar with the gcc testcases. So, the patch itself has no problem. What I need do is to rich its test cases and update change log, right?