From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 817763858D32 for ; Tue, 23 Aug 2022 21:54:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 817763858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661291673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Z6Qu1z3LJHDeMAqOt+BgkXJgJNAavlq+6jBTE/pfXo=; b=eGsS5ue1WuxiEsP79N6AMgvSoJtlXkU6IRGBoTChfyZgC3glFWY8P+DiDxGuYoMFUppzsi Jm/X7F3AArWLMLoHQ+W1Eq2mNz1NHE74DzmytVDopSTLijugtPcFXEkbflO/pPG9uTu8da EWsQ7Dngr0QzA77pFhKisa0s/ekPd1s= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-610-hdI5Fhu0N7CFq525y3ysQg-1; Tue, 23 Aug 2022 17:54:30 -0400 X-MC-Unique: hdI5Fhu0N7CFq525y3ysQg-1 Received: by mail-qv1-f72.google.com with SMTP id ly9-20020a0562145c0900b00496e3810e40so4201389qvb.12 for ; Tue, 23 Aug 2022 14:54:29 -0700 (PDT) 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 :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=5Z6Qu1z3LJHDeMAqOt+BgkXJgJNAavlq+6jBTE/pfXo=; b=xi3zRojJG4cjPCc6JYp5iEHGk8aC7NhzrFNmOqquAeqqu6JzkuL2iMefAdKmPG385x vaOTI0zRezEkleb8x4hMYETskJhRzOtW2JWyfFqapOIiD0J36nhKMn563D7Ssqf94nuc aBhVrK9kkMQlG+hDty0XVsGojA7bc8zaKDF7RgZegdVxmnqIIaWfZ8m+MqPCjIxlyn02 PAp8dZx8Qr/+5MdL4qeVuzwedy19PNAnMKrX29hzUdCVpEgxpPq8BpbC4Sz56xBLQUdQ dnGDqMVgkID3JFO7NKbu0TcaABdC5rdcOC55burFYBXghiybldzS625YPNRthfgeLB5X CxxQ== X-Gm-Message-State: ACgBeo3iyY89lat2U8K2Ksk/fgymgwCgq2ApKZr0ERmDoX8dWBnilkM3 HsWmClvwlreU1gSS/HL2VgzTFp/2Jz8Pzw4Qz2UsdkUQbysGjWM3RvK8UMfINTOIYHvS+F4HjZl FUPOtDx9xDEeVGU4D0Q== X-Received: by 2002:a05:622a:120d:b0:342:f643:3d6e with SMTP id y13-20020a05622a120d00b00342f6433d6emr21788704qtx.263.1661291669524; Tue, 23 Aug 2022 14:54:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wK5dAqxNozzdgSQW7aUtxIpA50dfeTL98fLL2cUcUKOrHZEkR4aWziWMcS6PnCUOIIX/+VQ== X-Received: by 2002:a05:622a:120d:b0:342:f643:3d6e with SMTP id y13-20020a05622a120d00b00342f6433d6emr21788690qtx.263.1661291669253; Tue, 23 Aug 2022 14:54:29 -0700 (PDT) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id r11-20020ae9d60b000000b006af1f0af045sm13470540qkk.107.2022.08.23.14.54.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Aug 2022 14:54:28 -0700 (PDT) Message-ID: Date: Tue, 23 Aug 2022 17:54:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] preprocessor: Implement C++23 P2437R1 - Support for #warning [PR106646] To: Jakub Jelinek , Joseph Myers Cc: gcc-patches@gcc.gnu.org, Marek Polacek References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SCC_5_SHORT_WORD_LINES,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 8/22/22 02:53, Jakub Jelinek wrote: > Hi! > > On Thu, Aug 18, 2022 at 11:02:44PM +0000, Joseph Myers wrote: >> ISO C2x standardizes the existing #warning extension. Arrange >> accordingly for it not to be diagnosed with -std=c2x -pedantic, but to >> be diagnosed with -Wc11-c2x-compat. > > And here is the corresponding C++ version. > Don't pedwarn about this for C++23/GNU++23 and tweak the diagnostics > for C++ otherwise, + testsuite coverage. > The diagnostic wording is similar e.g. to the #elifdef diagnostics. > > So far lightly tested, ok for trunk if it passes full bootstrap/regtest? OK. > 2022-08-22 Jakub Jelinek > > PR c++/106646 > * init.cc: Implement C++23 P2437R1 - Support for #warning. > (lang_defaults): Set warning_directive for GNUCXX23 and CXX23. > * directives.cc (directive_diagnostics): Use different wording of > #warning pedwarn for C++. > > * g++.dg/cpp/warning-1.C: New test. > * g++.dg/cpp/warning-2.C: New test. > * g++.dg/cpp/warning-3.C: New test. > > --- libcpp/init.cc.jj 2022-08-20 10:25:17.613071845 +0200 > +++ libcpp/init.cc 2022-08-22 11:30:57.642622570 +0200 > @@ -123,8 +123,8 @@ static const struct lang_flags lang_defa > /* CXX17 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0 }, > /* GNUCXX20 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 }, > /* CXX20 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 }, > - /* GNUCXX23 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1 }, > - /* CXX23 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1 }, > + /* GNUCXX23 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1 }, > + /* CXX23 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1 }, > /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } > }; > > --- libcpp/directives.cc.jj 2022-08-19 16:00:05.295386974 +0200 > +++ libcpp/directives.cc 2022-08-22 11:30:03.239357642 +0200 > @@ -388,8 +388,14 @@ directive_diagnostics (cpp_reader *pfile > else if (dir == &dtable[T_WARNING]) > { > if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, warning_directive)) > - cpp_error (pfile, CPP_DL_PEDWARN, > - "#%s before C2X is a GCC extension", dir->name); > + { > + if (CPP_OPTION (pfile, cplusplus)) > + cpp_error (pfile, CPP_DL_PEDWARN, > + "#%s before C++23 is a GCC extension", dir->name); > + else > + cpp_error (pfile, CPP_DL_PEDWARN, > + "#%s before C2X is a GCC extension", dir->name); > + } > else if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0) > cpp_warning (pfile, CPP_W_C11_C2X_COMPAT, > "#%s before C2X is a GCC extension", dir->name); > --- gcc/testsuite/g++.dg/cpp/warning-1.C.jj 2022-08-22 11:39:41.284547323 +0200 > +++ gcc/testsuite/g++.dg/cpp/warning-1.C 2022-08-22 11:44:03.925988332 +0200 > @@ -0,0 +1,6 @@ > +// P2437R1 - Support for #warning > +// { dg-do preprocess } > +// { dg-options "-pedantic-errors" } > + > +#warning example text /* { dg-warning "example text" } */ > +// { dg-error "#warning before C\\\+\\\+23 is a GCC extension" "pedantic" { target c++20_down } .-1 } > --- gcc/testsuite/g++.dg/cpp/warning-2.C.jj 2022-08-22 11:39:44.116509055 +0200 > +++ gcc/testsuite/g++.dg/cpp/warning-2.C 2022-08-22 11:44:14.933839041 +0200 > @@ -0,0 +1,6 @@ > +// P2437R1 - Support for #warning > +// { dg-do preprocess } > +// { dg-options "-pedantic" } > + > +#warning example text /* { dg-warning "example text" } */ > +// { dg-warning "#warning before C\\\+\\\+23 is a GCC extension" "pedantic" { target c++20_down } .-1 } > --- gcc/testsuite/g++.dg/cpp/warning-3.C.jj 2022-08-22 11:39:47.020469826 +0200 > +++ gcc/testsuite/g++.dg/cpp/warning-3.C 2022-08-22 11:42:23.640348405 +0200 > @@ -0,0 +1,6 @@ > +// P2437R1 - Support for #warning > +// { dg-do preprocess } > +// { dg-options "" } > + > +#warning example text /* { dg-warning "example text" } */ > +// { dg-bogus "#warning before C\\\+\\\+23 is a GCC extension" "" { target *-*-* } .-1 } > > > Jakub >