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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A0B093848412 for ; Wed, 19 May 2021 22:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A0B093848412 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-C5cxuKerNV2Kp8ZfAX6TrQ-1; Wed, 19 May 2021 18:52:43 -0400 X-MC-Unique: C5cxuKerNV2Kp8ZfAX6TrQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 067E71005D52 for ; Wed, 19 May 2021 22:52:42 +0000 (UTC) Received: from localhost (unknown [10.33.36.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A76619718; Wed, 19 May 2021 22:52:41 +0000 (UTC) Date: Wed, 19 May 2021 23:52:40 +0100 From: Jonathan Wakely To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: Add new warning options for C++ language mismatches Message-ID: References: <1de74255-18c5-727f-ce23-990603089252@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 19 May 2021 22:52:48 -0000 On 19/05/21 16:08 -0400, Jason Merrill wrote: >On 5/19/21 4:05 PM, Jonathan Wakely wrote: >>On 19/05/21 20:55 +0100, Jonathan Wakely wrote: >>>On 19/05/21 13:26 -0400, Jason Merrill wrote: >>>>On 5/19/21 12:46 PM, Jonathan Wakely wrote: >>>>>On 19/05/21 17:39 +0100, Jonathan Wakely wrote: >>>>>>Jakub pointed out I'd forgotten the spaces before the opening parens >>>>>>for function calls. The attached patch should fix all those, with no >>>>>>other changes. >>>>>> >>>>>>Tested x86_64-linux. OK for trunk? >>>>> >>>>>Jakub also pointed out we already have some similar diagnostics for >>>>>C++23, but I missed them as they say "only optional with" not "only >>>>>available with". >>>>> >>>>>I'm testing the incremental change in the attached patch which also >>>>>adds -Wc++23-extensions, and I'll resend the full patch after that >>>>>finishes. >>>> >>>>> if (omitted_parms_loc && lambda_specs.any_specifiers_p) >>>>>   { >>>>>-      pedwarn (omitted_parms_loc, 0, >>>>>+      pedwarn (omitted_parms_loc, OPT_Wc__23_extensions, >>>> >>>>You probably want to change >>>> >>>>>else if (cxx_dialect < cxx23) >>>>>  omitted_parms_loc = cp_lexer_peek_token (parser->lexer)->location; >>>> >>>>To use warn_about_dialect_p. >>> >>>Ah yes. >>> >>>And just above that there's another pedwarn about a C++14 feature >>>being used: >>> >>> >>>     /* Default arguments shall not be specified in the >>>     parameter-declaration-clause of a lambda-declarator.  */ >>>     if (cxx_dialect < cxx14) >>>    for (tree t = param_list; t; t = TREE_CHAIN (t)) >>>      if (TREE_PURPOSE (t) && DECL_P (TREE_VALUE (t))) >>>        pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic, >>>             "default argument specified for lambda parameter"); >>> >>> >>>I didn't notice that one initially. That should also use >>>warn_about_dialect_p and OPT_Wc__14_extensions. >>> >>>Should I change the message to say "init capture" rather than >>>"default argument"? >>> >>>I'll add some docs to invoke.texi and get a new patch out. >> >>Oh, also we have https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93769 >>which points out a problem with the current wording. Not a very >>important one, but still ... >> >>While I'm touching all 38(?) places that say "only available with >>-std=c++NN or -std=gnu++NN I could change them to say something like >>"only available since C++NN". Should I bother? >> >>Clang's equivalent warnings say "are a C++11 feature" e.g. >> >>ext.C:1:17: warning: inline namespaces are a C++11 feature >>[-Wc++11-inline-namespace] >> >>(They have a specific warning for each feature, with >>-Wc++11-extensions to control them all at once.) > >The clang wording seems more accurate, as that PR points out. OK, that requires touching a number of error_at and inform calls as well as the pedwarns, so I'll address that separately in a later patch.