From patchwork Fri Feb 17 12:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 729165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vPtQt1YYdz9s8J for ; Fri, 17 Feb 2017 23:59:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MCWmwyVQ"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=iJb8zzftFJSlti2EYYirgsgBnpYIoJ3jRby02bBnKxnWR4+lrW KVHOIec/fNQ0oGKaZW9GzXRgs7wIONcK1Gq/5tl2xEH05BEuYBJLMJr8VPEXtsvz 9lQFxPGQihecMAVAjkd9i079eJq9c3rSw+a3WZX5L4daH/+gp/W16biaw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=rCooPgLyXoQ/Mi5G+kv2dn4wSO0=; b=MCWmwyVQB2RdEuqLymVi sQ1V51RHWba5zas7XzQWtLvh2Rkj0RwuYbIFVPnYamPhYzcRTAXExtdgUVcwQ95i OGdOrbcjWT8S4bDWqsoph9TwOqBksnGWp8emxFvuLSdZ8bByfp8MnIHFDkURdjJu palhs72nb4Zcqx76csJOTp4= Received: (qmail 97072 invoked by alias); 17 Feb 2017 12:59:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 97059 invoked by uid 89); 17 Feb 2017 12:59:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=reserved X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Feb 2017 12:59:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 534A03D974 for ; Fri, 17 Feb 2017 12:59:30 +0000 (UTC) Received: from localhost (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1HCxTkc025128; Fri, 17 Feb 2017 07:59:29 -0500 Date: Fri, 17 Feb 2017 12:59:28 +0000 From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Cc: Jason Merrill Subject: [PATCH] PR c++/69523 make -Wliteral-suffix control warning Message-ID: <20170217125927.GA29907@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) Currently there's no way to disable the warning about literal suffix identifiers that use reserved names. This patch from Eric makes it depend on the existing -Wliteral-suffix option. Currently that controls warnings when encountering string literals concatenated with macros, such as "%"PRIu32, which isn't the same problem, but I think it's OK to reuse the warning option for this as well. Tested powerpc64le-linux. OK for trunk now, or should it wait for Stage 1? gcc: 2017-02-17 Jonathan Wakely PR c++/69523 * doc/invoke.texi (C++ Dialect Options) [-Wliteral-suffix]: Update description. gcc/cp: 2017-02-17 Eric Fiselier Jonathan Wakely PR c++/69523 * parser.c (cp_parser_unqualified_id): Use OPT_Wliteral_suffix to control warning about literal suffix identifiers without a leading underscore. gcc/testsuite: 2017-02-17 Eric Fiselier Jonathan Wakely PR c++/69523 * g++.dg/cpp0x/Wliteral-suffix2.C: New test. commit 4d04ba1c1d19973d2b7e845a2f92cdd292054756 Author: Jonathan Wakely Date: Fri Feb 17 10:50:20 2017 +0000 PR c++/69523 make -Wliteral-suffix control warning gcc: 2017-02-17 Jonathan Wakely PR c++/69523 * doc/invoke.texi (C++ Dialect Options) [-Wliteral-suffix]: Update description. gcc/cp: 2017-02-17 Eric Fiselier Jonathan Wakely PR c++/69523 * parser.c (cp_parser_unqualified_id): Use OPT_Wliteral_suffix to control warning about literal suffix identifiers without a leading underscore. gcc/testsuite: 2017-02-17 Eric Fiselier Jonathan Wakely PR c++/69523 * g++.dg/cpp0x/Wliteral-suffix2.C: New test. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 060962d..06f2beb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5812,8 +5812,9 @@ cp_parser_unqualified_id (cp_parser* parser, const char *name = UDLIT_OP_SUFFIX (id); if (name[0] != '_' && !in_system_header_at (input_location) && declarator_p) - warning (0, "literal operator suffixes not preceded by %<_%>" - " are reserved for future standardization"); + warning (OPT_Wliteral_suffix, + "literal operator suffixes not preceded by %<_%>" + " are reserved for future standardization"); } return id; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 72038a1..0154e3d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2851,6 +2851,11 @@ int main() @{ In this case, @code{PRId64} is treated as a separate preprocessing token. +Additionally, warn when a user-defined literal operator is declared with +a literal suffix identifier that doesn't begin with an underscore. Literal +suffix identifiers that don't begin with an underscore are reserved for +future standardization. + This warning is enabled by default. @item -Wlto-type-mismatch diff --git a/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C new file mode 100644 index 0000000..129947d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-literal-suffix" } + +// Test user-defined literals. +// Test "-Wno-literal-suffix" suppresses warnings on declaration without +// leading underscore. + +long double operator"" nounder(long double); // { dg-bogus "" } + +template + int operator"" nounder(); // { dg-bogus "" }