From patchwork Thu Oct 3 16:39:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1992433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fr7JwbY6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XKHWX0XFpz1xt2 for ; Fri, 4 Oct 2024 02:41:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C894138460B1 for ; Thu, 3 Oct 2024 16:41:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id ED5683865473 for ; Thu, 3 Oct 2024 16:41:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED5683865473 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED5683865473 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727973675; cv=none; b=kdtt7tjd4rqp9DrqXeS5zdao9k6bJ/bOjbH+qHuaPClldWfa9AJ/rAWGimQZAVIN6t0VEkG3XFfWIs1V7HYlGaxaZUSJKx2IzBBxi6KuKz7W9BBQC/w8M862dDd9NZl/nzvC4U+hN9GmMESu9xy1AeHODTp1e/BlGch8LJqygYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727973675; c=relaxed/simple; bh=8Z3zlWSwXw3bEdZuTADTzf23dFogeSmlHyk+P0dbjXE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=q6xeKM2KR+3bhbtSUNziL9E3vQOwjgGg2aDEXgaeU3k+RisSJdkJx6wRN6L5o4d11/V35DVGbaOV2eu93qaJ9Nrvtil77rPKv4APct3+8lT0ItqHVdf4JfybDjy2flddfwkMPhyndTq21S980wMtLkZnwEdCc+gCdMku2xj9bEM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727973668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+65UsnUCnSGfRfvAkp4Rdl0ZdHw6PLgmaw9LF/Vuat4=; b=Fr7JwbY6+HFffQd9WWRJ15uZgpGRntYaW/fWMVtHBxlAWHlWArF2DMBTWK0M/9vJ2Rz71x bgiP2VaMahhswvibjhJwB9GeNWijEGRzkUBCW/HboJRfAnv46N9fHtHF5MJyKH9h+ONURz rYFRlERN9TuBir+d2eN24L6X8M8YDZs= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-27-EmxGILT7NRuYLjmvObLEWA-1; Thu, 03 Oct 2024 12:41:06 -0400 X-MC-Unique: EmxGILT7NRuYLjmvObLEWA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7a9a74d39b5so195889885a.2 for ; Thu, 03 Oct 2024 09:41:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727973665; x=1728578465; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+65UsnUCnSGfRfvAkp4Rdl0ZdHw6PLgmaw9LF/Vuat4=; b=UOIsNc9R+Mv4uuKENaVO35P5WJWkU16vBs0U1+0nLwpfMW2fk6edXhmYFqjNf1hGf3 A0Q3e33hZQHCq0Dn9obcI7ZNd5mdk+8DzmRwiv8GWgbuq+orYkGlbliDVRzZNklF1h8t ZwMSO2daPshT2wljb1PAYlE74XxQ/67HDQ/TMnLjTvJLY2HFqSCRIR1Zv+COGU/dw/99 LZqnCwlPDJkRcwHjJIXHLOeFosMnHplkm377eiIX+TX5RN8tbtTKthhREVuGtqpVp+g1 OUnnyKhEEC2v2fBvp6FSqucF7VWDXaGI8Zu9aovWMalq1Dj+KENr5lmfnaBKps8bEEFT PROg== X-Gm-Message-State: AOJu0YzJNsOMn/+Y/Mz07ipFEAJGteug2asdWjf0Iu74WuMYUBvUDWyn lk26JxZjfOP1RqkJmluHTuraGc2raKlFsSkJkmjUDZtwCTVbzBvXUsL87c6d5eR6dBkQWLdC5FO QC6D/mvD2IfWHRYvK7D6maxUYnIyWB1OcMilKwfFulFys5WtaIK+Tl+J6CLEChzBG1yMxd6YcYj ctY+yt8O/YtXco/6pDdV9fERZm5qxZhjbv8KE= X-Received: by 2002:a05:620a:2707:b0:7ae:6cb9:5648 with SMTP id af79cd13be357-7ae6cb956f7mr209901885a.10.1727973662564; Thu, 03 Oct 2024 09:41:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/lriNLt3SkaXGVehgL9LnA6QZEkXuaqQkSfTjSEPHQlZDsSDxACsudxYj8DzrCxU9jYqq9g== X-Received: by 2002:a05:620a:2707:b0:7ae:6cb9:5648 with SMTP id af79cd13be357-7ae6cb956f7mr209885785a.10.1727973660202; Thu, 03 Oct 2024 09:41:00 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae6b3a306asm63455885a.62.2024.10.03.09.40.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 09:40:59 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] c++: add -Wdeprecated-literal-operator [CWG2521] Date: Thu, 3 Oct 2024 12:39:59 -0400 Message-ID: <20241003164057.1087609-1-jason@redhat.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- C++23 CWG issue 2521 (https://wg21.link/cwg2521) deprecates user-defined literal operators declared with the optional space between "" and the suffix. Many testcases used that syntax; I removed the space from most of them, and added C++23 warning tests to a few. CWG 2521 gcc/ChangeLog: * doc/invoke.texi: Document -Wdeprecated-literal-operator. gcc/c-family/ChangeLog: * c.opt: Add -Wdeprecated-literal-operator. * c-opts.cc (c_common_post_options): Default on in C++23. * c.opt.urls: Regenerate. gcc/cp/ChangeLog: * parser.cc (location_between): New. (cp_parser_operator): Handle -Wdeprecated-literal-operator. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/udlit-string-literal.h * g++.dg/cpp0x/Wliteral-suffix2.C * g++.dg/cpp0x/constexpr-55708.C * g++.dg/cpp0x/gnu_fext-numeric-literals.C * g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C * g++.dg/cpp0x/pr51420.C * g++.dg/cpp0x/pr60209-neg.C * g++.dg/cpp0x/pr60209.C * g++.dg/cpp0x/pr61038.C * g++.dg/cpp0x/std_fext-numeric-literals.C * g++.dg/cpp0x/std_fno-ext-numeric-literals.C * g++.dg/cpp0x/udlit-addr.C * g++.dg/cpp0x/udlit-args-neg.C * g++.dg/cpp0x/udlit-args.C * g++.dg/cpp0x/udlit-args2.C * g++.dg/cpp0x/udlit-clink-neg.C * g++.dg/cpp0x/udlit-concat-neg.C * g++.dg/cpp0x/udlit-concat.C * g++.dg/cpp0x/udlit-constexpr.C * g++.dg/cpp0x/udlit-cpp98-neg.C * g++.dg/cpp0x/udlit-declare-neg.C * g++.dg/cpp0x/udlit-embed-quote.C * g++.dg/cpp0x/udlit-extended-id-1.C * g++.dg/cpp0x/udlit-extended-id-3.C * g++.dg/cpp0x/udlit-extern-c.C * g++.dg/cpp0x/udlit-friend.C * g++.dg/cpp0x/udlit-general.C * g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C * g++.dg/cpp0x/udlit-implicit-conv-neg.C * g++.dg/cpp0x/udlit-inline.C * g++.dg/cpp0x/udlit-mangle.C * g++.dg/cpp0x/udlit-member-neg.C * g++.dg/cpp0x/udlit-namespace.C * g++.dg/cpp0x/udlit-nofunc-neg.C * g++.dg/cpp0x/udlit-nonempty-str-neg.C * g++.dg/cpp0x/udlit-nosuffix-neg.C * g++.dg/cpp0x/udlit-nounder-neg.C * g++.dg/cpp0x/udlit-operator-neg.C * g++.dg/cpp0x/udlit-overflow-neg.C * g++.dg/cpp0x/udlit-overflow.C * g++.dg/cpp0x/udlit-preproc-neg.C * g++.dg/cpp0x/udlit-raw-length.C * g++.dg/cpp0x/udlit-raw-op-string-neg.C * g++.dg/cpp0x/udlit-raw-op.C * g++.dg/cpp0x/udlit-raw-str.C * g++.dg/cpp0x/udlit-resolve-char8_t.C * g++.dg/cpp0x/udlit-resolve.C * g++.dg/cpp0x/udlit-shadow-neg.C * g++.dg/cpp0x/udlit-string-length.C * g++.dg/cpp0x/udlit-suffix-neg.C * g++.dg/cpp0x/udlit-template.C * g++.dg/cpp0x/udlit-tmpl-arg-neg.C * g++.dg/cpp0x/udlit-tmpl-arg-neg2.C * g++.dg/cpp0x/udlit-tmpl-arg.C * g++.dg/cpp0x/udlit-tmpl-parms-neg.C * g++.dg/cpp0x/udlit-tmpl-parms.C * g++.dg/cpp1y/pr57640.C * g++.dg/cpp1y/pr88872.C * g++.dg/cpp26/unevalstr1.C * g++.dg/cpp2a/concepts-pr60391.C * g++.dg/cpp2a/consteval-prop21.C * g++.dg/cpp2a/nontype-class6.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C * g++.dg/cpp2a/udlit-class-nttp-ctad.C * g++.dg/cpp2a/udlit-class-nttp-neg.C * g++.dg/cpp2a/udlit-class-nttp-neg2.C * g++.dg/cpp2a/udlit-class-nttp.C * g++.dg/ext/is_convertible2.C * g++.dg/lookup/pr87269.C * g++.dg/cpp0x/udlit_system_header: Adjust for C++23 deprecated operator "" _suffix. * g++.dg/DRs/dr2521.C: New test. --- gcc/doc/invoke.texi | 12 ++++++ gcc/c-family/c.opt | 4 ++ .../g++.dg/cpp0x/udlit-string-literal.h | 10 ++--- gcc/c-family/c-opts.cc | 5 +++ gcc/cp/parser.cc | 33 +++++++++++++-- gcc/testsuite/g++.dg/DRs/dr2521.C | 5 +++ gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C | 5 ++- gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C | 2 +- .../g++.dg/cpp0x/gnu_fext-numeric-literals.C | 32 +++++++-------- .../cpp0x/gnu_fno-ext-numeric-literals.C | 32 +++++++-------- gcc/testsuite/g++.dg/cpp0x/pr51420.C | 4 +- gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C | 16 ++++---- gcc/testsuite/g++.dg/cpp0x/pr60209.C | 2 + gcc/testsuite/g++.dg/cpp0x/pr61038.C | 4 +- .../g++.dg/cpp0x/std_fext-numeric-literals.C | 32 +++++++-------- .../cpp0x/std_fno-ext-numeric-literals.C | 32 +++++++-------- gcc/testsuite/g++.dg/cpp0x/udlit-addr.C | 4 +- gcc/testsuite/g++.dg/cpp0x/udlit-args-neg.C | 24 +++++------ gcc/testsuite/g++.dg/cpp0x/udlit-args.C | 22 +++++----- gcc/testsuite/g++.dg/cpp0x/udlit-args2.C | 8 ++-- gcc/testsuite/g++.dg/cpp0x/udlit-clink-neg.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-concat-neg.C | 4 +- gcc/testsuite/g++.dg/cpp0x/udlit-concat.C | 6 +-- gcc/testsuite/g++.dg/cpp0x/udlit-constexpr.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-cpp98-neg.C | 4 +- .../g++.dg/cpp0x/udlit-declare-neg.C | 8 ++-- .../g++.dg/cpp0x/udlit-embed-quote.C | 4 +- .../g++.dg/cpp0x/udlit-extended-id-1.C | 10 ++--- .../g++.dg/cpp0x/udlit-extended-id-3.C | 1 + gcc/testsuite/g++.dg/cpp0x/udlit-extern-c.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-friend.C | 12 +++--- gcc/testsuite/g++.dg/cpp0x/udlit-general.C | 22 +++++----- .../cpp0x/udlit-implicit-conv-neg-char8_t.C | 24 +++++------ .../g++.dg/cpp0x/udlit-implicit-conv-neg.C | 20 +++++----- gcc/testsuite/g++.dg/cpp0x/udlit-inline.C | 10 ++--- gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-member-neg.C | 6 +-- gcc/testsuite/g++.dg/cpp0x/udlit-namespace.C | 10 ++--- gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C | 4 +- .../g++.dg/cpp0x/udlit-nonempty-str-neg.C | 2 +- .../g++.dg/cpp0x/udlit-nosuffix-neg.C | 2 +- .../g++.dg/cpp0x/udlit-nounder-neg.C | 4 +- .../g++.dg/cpp0x/udlit-operator-neg.C | 12 +++--- .../g++.dg/cpp0x/udlit-overflow-neg.C | 4 +- gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C | 4 +- .../g++.dg/cpp0x/udlit-preproc-neg.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C | 2 +- .../g++.dg/cpp0x/udlit-raw-op-string-neg.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-raw-str.C | 2 +- .../g++.dg/cpp0x/udlit-resolve-char8_t.C | 30 +++++++------- gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C | 26 ++++++------ gcc/testsuite/g++.dg/cpp0x/udlit-shadow-neg.C | 40 +++++++++---------- .../g++.dg/cpp0x/udlit-string-length.C | 10 ++--- gcc/testsuite/g++.dg/cpp0x/udlit-suffix-neg.C | 2 +- gcc/testsuite/g++.dg/cpp0x/udlit-template.C | 18 ++++----- .../g++.dg/cpp0x/udlit-tmpl-arg-neg.C | 2 +- .../g++.dg/cpp0x/udlit-tmpl-arg-neg2.C | 4 +- gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg.C | 2 +- .../g++.dg/cpp0x/udlit-tmpl-parms-neg.C | 6 +-- gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms.C | 2 +- gcc/testsuite/g++.dg/cpp1y/pr57640.C | 2 +- gcc/testsuite/g++.dg/cpp1y/pr88872.C | 2 +- gcc/testsuite/g++.dg/cpp26/unevalstr1.C | 34 ++++++++-------- gcc/testsuite/g++.dg/cpp2a/concepts-pr60391.C | 2 +- gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C | 2 +- gcc/testsuite/g++.dg/cpp2a/nontype-class6.C | 2 +- .../g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C | 2 +- .../g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C | 2 +- .../g++.dg/cpp2a/udlit-class-nttp-ctad.C | 2 +- .../g++.dg/cpp2a/udlit-class-nttp-neg.C | 2 +- .../g++.dg/cpp2a/udlit-class-nttp-neg2.C | 2 +- gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp.C | 2 +- gcc/testsuite/g++.dg/ext/is_convertible2.C | 2 +- gcc/testsuite/g++.dg/lookup/pr87269.C | 4 +- gcc/c-family/c.opt.urls | 3 ++ .../g++.dg/cpp0x/udlit_system_header | 2 +- 77 files changed, 373 insertions(+), 315 deletions(-) create mode 100644 gcc/testsuite/g++.dg/DRs/dr2521.C base-commit: 5b08ae503dd4aef2789a667daaf1984e7cc94aaa diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e199522f62c..c90f5b4d58e 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4032,6 +4032,18 @@ bool b = e <= 3.7; @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled by @option{-Wenum-conversion}. +@opindex Wdeprecated-literal-operator +@opindex Wno-deprecated-literal-operator +@item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)} +Warn that the declaration of a user-defined literal operator with a +space before the suffix is deprecated. This warning is enabled by +default in C++23. + +@smallexample +string operator "" _i18n(const char*, std::size_t); // deprecated +string operator ""_i18n(const char*, std::size_t); // preferred +@end smallexample + @opindex Welaborated-enum-base @opindex Wno-elaborated-enum-base @item -Wno-elaborated-enum-base diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 77fe1b02bd2..9d1fccadbf9 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -664,6 +664,10 @@ C++ ObjC++ Var(warn_deprecated_enum_float_conv) Warning Warn about deprecated arithmetic conversions on operands where one is of enumeration type and the other is of a floating-point type. +Wdeprecated-literal-operator +C++ ObjC++ Var(warn_deprecated_literal_operator) Warning +Warn about deprecated space between "" and suffix in a user-defined literal operator. + Wdesignated-init C ObjC Var(warn_designated_init) Init(1) Warning Warn about positional initialization of structs requiring designated initializers. diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h b/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h index c8725fa9f46..529d5b7e6dc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h @@ -5,24 +5,24 @@ inline namespace my_string_literals { std::string - operator"" s(const char* str, std::size_t len) + operator ""s(const char* str, std::size_t len) { return std::string{str, len}; } #if __cpp_lib_char8_t std::u8string - operator"" s(const char8_t* str, std::size_t len) + operator ""s(const char8_t* str, std::size_t len) { return std::u8string{str, len}; } #endif std::wstring - operator"" s(const wchar_t* str, std::size_t len) + operator ""s(const wchar_t* str, std::size_t len) { return std::wstring{str, len}; } std::u16string - operator"" s(const char16_t* str, std::size_t len) + operator ""s(const char16_t* str, std::size_t len) { return std::u16string{str, len}; } std::u32string - operator"" s(const char32_t* str, std::size_t len) + operator ""s(const char32_t* str, std::size_t len) { return std::u32string{str, len}; } } diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 86163ddb4ed..8ff3d966bb6 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1016,6 +1016,11 @@ c_common_post_options (const char **pfilename) warn_deprecated_enum_float_conv, cxx_dialect >= cxx20 && warn_deprecated); + /* -Wdeprecated-literal-operator is enabled by default in C++23. */ + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + warn_deprecated_literal_operator, + cxx_dialect >= cxx23 && warn_deprecated); + /* -Wtemplate-id-cdtor is enabled by default in C++20. */ SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_template_id_cdtor, diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 0944827d777..08f9c89f1f0 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -943,6 +943,18 @@ make_location (cp_token *caret, cp_token *start, cp_token *end) return make_location (caret->location, start->location, end->location); } +/* Location for the whitespace between two tokens. */ + +static location_t +location_between (cp_token *stok, cp_token *etok) +{ + location_t s = get_finish (stok->location); + s = linemap_position_for_loc_and_offset (line_table, s, 1); + location_t e = get_start (etok->location); + e = linemap_position_for_loc_and_offset (line_table, e, -1); + return make_location (s, s, e); +} + /* nonzero if we are presently saving tokens. */ static inline int @@ -18325,6 +18337,8 @@ cp_parser_operator (cp_parser* parser, location_t start_loc) if (cxx_dialect == cxx98) maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS); + token = cp_lexer_peek_token (parser->lexer); + /* Consume the string. */ cp_expr str = cp_parser_userdef_string_literal (parser, /*lookup_udlit=*/false); @@ -18340,13 +18354,24 @@ cp_parser_operator (cp_parser* parser, location_t start_loc) { string_tree = str; /* Look for the suffix identifier. */ - token = cp_lexer_peek_token (parser->lexer); - if (token->type == CPP_NAME) + cp_token *id_tok = cp_lexer_peek_token (parser->lexer); + if (id_tok->type == CPP_NAME) { id = cp_parser_identifier (parser); - end_loc = token->location; + end_loc = id_tok->location; + + /* Deprecated by CWG2521 in C++23. */ + if (warn_deprecated_literal_operator) + { + gcc_rich_location + space (location_between (token, id_tok)); + space.add_fixit_remove (); + warning_at (&space, OPT_Wdeprecated_literal_operator, + "space between quotes and suffix is " + "deprecated in C++23"); + } } - else if (token->type == CPP_KEYWORD) + else if (id_tok->type == CPP_KEYWORD) { error ("unexpected keyword;" " remove space between quotes and suffix identifier"); diff --git a/gcc/testsuite/g++.dg/DRs/dr2521.C b/gcc/testsuite/g++.dg/DRs/dr2521.C new file mode 100644 index 00000000000..bce70421bd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2521.C @@ -0,0 +1,5 @@ +// CWG2521 +// { dg-do compile { target c++11 } } + +void operator "" _foo(const char *); // { dg-warning "deprecated" "" { target c++23 } } +void operator ""_bar(const char *); diff --git a/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C index 129947d86b3..e93e2720662 100644 --- a/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C +++ b/gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C @@ -5,7 +5,8 @@ // Test "-Wno-literal-suffix" suppresses warnings on declaration without // leading underscore. -long double operator"" nounder(long double); // { dg-bogus "" } +long double operator"" nounder(long double); // { dg-bogus "reserved" } +// { dg-warning "space" "" { target c++23 } .-1 } template - int operator"" nounder(); // { dg-bogus "" } + int operator ""nounder(); // { dg-bogus "reserved" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C index ffbefbbac46..9d1bd196126 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C @@ -11,7 +11,7 @@ constexpr unsigned long long mymax(A && a,const B& b){ } template -constexpr long long operator"" _y() noexcept +constexpr long long operator ""_y() noexcept { return AA<1, mymax(1,2)>::val; // <-- crashes gcc // return mymax(1,2); // <-- compiles diff --git a/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C index 7a467a154b0..46bf419adb2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C +++ b/gcc/testsuite/g++.dg/cpp0x/gnu_fext-numeric-literals.C @@ -4,73 +4,73 @@ // Integer imaginary... constexpr unsigned long long -operator"" i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } } +operator ""i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } } { return 4 * n + 0; } constexpr unsigned long long -operator"" I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" } +operator ""I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" } { return 4 * n + 1; } constexpr unsigned long long -operator"" j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" } +operator ""j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" } { return 4 * n + 2; } constexpr unsigned long long -operator"" J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" } +operator ""J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" } { return 4 * n + 3; } // Floating-point imaginary... constexpr long double -operator"" i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } } +operator ""i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } } { return 4.0L * n + 0.0L; } constexpr long double -operator"" I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" } +operator ""I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" } { return 4.0L * n + 1.0L; } constexpr long double -operator"" j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" } +operator ""j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" } { return 4.0L * n + 2.0L; } constexpr long double -operator"" J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" } +operator ""J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" } { return 4.0L * n + 3.0L; } // Fixed-point... constexpr long double -operator"" k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" } +operator ""k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" } { return 4 * (n + 1) + 0; } constexpr long double -operator"" K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" } +operator ""K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" } { return 4 * (n + 1) + 1; } constexpr long double -operator"" r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" } +operator ""r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" } { return 4 * (n + 1) + 2; } constexpr long double -operator"" R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" } +operator ""R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" } { return 4 * (n + 1) + 3; } // Machine-defined... constexpr long double -operator"" w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" } +operator ""w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" } { return 4 * (n + 2) + 0; } constexpr long double -operator"" W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" } +operator ""W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" } { return 4 * (n + 2) + 1; } constexpr long double -operator"" q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" } +operator ""q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" } { return 4 * (n + 2) + 2; } constexpr long double -operator"" Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" } +operator ""Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" } { return 4 * (n + 2) + 3; } int diff --git a/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C index c738a484da6..7ee35d4c42c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C +++ b/gcc/testsuite/g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C @@ -4,73 +4,73 @@ // Integer imaginary... constexpr unsigned long long -operator"" i(unsigned long long n) +operator ""i(unsigned long long n) { return 4 * n + 0; } constexpr unsigned long long -operator"" I(unsigned long long n) +operator ""I(unsigned long long n) { return 4 * n + 1; } constexpr unsigned long long -operator"" j(unsigned long long n) +operator ""j(unsigned long long n) { return 4 * n + 2; } constexpr unsigned long long -operator"" J(unsigned long long n) +operator ""J(unsigned long long n) { return 4 * n + 3; } // Floating-point imaginary... constexpr long double -operator"" i(long double n) +operator ""i(long double n) { return 4.0L * n + 0.0L; } constexpr long double -operator"" I(long double n) +operator ""I(long double n) { return 4.0L * n + 1.0L; } constexpr long double -operator"" j(long double n) +operator ""j(long double n) { return 4.0L * n + 2.0L; } constexpr long double -operator"" J(long double n) +operator ""J(long double n) { return 4.0L * n + 3.0L; } // Fixed-point... constexpr long double -operator"" k(long double n) +operator ""k(long double n) { return 4 * (n + 1) + 0; } constexpr long double -operator"" K(long double n) +operator ""K(long double n) { return 4 * (n + 1) + 1; } constexpr long double -operator"" r(long double n) +operator ""r(long double n) { return 4 * (n + 1) + 2; } constexpr long double -operator"" R(long double n) +operator ""R(long double n) { return 4 * (n + 1) + 3; } // Machine-defined... constexpr long double -operator"" w(long double n) +operator ""w(long double n) { return 4 * (n + 2) + 0; } constexpr long double -operator"" W(long double n) +operator ""W(long double n) { return 4 * (n + 2) + 1; } constexpr long double -operator"" q(long double n) +operator ""q(long double n) { return 4 * (n + 2) + 2; } constexpr long double -operator"" Q(long double n) +operator ""Q(long double n) { return 4 * (n + 2) + 3; } int diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51420.C b/gcc/testsuite/g++.dg/cpp0x/pr51420.C index 1612cef9ee2..a06d62788cd 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr51420.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr51420.C @@ -4,9 +4,9 @@ void foo() { - float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" } + float x = operator ""_F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" } /* { dg-begin-multiline-output "" } - float x = operator"" _F(); + float x = operator ""_F(); ^~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C b/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C index 6c3ad0c9016..1d87207a106 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr60209-neg.C @@ -4,25 +4,25 @@ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473 void operator "" "boo" _ya(unsigned long long); // { dg-error "expected empty string after" } +// { dg-warning "space" "" { target c++23 } .-1 } void operator "" "boo"_ya(unsigned long long); // { dg-error "expected empty string after" } -void operator "" u"" _u(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } +void operator "" u""_u(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } -void operator u"" "" _v(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } +void operator u"" ""_v(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } -void operator U"" "" _w(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } +void operator U"" ""_w(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } -void operator L"" "" _x(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } +void operator L"" ""_x(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } -void operator u8"" "" _y(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } +void operator u8"" ""_y(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" } -void operator u"" L"" _z(unsigned long long); // { dg-error "concatenation of string literals with conflicting encoding prefixes" } +void operator u"" L""_z(unsigned long long); // { dg-error "concatenation of string literals with conflicting encoding prefixes" } +// { dg-error "invalid encoding prefix in literal operator" "invalid" { target *-*-* } .-1 } void operator ""_p ""_q(unsigned long long); // { dg-error "inconsistent user-defined literal suffixes" } void operator "" "" while(unsigned long long); // { dg-error "unexpected keyword; remove space between quotes and suffix identifier" } void operator "" ""(unsigned long long); // { dg-error "expected suffix identifier" } - -// { dg-error "invalid encoding prefix in literal operator" "invalid" { target *-*-* } 20 } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60209.C b/gcc/testsuite/g++.dg/cpp0x/pr60209.C index 6ed26e9bcc6..2ecb7ed0c82 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr60209.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr60209.C @@ -4,8 +4,10 @@ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473 void operator "" "" _x(unsigned long long); +// { dg-warning "space" "" { target c++23 } .-1 } void operator "" "" "" _x(unsigned long long); +// { dg-warning "space" "" { target c++23 } .-1 } void operator "" ""_w(unsigned long long); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr61038.C b/gcc/testsuite/g++.dg/cpp0x/pr61038.C index 96aabe554b8..3030defe94d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr61038.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr61038.C @@ -6,11 +6,11 @@ #include void -operator "" _s(const char *, size_t) +operator ""_s(const char *, size_t) { } void -operator "" _t(const char) +operator ""_t(const char) { } #define QUOTE(s) #s diff --git a/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C index d251c744999..192383d104a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C +++ b/gcc/testsuite/g++.dg/cpp0x/std_fext-numeric-literals.C @@ -4,73 +4,73 @@ // Integer imaginary... constexpr unsigned long long -operator"" i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } } +operator ""i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } } { return 4 * n + 0; } constexpr unsigned long long -operator"" I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" } +operator ""I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" } { return 4 * n + 1; } constexpr unsigned long long -operator"" j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" } +operator ""j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" } { return 4 * n + 2; } constexpr unsigned long long -operator"" J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" } +operator ""J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" } { return 4 * n + 3; } // Floating-point imaginary... constexpr long double -operator"" i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } } +operator ""i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } } { return 4.0L * n + 0.0L; } constexpr long double -operator"" I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" } +operator ""I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" } { return 4.0L * n + 1.0L; } constexpr long double -operator"" j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" } +operator ""j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" } { return 4.0L * n + 2.0L; } constexpr long double -operator"" J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" } +operator ""J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" } { return 4.0L * n + 3.0L; } // Fixed-point... constexpr long double -operator"" k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" } +operator ""k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" } { return 4 * (n + 1) + 0; } constexpr long double -operator"" K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" } +operator ""K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" } { return 4 * (n + 1) + 1; } constexpr long double -operator"" r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" } +operator ""r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" } { return 4 * (n + 1) + 2; } constexpr long double -operator"" R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" } +operator ""R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" } { return 4 * (n + 1) + 3; } // Machine-defined... constexpr long double -operator"" w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" } +operator ""w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" } { return 4 * (n + 2) + 0; } constexpr long double -operator"" W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" } +operator ""W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" } { return 4 * (n + 2) + 1; } constexpr long double -operator"" q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" } +operator ""q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" } { return 4 * (n + 2) + 2; } constexpr long double -operator"" Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" } +operator ""Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" } { return 4 * (n + 2) + 3; } int diff --git a/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C b/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C index b4f9d457d98..23b988ea6b5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C +++ b/gcc/testsuite/g++.dg/cpp0x/std_fno-ext-numeric-literals.C @@ -4,73 +4,73 @@ // Integer imaginary... constexpr unsigned long long -operator"" i(unsigned long long n) +operator ""i(unsigned long long n) { return 4 * n + 0; } constexpr unsigned long long -operator"" I(unsigned long long n) +operator ""I(unsigned long long n) { return 4 * n + 1; } constexpr unsigned long long -operator"" j(unsigned long long n) +operator ""j(unsigned long long n) { return 4 * n + 2; } constexpr unsigned long long -operator"" J(unsigned long long n) +operator ""J(unsigned long long n) { return 4 * n + 3; } // Floating-point imaginary... constexpr long double -operator"" i(long double n) +operator ""i(long double n) { return 4.0L * n + 0.0L; } constexpr long double -operator"" I(long double n) +operator ""I(long double n) { return 4.0L * n + 1.0L; } constexpr long double -operator"" j(long double n) +operator ""j(long double n) { return 4.0L * n + 2.0L; } constexpr long double -operator"" J(long double n) +operator ""J(long double n) { return 4.0L * n + 3.0L; } // Fixed-point... constexpr long double -operator"" k(long double n) +operator ""k(long double n) { return 4 * (n + 1) + 0; } constexpr long double -operator"" K(long double n) +operator ""K(long double n) { return 4 * (n + 1) + 1; } constexpr long double -operator"" r(long double n) +operator ""r(long double n) { return 4 * (n + 1) + 2; } constexpr long double -operator"" R(long double n) +operator ""R(long double n) { return 4 * (n + 1) + 3; } // Machine-defined... constexpr long double -operator"" w(long double n) +operator ""w(long double n) { return 4 * (n + 2) + 0; } constexpr long double -operator"" W(long double n) +operator ""W(long double n) { return 4 * (n + 2) + 1; } constexpr long double -operator"" q(long double n) +operator ""q(long double n) { return 4 * (n + 2) + 2; } constexpr long double -operator"" Q(long double n) +operator ""Q(long double n) { return 4 * (n + 2) + 3; } int diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-addr.C b/gcc/testsuite/g++.dg/cpp0x/udlit-addr.C index 11389bfbc28..3c62524f1d6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-addr.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-addr.C @@ -2,9 +2,9 @@ #include -bool operator"" _yn(const char*, size_t); +bool operator ""_yn(const char*, size_t); typedef bool (*pfunk)(const char*, size_t); -pfunk p = &operator"" _yn; +pfunk p = &operator ""_yn; bool tf = p("Hello,\0 World!", 14); diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-args-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-args-neg.C index b22fddd0403..72cb4b4c4cb 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-args-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-args-neg.C @@ -5,37 +5,37 @@ class Foo { }; int -operator"" _Foo(); // { dg-error "1:.int operator\"\"_Foo\\(\\). has invalid argument list" } +operator ""_Foo(); // { dg-error "1:.int operator\"\"_Foo\\(\\). has invalid argument list" } Foo -operator"" _Foo(int *); // { dg-error "1:.Foo operator\"\"_Foo\\(int\\*\\). has invalid argument list" } +operator ""_Foo(int *); // { dg-error "1:.Foo operator\"\"_Foo\\(int\\*\\). has invalid argument list" } Foo -operator"" _Foo(unsigned long int); // { dg-error "1:.Foo operator\"\"_Foo\\(long unsigned int\\). has invalid argument list" } +operator ""_Foo(unsigned long int); // { dg-error "1:.Foo operator\"\"_Foo\\(long unsigned int\\). has invalid argument list" } Foo -operator"" _Foo(double); // { dg-error "1:.Foo operator\"\"_Foo\\(double\\). has invalid argument list" } +operator ""_Foo(double); // { dg-error "1:.Foo operator\"\"_Foo\\(double\\). has invalid argument list" } Foo -operator"" _Foo(const float *, std::size_t); // { dg-error "1:.Foo operator\"\"_Foo\\(const float\\*, std::size_t\\). has invalid argument list" } +operator ""_Foo(const float *, std::size_t); // { dg-error "1:.Foo operator\"\"_Foo\\(const float\\*, std::size_t\\). has invalid argument list" } Foo -operator"" _Foo(const wchar_t *, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const wchar_t\\*, int\\). has invalid argument list" } +operator ""_Foo(const wchar_t *, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const wchar_t\\*, int\\). has invalid argument list" } Foo -operator"" _Foo(const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(const char16_t\\*\\). has invalid argument list" } +operator ""_Foo(const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(const char16_t\\*\\). has invalid argument list" } Foo -operator"" _Foo(char...); // { dg-error "1:.Foo operator\"\"_Foo\\(char, \\.\\.\\.\\). has invalid argument list" } +operator ""_Foo(char...); // { dg-error "1:.Foo operator\"\"_Foo\\(char, \\.\\.\\.\\). has invalid argument list" } Foo -operator"" _Foo(unsigned long long int, char); // { dg-error "1:.Foo operator\"\"_Foo\\(long long unsigned int, char\\). has invalid argument list" } +operator ""_Foo(unsigned long long int, char); // { dg-error "1:.Foo operator\"\"_Foo\\(long long unsigned int, char\\). has invalid argument list" } Foo -operator"" _Foo(const char *, std::size_t, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const char\\*, std::size_t, int\\). has invalid argument list" } +operator ""_Foo(const char *, std::size_t, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const char\\*, std::size_t, int\\). has invalid argument list" } Foo -operator"" _Foo(long double &); // { dg-error "1:.Foo operator\"\"_Foo\\(long double&\\). has invalid argument list" } +operator ""_Foo(long double &); // { dg-error "1:.Foo operator\"\"_Foo\\(long double&\\). has invalid argument list" } Foo -operator"" _Foo(std::size_t, const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(std::size_t, const char16_t\\*\\). has invalid argument list" } +operator ""_Foo(std::size_t, const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(std::size_t, const char16_t\\*\\). has invalid argument list" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-args.C b/gcc/testsuite/g++.dg/cpp0x/udlit-args.C index 4680288d20c..2c1058ec344 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-args.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-args.C @@ -5,34 +5,34 @@ class Foo { }; Foo -operator"" _Foo(const char *); +operator ""_Foo(const char *); Foo -operator"" _Foo(unsigned long long int); +operator ""_Foo(unsigned long long int); Foo -operator"" _Foo(long double); +operator ""_Foo(long double); Foo -operator"" _Foo(char); +operator ""_Foo(char); Foo -operator"" _Foo(wchar_t); +operator ""_Foo(wchar_t); Foo -operator"" _Foo(char16_t); +operator ""_Foo(char16_t); Foo -operator"" _Foo(char32_t); +operator ""_Foo(char32_t); Foo -operator"" _Foo(const char *, std::size_t); +operator ""_Foo(const char *, std::size_t); Foo -operator"" _Foo(const wchar_t *, std::size_t); +operator ""_Foo(const wchar_t *, std::size_t); Foo -operator"" _Foo(const char16_t *, std::size_t); +operator ""_Foo(const char16_t *, std::size_t); Foo -operator"" _Foo(const char32_t *, std::size_t); +operator ""_Foo(const char32_t *, std::size_t); diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C b/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C index b9cb8e093a9..faf6ca533ff 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C @@ -3,12 +3,12 @@ #include -int operator "" _a (const char *); -int operator "" _a (const char *, std::size_t); +int operator ""_a (const char *); +int operator ""_a (const char *, std::size_t); int a = 123_a; int a2 = "abc"_a; -int operator "" _b (const char *, std::size_t); -int operator "" _b (const char *); +int operator ""_b (const char *, std::size_t); +int operator ""_b (const char *); int b = 123_b; int b2 = "abc"_b; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-clink-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-clink-neg.C index eb7ae8c0b17..f20b755b715 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-clink-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-clink-neg.C @@ -3,6 +3,6 @@ extern "C" { int -operator"" _badclinkage(unsigned long long); // { dg-error "1:literal operator with C linkage" } +operator ""_badclinkage(unsigned long long); // { dg-error "1:literal operator with C linkage" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-concat-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-concat-neg.C index 95d49271b81..4b7e33d80fc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-concat-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-concat-neg.C @@ -3,8 +3,8 @@ #include -std::string operator"" _xxx(const char*, size_t); +std::string operator ""_xxx(const char*, size_t); -std::string operator"" _yyy(const char*, size_t); +std::string operator ""_yyy(const char*, size_t); std::string concat = "Hello, "_xxx "World!"_yyy; // { dg-error "inconsistent user-defined literal suffixes" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-concat.C b/gcc/testsuite/g++.dg/cpp0x/udlit-concat.C index 208aaeea55d..b513e738ab9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-concat.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-concat.C @@ -3,7 +3,7 @@ #include -std::string operator"" _www(const char*, size_t); +std::string operator ""_www(const char*, size_t); std::string concat01 = "Hello, " "World!"_www; @@ -14,9 +14,9 @@ std::string concat11 = "Hello, "_www "World!"_www; class Tachyon { }; -Tachyon operator"" _fast(const char*, size_t); +Tachyon operator ""_fast(const char*, size_t); -int operator"" _fast(const char32_t*, size_t); +int operator ""_fast(const char32_t*, size_t); int speedy01 = "Hello, " U"World!"_fast; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-constexpr.C b/gcc/testsuite/g++.dg/cpp0x/udlit-constexpr.C index 4c2f7eda371..f91bf147eb1 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-constexpr.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-constexpr.C @@ -1,7 +1,7 @@ // { dg-do compile { target c++11 } } constexpr unsigned long long -operator"" _grow(unsigned long long n) +operator ""_grow(unsigned long long n) { return 2 * n; } double buffer[25_grow]; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-cpp98-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-cpp98-neg.C index cb4c359658c..a68505d62a2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-cpp98-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-cpp98-neg.C @@ -3,13 +3,13 @@ #include int -operator"" _mm(long double m) // { dg-warning "user-defined literals only available with" } +operator ""_mm(long double m) // { dg-warning "user-defined literals only available with" } { return int(1000.0L * m); } int in = 0.0254_mm; // { dg-error "invalid suffix" } int -operator"" _Q(const char *, std::size_t) // { dg-warning "user-defined literals only available with" } +operator ""_Q(const char *, std::size_t) // { dg-warning "user-defined literals only available with" } { return 42; } int x = "Hello"_Q; // { dg-error "invalid conversion from" "invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-declare-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-declare-neg.C index 721f87d4e66..7d06e42c4dc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-declare-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-declare-neg.C @@ -2,14 +2,14 @@ // Check that undeclared literal operator calls and literals give appropriate errors. -int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" } +int i = operator ""_Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" } int j = 'x'_Bar; // { dg-error "unable to find character literal operator|with|argument" } -int ii = operator"" _BarCharStr("Howdy, Pardner!"); // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" } +int ii = operator ""_BarCharStr("Howdy, Pardner!"); // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" } int jj = "Howdy, Pardner!"_BarCharStr; // { dg-error "unable to find string literal operator|Possible missing length argument" } -unsigned long long iULL = operator"" _BarULL(666ULL); // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" } +unsigned long long iULL = operator ""_BarULL(666ULL); // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" } unsigned long long jULL = 666_BarULL; // { dg-error "unable to find numeric literal operator" } -long double iLD = operator"" _BarLD(666.0L); // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" } +long double iLD = operator ""_BarLD(666.0L); // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" } long double jLD = 666.0_BarLD; // { dg-error "unable to find numeric literal operator" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-embed-quote.C b/gcc/testsuite/g++.dg/cpp0x/udlit-embed-quote.C index 27f7c990a12..ddadef48a92 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-embed-quote.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-embed-quote.C @@ -6,10 +6,10 @@ #include #include -int operator"" _embedchar(char) +int operator ""_embedchar(char) { return 41; } -int operator"" _embedstr(const char*, std::size_t len) +int operator ""_embedstr(const char*, std::size_t len) { return 42 + len; } void diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-1.C b/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-1.C index e9373e563d9..29a5e92938f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-1.C @@ -1,5 +1,5 @@ // { dg-do run { target c++11 } } -// { dg-additional-options "-Wno-error=normalized" } +// { dg-additional-options "-Wno-error=normalized -Wno-deprecated-literal-operator" } // { dg-require-effective-target ucn } // { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } } @@ -7,7 +7,7 @@ #include using namespace std; -constexpr unsigned long long operator "" _π (unsigned long long x) +constexpr unsigned long long operator ""_π (unsigned long long x) { return 3 * x; } @@ -25,7 +25,7 @@ char x2[2_Π2]; static_assert (sizeof x1 == 3, "test1"); static_assert (sizeof x2 == 8, "test2"); -const char * operator "" _1σ (const char *s, size_t) +const char * operator ""_1σ (const char *s, size_t) { return s + 1; } @@ -35,7 +35,7 @@ const char * operator ""_Σ2 (const char *s, size_t) return s + 2; } -const char * operator "" _\U000000e61 (const char *s, size_t) +const char * operator ""_\U000000e61 (const char *s, size_t) { return "ae"; } @@ -45,7 +45,7 @@ const char* operator ""_\u01532 (const char *s, size_t) return "oe"; } -bool operator "" _\u0BC7\u0BBE (unsigned long long); // { dg-warning "not in NFC" } +bool operator ""_\u0BC7\u0BBE (unsigned long long); // { dg-warning "not in NFC" } bool operator ""_\u0B47\U00000B3E (unsigned long long); // { dg-warning "not in NFC" } #define xτy diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-3.C b/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-3.C index cb8a957947a..e3d92857b3b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-3.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-extended-id-3.C @@ -14,4 +14,5 @@ const char *x = "hbar"_ħ; // { dg-bogus "poisoned" } syntax has been deprecated for C++23. */ #pragma GCC poison _ħ2 const char * operator "" _ħ2 (const char *, size_t); // { dg-bogus "poisoned" "" { xfail *-*-*} } +// { dg-warning "space" "" { target c++23 } .-1 } const char *x2 = "hbar2"_ħ2; // { dg-bogus "poisoned" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-extern-c.C b/gcc/testsuite/g++.dg/cpp0x/udlit-extern-c.C index 7a38e12dcd0..a0eed21f24f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-extern-c.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-extern-c.C @@ -2,6 +2,6 @@ extern "C" { // { dg-message "1: 'extern .C.' linkage started here" } -constexpr double operator"" _deg ( double degrees ); // { dg-error "18:literal operator with C linkage" } +constexpr double operator ""_deg ( double degrees ); // { dg-error "18:literal operator with C linkage" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-friend.C b/gcc/testsuite/g++.dg/cpp0x/udlit-friend.C index 54d7b7a1f11..235dfc9b25d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-friend.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-friend.C @@ -1,28 +1,28 @@ // { dg-do compile { target c++11 } } long double -operator"" _Hertz(long double); +operator ""_Hertz(long double); class Foo { public: Foo() { } - friend Foo operator"" _Bar(char); + friend Foo operator ""_Bar(char); friend long double - operator"" _Hertz(long double omega) + operator ""_Hertz(long double omega) { return omega / 6.28318530717958648; } }; Foo -operator"" _Bar(char) +operator ""_Bar(char) { return Foo(); } -Foo f1 = operator"" _Bar('x'); +Foo f1 = operator ""_Bar('x'); Foo f2 = 'x'_Bar; -long double fm1 = operator"" _Hertz(552.92L); +long double fm1 = operator ""_Hertz(552.92L); long double fm2 = 552.92_Hertz; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-general.C b/gcc/testsuite/g++.dg/cpp0x/udlit-general.C index 28732d86212..7e5bfd0a275 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-general.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-general.C @@ -9,27 +9,27 @@ #include #include -long double operator"" _v(long double); -std::string operator"" _w(const char16_t*, size_t); -unsigned operator"" _w(const char*); +long double operator ""_v(long double); +std::string operator ""_w(const char16_t*, size_t); +unsigned operator ""_w(const char*); std::complex -operator"" _i(long double y) +operator ""_i(long double y) { return std::complex(0.0L, y); } void test1() { - long double x = operator"" _v(1.2L); + long double x = operator ""_v(1.2L); assert(x == 2.2L); - std::string s = operator"" _w(u"one", 3); + std::string s = operator ""_w(u"one", 3); assert(s == "boo"); - unsigned u = operator"" _w("Hello, World!"); + unsigned u = operator ""_w("Hello, World!"); assert(u == 13U); - std::complex i = operator"" _i(2.0); + std::complex i = operator ""_i(2.0); assert(i == std::complex(0.0, 2.0)); } @@ -40,13 +40,13 @@ main() } long double -operator"" _v(long double x) +operator ""_v(long double x) { return x + 1.0L; } std::string -operator"" _w(const char16_t*, size_t) +operator ""_w(const char16_t*, size_t) { return std::string("boo"); } unsigned -operator"" _w(const char* str) +operator ""_w(const char* str) { return strlen(str); } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C b/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C index b917b5f6b90..a224c1094e5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C @@ -2,23 +2,23 @@ #include -int operator"" _bar (long double); +int operator ""_bar (long double); -double operator"" _foo (long long unsigned); +double operator ""_foo (long long unsigned); int i = 12_bar; // { dg-error "unable to find numeric literal operator|with|argument" } double d = 1.2_foo; // { dg-error "unable to find numeric literal operator|with|argument" } -int operator"" _char(char); +int operator ""_char(char); -int operator"" _char8_t(char8_t); +int operator ""_char8_t(char8_t); -int operator"" _wchar_t(wchar_t); +int operator ""_wchar_t(wchar_t); -int operator"" _char16_t(char16_t); +int operator ""_char16_t(char16_t); -int operator"" _char32_t(char32_t); +int operator ""_char32_t(char32_t); int cwcx = 'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" } int cc8 = 'c'_char8_t; // { dg-error "unable to find character literal operator|with|argument" } @@ -45,15 +45,15 @@ int c32c8 = U'c'_char8_t; // { dg-error "unable to find character literal operat int c32wc = U'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" } int c32c16 = U'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" } -int operator"" _char_str(const char*, std::size_t); +int operator ""_char_str(const char*, std::size_t); -int operator"" _wchar_t_str(const wchar_t*, std::size_t); +int operator ""_wchar_t_str(const wchar_t*, std::size_t); -int operator"" _char8_t_str(const char8_t*, std::size_t); +int operator ""_char8_t_str(const char8_t*, std::size_t); -int operator"" _char16_t_str(const char16_t*, std::size_t); +int operator ""_char16_t_str(const char16_t*, std::size_t); -int operator"" _char32_t_str(const char32_t*, std::size_t); +int operator ""_char32_t_str(const char32_t*, std::size_t); int strwstr = "str"_wchar_t_str; // { dg-error "unable to find string literal operator|with|arguments" } int strstr8 = "str"_char8_t_str; // { dg-error "unable to find string literal operator|with|arguments" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg.C index ea6095d14e9..92eae54372b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg.C @@ -2,21 +2,21 @@ #include -int operator"" _bar (long double); +int operator ""_bar (long double); -double operator"" _foo (long long unsigned); +double operator ""_foo (long long unsigned); int i = 12_bar; // { dg-error "unable to find numeric literal operator|with|argument" } double d = 1.2_foo; // { dg-error "unable to find numeric literal operator|with|argument" } -int operator"" _char(char); +int operator ""_char(char); -int operator"" _wchar_t(wchar_t); +int operator ""_wchar_t(wchar_t); -int operator"" _char16_t(char16_t); +int operator ""_char16_t(char16_t); -int operator"" _char32_t(char32_t); +int operator ""_char32_t(char32_t); int cwcx = 'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" } int cc16 = 'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" } @@ -34,13 +34,13 @@ int c32c = U'c'_char; // { dg-error "unable to find character literal operator|w int c32wc = U'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" } int c32c16 = U'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" } -int operator"" _char_str(const char*, std::size_t); +int operator ""_char_str(const char*, std::size_t); -int operator"" _wchar_t_str(const wchar_t*, std::size_t); +int operator ""_wchar_t_str(const wchar_t*, std::size_t); -int operator"" _char16_t_str(const char16_t*, std::size_t); +int operator ""_char16_t_str(const char16_t*, std::size_t); -int operator"" _char32_t_str(const char32_t*, std::size_t); +int operator ""_char32_t_str(const char32_t*, std::size_t); int strwstr = "str"_wchar_t_str; // { dg-error "unable to find string literal operator|with|arguments" } int strstr16 = "str"_char16_t_str; // { dg-error "unable to find string literal operator|with|arguments" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-inline.C b/gcc/testsuite/g++.dg/cpp0x/udlit-inline.C index fd8b9a05b38..4092d071bf2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-inline.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-inline.C @@ -3,20 +3,20 @@ // Literal operators can be inline. inline int -operator"" _thing1(char cc) +operator ""_thing1(char cc) { return 42 * cc; } -int operator"" _thing2(char cc); +int operator ""_thing2(char cc); class Foo { int - friend operator"" _thing2(char cc) + friend operator ""_thing2(char cc) { return 42 * cc; } }; -int i = operator"" _thing1('x'); +int i = operator ""_thing1('x'); int j = 'x'_thing1; -int iF = operator"" _thing2('x'); +int iF = operator ""_thing2('x'); int jF = 'x'_thing2; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C b/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C index 8840dcdce28..94143a1a0cd 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C @@ -2,7 +2,7 @@ // { dg-do compile { target c++11 } } // { dg-final { scan-assembler "_Zli2_wPKc" } } -int operator "" _w(const char*); +int operator ""_w(const char*); int main() { 123_w; } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-member-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-member-neg.C index f2eef0f52a2..4b69a27ff1d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-member-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-member-neg.C @@ -4,12 +4,12 @@ class Foo { public: Foo() { } - int operator"" _Bar(char32_t); // { dg-error "7:.int Foo::operator\"\"_Bar\\(char32_t\\). must be a non-member function" } + int operator ""_Bar(char32_t); // { dg-error "7:.int Foo::operator\"\"_Bar\\(char32_t\\). must be a non-member function" } }; -int i = operator"" _Bar(U'x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" } +int i = operator ""_Bar(U'x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" } int j = U'x'_Bar; // { dg-error "unable to find character literal operator" } int -Foo::operator"" _Bar(char32_t) // { dg-error "must be a non-member function" } +Foo::operator ""_Bar(char32_t) // { dg-error "must be a non-member function" } { return 42; } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-namespace.C b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace.C index a2e4e414319..fcaa41a4da8 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-namespace.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-namespace.C @@ -9,23 +9,23 @@ namespace Long { - long double operator"" _LL(long double); + long double operator ""_LL(long double); } namespace Short { short - operator"" _SS(long double x) + operator ""_SS(long double x) { return std::fmod(x, static_cast(std::numeric_limits::max())); } } void test1() { - long double x = Long::operator "" _LL(1.2L); + long double x = Long::operator ""_LL(1.2L); using namespace Short; - short s = operator"" _SS(1.2L); + short s = operator ""_SS(1.2L); short s2 = 1.2_SS; } @@ -38,6 +38,6 @@ main() namespace Long { long double - operator"" _LL(long double x) + operator ""_LL(long double x) { return x + 2.0L; } } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C index 861a77ce7bf..ae32d11dd95 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-nofunc-neg.C @@ -3,7 +3,7 @@ // Test user-defined literals. // Test error on non-function declaration. -double operator"" _baddecl; // { dg-error "8:declaration of .operator\"\"_baddecl. as non-function" } +double operator ""_baddecl; // { dg-error "8:declaration of .operator\"\"_baddecl. as non-function" } template - int operator"" _badtmpldecl; // { dg-error "7:declaration of .operator\"\"_badtmpldecl. as non-function" } + int operator ""_badtmpldecl; // { dg-error "7:declaration of .operator\"\"_badtmpldecl. as non-function" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-nonempty-str-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-nonempty-str-neg.C index ddaa1aa6c3e..06f5642ceaf 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-nonempty-str-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-nonempty-str-neg.C @@ -3,4 +3,4 @@ // Test user-defined literals. // Test error on non-empty string after 'operator' keyword. -double operator"hi" _badword(long double); // { dg-error "expected empty string after" } +double operator "hi"_badword(long double); // { dg-error "expected empty string after" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-nosuffix-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-nosuffix-neg.C index 790726fb71d..e89b9f5a689 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-nosuffix-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-nosuffix-neg.C @@ -1,5 +1,5 @@ // { dg-do compile { target c++11 } } char32_t -operator"" (char32_t C) // { dg-error "expected suffix identifier" } +operator ""(char32_t C) // { dg-error "expected suffix identifier" } { return C; } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-nounder-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-nounder-neg.C index 9120ae45dfa..21d6c475ef8 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-nounder-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-nounder-neg.C @@ -3,7 +3,7 @@ // Test user-defined literals. // Test warning on declaration without leading underscore. -long double operator"" nounder(long double); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" } +long double operator ""nounder(long double); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" } template - int operator"" nounder(); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" } + int operator ""nounder(); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-operator-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-operator-neg.C index d71f4a240e8..49761ca1631 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-operator-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-operator-neg.C @@ -3,40 +3,40 @@ // Can't have *both* literal operator template and raw literal operator. int -operator"" _abc(const char*) +operator ""_abc(const char*) { return 42; } template int - operator"" _abc() // { dg-error "literal operator template|conflicts with raw literal operator" } + operator ""_abc() // { dg-error "literal operator template|conflicts with raw literal operator" } { return 13; } template int - operator"" _def() + operator ""_def() { return 12; } int -operator"" _def(const char*) // { dg-error "raw literal operator|conflicts with literal operator template" } +operator ""_def(const char*) // { dg-error "raw literal operator|conflicts with literal operator template" } { return 43; } int -operator"" _ghi(long double) +operator ""_ghi(long double) { return 42; } template int - operator"" _ghi() // OK + operator ""_ghi() // OK { return 13; } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C index d7e5e4b1f99..93ed5379243 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C @@ -2,11 +2,11 @@ // { dg-options "-Woverflow" } // PR c++/52654 int -operator"" _w(unsigned long long) +operator ""_w(unsigned long long) { return 0; } int -operator"" _w(long double) +operator ""_w(long double) { return 0.0L; } int i = 12345678901234567890123456789012345678901234567890_w; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C b/gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C index 1b9888b7159..be4dddbb632 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C @@ -2,12 +2,12 @@ // PR c++/52654 int -operator"" _w(const char*) +operator ""_w(const char*) { return 0; } template int - operator"" _tw() + operator ""_tw() { return 0; } int i = 12345678901234567890123456789012345678901234567890_w; diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-preproc-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-preproc-neg.C index 64b6f8266bf..0ae90d9aaa1 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-preproc-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-preproc-neg.C @@ -1,7 +1,7 @@ // { dg-do compile { target c++11 } } int -operator"" _badpreproc(const char *str) +operator ""_badpreproc(const char *str) { return 0; } #if 123_badpreproc // { dg-error "user-defined literal in preprocessor expression" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C index 8969c96d8c1..73548409580 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-length.C @@ -16,7 +16,7 @@ cstrlen(const char* s) } constexpr size_type -operator "" _lenraw(const char* digits) +operator ""_lenraw(const char* digits) { return cstrlen(digits); } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op-string-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op-string-neg.C index be68333f509..76a0e556554 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op-string-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op-string-neg.C @@ -2,7 +2,7 @@ // Make sure handing a string to a raw literal generates a sensible error message. -int operator"" _embedraw(const char*) +int operator ""_embedraw(const char*) { return 41; } int k = "Boo!"_embedraw; // { dg-error "unable to find string literal operator" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C index 9f57ac56596..d49e42642c9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-op.C @@ -5,7 +5,7 @@ #include int -operator"" _raw_umber(const char * str) +operator ""_raw_umber(const char * str) { return strlen(str); } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-str.C b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-str.C index 1991de1150f..7e43a22345f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-raw-str.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-raw-str.C @@ -3,7 +3,7 @@ #include -std::string operator"" _i18n(const char*, std::size_t); +std::string operator ""_i18n(const char*, std::size_t); std::string vogon_poem = R"V0G0N( O freddled gruntbuggly thy micturations are to me diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve-char8_t.C b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve-char8_t.C index 5a264c24833..25d94c18845 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve-char8_t.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve-char8_t.C @@ -4,21 +4,21 @@ #include #include -int operator"" _foo(const char*) { return 0; } -int operator"" _foo(unsigned long long int) { return 1; } -int operator"" _foo(long double) { return 2; } -int operator"" _foo(char) { return 3; } -int operator"" _foo(wchar_t) { return 4; } -int operator"" _foo(char8_t) { return 5; } -int operator"" _foo(char16_t) { return 6; } -int operator"" _foo(char32_t) { return 7; } -int operator"" _foo(const char*, std::size_t) { return 8; } -int operator"" _foo(const wchar_t*, std::size_t) { return 9; } -int operator"" _foo(const char8_t*, std::size_t) { return 10; } -int operator"" _foo(const char16_t*, std::size_t) { return 11; } -int operator"" _foo(const char32_t*, std::size_t) { return 12; } -template int operator"" _foo2() { return 20; } -int operator"" _foo2(unsigned long long int) { return 21; } +int operator ""_foo(const char*) { return 0; } +int operator ""_foo(unsigned long long int) { return 1; } +int operator ""_foo(long double) { return 2; } +int operator ""_foo(char) { return 3; } +int operator ""_foo(wchar_t) { return 4; } +int operator ""_foo(char8_t) { return 5; } +int operator ""_foo(char16_t) { return 6; } +int operator ""_foo(char32_t) { return 7; } +int operator ""_foo(const char*, std::size_t) { return 8; } +int operator ""_foo(const wchar_t*, std::size_t) { return 9; } +int operator ""_foo(const char8_t*, std::size_t) { return 10; } +int operator ""_foo(const char16_t*, std::size_t) { return 11; } +int operator ""_foo(const char32_t*, std::size_t) { return 12; } +template int operator ""_foo2() { return 20; } +int operator ""_foo2(unsigned long long int) { return 21; } int main() diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C index c311cfb8db7..5496d5b583c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-resolve.C @@ -4,19 +4,19 @@ #include #include -int operator"" _foo(const char*) { return 0; } -int operator"" _foo(unsigned long long int) { return 1; } -int operator"" _foo(long double) { return 2; } -int operator"" _foo(char) { return 3; } -int operator"" _foo(wchar_t) { return 4; } -int operator"" _foo(char16_t) { return 5; } -int operator"" _foo(char32_t) { return 6; } -int operator"" _foo(const char*, std::size_t) { return 7; } -int operator"" _foo(const wchar_t*, std::size_t) { return 8; } -int operator"" _foo(const char16_t*, std::size_t) { return 9; } -int operator"" _foo(const char32_t*, std::size_t) { return 10; } -template int operator"" _foo2() { return 20; } -int operator"" _foo2(unsigned long long int) { return 21; } +int operator ""_foo(const char*) { return 0; } +int operator ""_foo(unsigned long long int) { return 1; } +int operator ""_foo(long double) { return 2; } +int operator ""_foo(char) { return 3; } +int operator ""_foo(wchar_t) { return 4; } +int operator ""_foo(char16_t) { return 5; } +int operator ""_foo(char32_t) { return 6; } +int operator ""_foo(const char*, std::size_t) { return 7; } +int operator ""_foo(const wchar_t*, std::size_t) { return 8; } +int operator ""_foo(const char16_t*, std::size_t) { return 9; } +int operator ""_foo(const char32_t*, std::size_t) { return 10; } +template int operator ""_foo2() { return 20; } +int operator ""_foo2(unsigned long long int) { return 21; } int main() diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-shadow-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-shadow-neg.C index a30ec0f4f7e..802d1224bed 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-shadow-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-shadow-neg.C @@ -2,43 +2,43 @@ // Test that the standard suffixes shadow any user-defined suffixes of the same name. long double -operator"" L(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" } +operator ""L(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" } { return x; } unsigned long long int -operator"" ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } long double -operator"" l(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" } +operator ""l(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" } { return x; } unsigned long long int -operator"" ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } // Namespaces are no hiding place. @@ -46,43 +46,43 @@ namespace Long { long double -operator"" L(long double x) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""L(long double x) // { dg-warning "integer suffix|shadowed by implementation" } { return x; } unsigned long long int -operator"" ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } long double -operator"" l(long double x) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""l(long double x) // { dg-warning "integer suffix|shadowed by implementation" } { return x; } unsigned long long int -operator"" ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } unsigned long long int -operator"" ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } +operator ""ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" } { return k; } } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-string-length.C b/gcc/testsuite/g++.dg/cpp0x/udlit-string-length.C index c76b0af9a28..34e3d3f4021 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-string-length.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-string-length.C @@ -4,33 +4,33 @@ typedef decltype(sizeof(0)) size_type; constexpr size_type -operator"" _len(const char*, size_type len) +operator ""_len(const char*, size_type len) { return len; } #if __cpp_char8_t constexpr size_type -operator"" _len(const char8_t*, size_type len) +operator ""_len(const char8_t*, size_type len) { return len; } #endif constexpr size_type -operator"" _len(const wchar_t*, size_type len) +operator ""_len(const wchar_t*, size_type len) { return len; } constexpr size_type -operator"" _len(const char16_t*, size_type len) +operator ""_len(const char16_t*, size_type len) { return len; } constexpr size_type -operator"" _len(const char32_t*, size_type len) +operator ""_len(const char32_t*, size_type len) { return len; } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-suffix-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-suffix-neg.C index 8f3cc87825a..f6b74fe45ea 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-suffix-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-suffix-neg.C @@ -3,4 +3,4 @@ #include -std::string operator"" 5X(const char*, std::size_t); // { dg-error "expected suffix identifier" } +std::string operator ""5X(const char*, std::size_t); // { dg-error "expected suffix identifier" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-template.C b/gcc/testsuite/g++.dg/cpp0x/udlit-template.C index b5306b9962f..b740ca7c1e2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-template.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-template.C @@ -7,32 +7,32 @@ #include template - int operator"" _abc(); + int operator ""_abc(); template<> int - operator"" _abc<>() + operator ""_abc<>() { return -1; } template<> int - operator"" _abc<'L','U','E'>() + operator ""_abc<'L','U','E'>() { return 42; } template<> int - operator"" _abc<'6','6','6'>() + operator ""_abc<'6','6','6'>() { return 21; } void test1() { - int i = operator"" _abc<'1','2','3'>(); + int i = operator ""_abc<'1','2','3'>(); assert(i == 45); - int universal_meaning = operator"" _abc<'L','U','E'>(); + int universal_meaning = operator ""_abc<'L','U','E'>(); assert(universal_meaning == 42); - int b = operator"" _abc<'6','6','6'>(); - int z = operator"" _abc<>(); + int b = operator ""_abc<'6','6','6'>(); + int z = operator ""_abc<>(); assert(z == -1); int j = 123_abc; assert(j == i); @@ -47,5 +47,5 @@ main() } template - int operator"" _abc() + int operator ""_abc() { return 42 + sizeof...(Chars); } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg.C index 678a53e3f4f..fa6ec4889ef 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg.C @@ -1,4 +1,4 @@ // { dg-do compile { target c++11 } } template - int operator"" _xyz(unsigned long long); // { dg-error "has invalid argument list" } + int operator ""_xyz(unsigned long long); // { dg-error "has invalid argument list" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C index f2db95d3ead..2aae8a1667b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C @@ -2,6 +2,6 @@ // { dg-do compile { target c++11 } } template // { dg-error "'T' has not been declared" } -int operator"" _foo (); // { dg-error "5:literal operator template .int operator\"\"_foo\\(\\). has invalid parameter list" } +int operator ""_foo (); // { dg-error "5:literal operator template .int operator\"\"_foo\\(\\). has invalid parameter list" } template // { dg-error "'T' has not been declared" } -int operator"" _bar (); // { dg-error "5:literal operator template .int operator\"\"_bar\\(\\). has invalid parameter list" } +int operator ""_bar (); // { dg-error "5:literal operator template .int operator\"\"_bar\\(\\). has invalid parameter list" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg.C index cec79a5ffb4..04752d4a96c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-arg.C @@ -1,4 +1,4 @@ // { dg-do compile { target c++11 } } template - int operator"" _abc(); + int operator ""_abc(); diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C index 167d871a005..33486fa7d60 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C @@ -3,10 +3,10 @@ class Foo { }; template - Foo operator"" _Foo(); // { dg-error "7:literal operator template .Foo operator\"\"_Foo\\(\\). has invalid parameter list" } + Foo operator ""_Foo(); // { dg-error "7:literal operator template .Foo operator\"\"_Foo\\(\\). has invalid parameter list" } template - Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" } + Foo operator ""_Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" } template - Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" } + Foo operator ""_Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" } diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms.C b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms.C index bc7eaf66fb9..c0b9a23f300 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-tmpl-parms.C @@ -3,4 +3,4 @@ class Foo { }; template - Foo operator"" _Foo(); + Foo operator ""_Foo(); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr57640.C b/gcc/testsuite/g++.dg/cpp1y/pr57640.C index 6a79ea239d6..f6400408047 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr57640.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr57640.C @@ -5,4 +5,4 @@ using namespace std::literals::chrono_literals; -auto blooper = operator"" min(45.0L); +auto blooper = operator ""min(45.0L); diff --git a/gcc/testsuite/g++.dg/cpp1y/pr88872.C b/gcc/testsuite/g++.dg/cpp1y/pr88872.C index 3719e395c0e..be856098418 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr88872.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr88872.C @@ -6,7 +6,7 @@ struct a { int c; }; void d(); -template constexpr a operator"" _n() { return d; } +template constexpr a operator ""_n() { return d; } struct e; struct f { e operator[](int); diff --git a/gcc/testsuite/g++.dg/cpp26/unevalstr1.C b/gcc/testsuite/g++.dg/cpp26/unevalstr1.C index 3220cf04937..5317d696de8 100644 --- a/gcc/testsuite/g++.dg/cpp26/unevalstr1.C +++ b/gcc/testsuite/g++.dg/cpp26/unevalstr1.C @@ -83,21 +83,21 @@ extern "\o{0103}" { int f14 (); } // { dg-error "numeric escape sequence in unev [[nodiscard ("\x{20}")]] int h19 (); // { dg-error "numeric escape sequence in unevaluated string" } [[nodiscard ("\h")]] int h20 (); // { dg-error "unknown escape sequence" } -float operator "" _my0 (const char *); -float operator "" "" _my1 (const char *); -float operator L"" _my2 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator u"" _my3 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator U"" _my4 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator u8"" _my5 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator L"" "" _my6 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator u"" "" _my7 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator U"" "" _my8 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator u8"" "" _my9 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator "" L"" _my10 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator "" u"" _my11 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator "" U"" _my12 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator "" u8"" _my13 (const char *); // { dg-error "invalid encoding prefix in literal operator" } -float operator "\0" _my14 (const char *); // { dg-error "expected empty string after 'operator' keyword" } -float operator "\x00" _my15 (const char *); // { dg-error "expected empty string after 'operator' keyword" } -float operator "\h" _my16 (const char *); // { dg-error "expected empty string after 'operator' keyword" } +float operator ""_my0 (const char *); +float operator "" ""_my1 (const char *); +float operator L""_my2 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator u""_my3 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator U""_my4 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator u8""_my5 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator L"" ""_my6 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator u"" ""_my7 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator U"" ""_my8 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator u8"" ""_my9 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator "" L""_my10 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator "" u""_my11 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator "" U""_my12 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator "" u8""_my13 (const char *); // { dg-error "invalid encoding prefix in literal operator" } +float operator "\0"_my14 (const char *); // { dg-error "expected empty string after 'operator' keyword" } +float operator "\x00"_my15 (const char *); // { dg-error "expected empty string after 'operator' keyword" } +float operator "\h"_my16 (const char *); // { dg-error "expected empty string after 'operator' keyword" } // { dg-error "unknown escape sequence" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr60391.C b/gcc/testsuite/g++.dg/cpp2a/concepts-pr60391.C index 5c5ca2c2381..0926d41d12e 100644 --- a/gcc/testsuite/g++.dg/cpp2a/concepts-pr60391.C +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr60391.C @@ -3,7 +3,7 @@ namespace N { - int operator"" _X(auto) {} // { dg-error "auto|invalid" } + int operator ""_X(auto) {} // { dg-error "auto|invalid" } } namespace N {} diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C b/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C index 36da1bd91f3..b081e3688a2 100644 --- a/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C +++ b/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C @@ -11,7 +11,7 @@ __uint128_t #else unsigned long long #endif -operator"" _c(const char*) { return 0; } +operator ""_c(const char*) { return 0; } constexpr char e() { long f = true ? 0 : b(long(1)); return b(f); diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class6.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class6.C index 377a151d343..af632be0055 100644 --- a/gcc/testsuite/g++.dg/cpp2a/nontype-class6.C +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class6.C @@ -11,7 +11,7 @@ struct A { // auto operator<=> (const A&) = default; }; -template constexpr A operator "" _sh() { return a; } +template constexpr A operator ""_sh() { return a; } constexpr auto a = "foo"_sh; static_assert (a.ar[0] == 'f'); diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C index b91e01ce0b3..6066255aaf8 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C @@ -16,7 +16,7 @@ struct fixed_string { // Missing deduction guide. template -constexpr std::size_t operator"" _udl() { +constexpr std::size_t operator ""_udl() { return decltype(fs)::length; } diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C index 067fdbac81e..8c36d700d93 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C @@ -17,4 +17,4 @@ template fixed_string(const CharT (&str)[N]) -> fixed_string; template -int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" } +int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" } diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad.C index e9421bc4072..cea52ba7bae 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-ctad.C @@ -17,7 +17,7 @@ template fixed_string(const CharT (&str)[N]) -> fixed_string; template -constexpr std::size_t operator"" _udl() { +constexpr std::size_t operator ""_udl() { return decltype(fs)::length; } diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg.C index 85b3fe7fc61..d45527a211d 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg.C @@ -9,4 +9,4 @@ struct literal_class { }; template -int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" } +int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" } diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg2.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg2.C index ab7c012f5f4..872829fcbd8 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg2.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg2.C @@ -10,4 +10,4 @@ struct non_literal_class { }; template // { dg-error "11:is not a valid type for a template non-type parameter because it is not structural" "" { target { ! implicit_constexpr } } } -int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" "" { target { ! implicit_constexpr } } } +int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" "" { target { ! implicit_constexpr } } } diff --git a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp.C b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp.C index b7ef79d68a0..b753d7dcc09 100644 --- a/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp.C +++ b/gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp.C @@ -9,7 +9,7 @@ struct literal_class { }; template -constexpr int operator"" _udl() { +constexpr int operator ""_udl() { return 1; } diff --git a/gcc/testsuite/g++.dg/ext/is_convertible2.C b/gcc/testsuite/g++.dg/ext/is_convertible2.C index 3dd90bdafb9..1e8425571f0 100644 --- a/gcc/testsuite/g++.dg/ext/is_convertible2.C +++ b/gcc/testsuite/g++.dg/ext/is_convertible2.C @@ -23,7 +23,7 @@ int main() SA(!__is_convertible(B*, C*)); SA(__is_convertible(A, E)); - using std::operator "" s, std::operator "" sv; + using std::operator ""s, std::operator ""sv; auto stringify = [](T x) { if constexpr (std::is_convertible_v or diff --git a/gcc/testsuite/g++.dg/lookup/pr87269.C b/gcc/testsuite/g++.dg/lookup/pr87269.C index 0c87ee5aef5..253bad1a14b 100644 --- a/gcc/testsuite/g++.dg/lookup/pr87269.C +++ b/gcc/testsuite/g++.dg/lookup/pr87269.C @@ -6,10 +6,10 @@ namespace std { } namespace { - void operator"" _a (const char *, std::size_t) {} + void operator ""_a (const char *, std::size_t) {} } -void operator"" _a (unsigned long long); +void operator ""_a (unsigned long long); template void f () { ""_a; } diff --git a/gcc/c-family/c.opt.urls b/gcc/c-family/c.opt.urls index 4cd9a75b950..b77575bc896 100644 --- a/gcc/c-family/c.opt.urls +++ b/gcc/c-family/c.opt.urls @@ -301,6 +301,9 @@ UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-enum-enum-conve Wdeprecated-enum-float-conversion UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-enum-float-conversion) +Wdeprecated-literal-operator +UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-literal-operator) + Wdesignated-init UrlSuffix(gcc/Warning-Options.html#index-Wdesignated-init) diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit_system_header b/gcc/testsuite/g++.dg/cpp0x/udlit_system_header index d541f24f62a..7bb54df8f89 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit_system_header +++ b/gcc/testsuite/g++.dg/cpp0x/udlit_system_header @@ -2,5 +2,5 @@ #pragma GCC system_header char -operator"" stdsuffix(char __c) +operator ""stdsuffix(char __c) { return __c/2; }