From patchwork Thu Aug 10 15:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 134044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp496430vqi; Thu, 10 Aug 2023 08:23:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGokupC15yy2RaIRF45vqFUV0jlpmbVm1d+Zm6iALSrDj+quoKdJetCCwQAVg5l/iyUobsp X-Received: by 2002:a17:906:3015:b0:974:1ef7:1e88 with SMTP id 21-20020a170906301500b009741ef71e88mr2290963ejz.13.1691681030439; Thu, 10 Aug 2023 08:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691681030; cv=none; d=google.com; s=arc-20160816; b=hElNitaFmCTvNx6dufIEpwj75CivauDKfyHXeuOp5wQdCCkNLnFDH6kVeKPUwHZ0gb kjx71xDSQDcm93EXrLgy6K/DIK00PLOpOlls1CN8ijnzfFsw4ypI1cVpMI5IQ9S/njqw N+A2obWFc4HjGFkllF+dTfbnZf6cqDEmnJWpZhBKSkHUc1b+CBGePjw6/Xu2oOh1kT5u sU6MbxNn+ZVsErPoKhXwLtnzQtyK6eI7hzpmgIv97Z6faO0KFNmVCZNPJ/btx6WgfMuZ jlMBU0L1YFDS2zh8pvZPuVAJZwRaxcK4ND6isDl1pwmOzXWglyzXggkFTk2AhfyOtU22 zG7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=gtP3RKnyp4G4aev3rZIbdpiEJLE8+cSmsvTLI8ZrN+U=; fh=eq/JEyrXtQDUwCKd8TMtL9cNlvb4il+xO4pyNMaZeK4=; b=0mgYJ+lpQWkOBM6kKntd82xlgWQXPEcJttUdSzuAFOyfvecZr8O0VdWvLvK4t2ymLh m75hyBd+rnl4Tc+VIjc+HiJu2uaZZDuMFxPYYMyQfSR7U05E6YSurOtcprL9gSAyFW0f EC5WJaZqBgr+4/8T0/dhbMaNmCRf5AwFynpvKs3meVNiWsxEM+7vYZNnthnqs4MD6nT5 ACLmNkAa3ol31nHqV1AhxNfx0ykFAfVizosWyBzMHdXK+x0642KVieDNJUzD514sfX8g jcCePqnXv0+PxdE9rDT3HI7UqMBnDFIMPOEfZXeMCOqgW+eXuSM+pEB8C0z4XiTC+bnu JdtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cwL5Fcgh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i22-20020a170906445600b0099238b86ef1si1752958ejp.164.2023.08.10.08.23.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 08:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cwL5Fcgh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 494763858298 for ; Thu, 10 Aug 2023 15:23:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 494763858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691681029; bh=gtP3RKnyp4G4aev3rZIbdpiEJLE8+cSmsvTLI8ZrN+U=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cwL5Fcgh52LlLz1F0+tePqcvuHAI+GAW/Kk8wfE/Z7GOfK+5LVLSsWph90PA9prEq R+YDt8djz4/Uq/85wId22ml0CZv5IsQlWRiRPPwrOr5Qt6hNXjT1UrL/gRDXugk7vT 0+gywpEgHBAOyUdHUy4h1bc/dYEkdoBwfDSq2ULU= 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 ESMTPS id 257813858D32 for ; Thu, 10 Aug 2023 15:23:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 257813858D32 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-155-MdORi-jxMliBOkugF13OGw-1; Thu, 10 Aug 2023 11:23:03 -0400 X-MC-Unique: MdORi-jxMliBOkugF13OGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0378B85CBEA; Thu, 10 Aug 2023 15:23:03 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.225.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1905140E96E; Thu, 10 Aug 2023 15:23:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 37AFN0Vd2355604 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 10 Aug 2023 17:23:00 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 37AFMxCI2355603; Thu, 10 Aug 2023 17:22:59 +0200 Date: Thu, 10 Aug 2023 17:22:59 +0200 To: Joseph Myers , gcc-patches@gcc.gnu.org Subject: [PATCH 13/12 v2] C _BitInt incremental fixes [PR102989] Message-ID: References: <696ce2b2-5ac2-8946-29de-d5dd4fb3aff2@codesourcery.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773836448512058588 X-GMAIL-MSGID: 1773856128029080812 On Thu, Aug 10, 2023 at 12:10:07PM +0200, Jakub Jelinek via Gcc-patches wrote: > Here is an incremental patch which does that: Bootstrap/regtest on i686-linux (next to x86_64-linux where it went fine) revealed I forgot to add { target bitint } to dg-do compile lines. Here is an updated patch which does that and passes even on i686-linux. 2023-08-10 Jakub Jelinek PR c/102989 gcc/c/ * c-decl.cc (finish_declspecs): Emit pedwarn_c11 on _BitInt. * c-typeck.cc (c_common_type): Emit sorry for common type between _Complex integer and larger _BitInt and return the _Complex integer. gcc/c-family/ * c-attribs.cc (type_valid_for_vector_size): Reject vector types with BITINT_TYPE elements even if they have mode precision and suitable size. gcc/testsuite/ * gcc.dg/bitint-19.c: New test. * gcc.dg/bitint-20.c: New test. * gcc.dg/bitint-21.c: New test. * gcc.dg/bitint-22.c: New test. * gcc.dg/bitint-23.c: New test. * gcc.dg/bitint-24.c: New test. * gcc.dg/bitint-25.c: New test. * gcc.dg/bitint-26.c: New test. * gcc.dg/bitint-27.c: New test. * g++.dg/ext/bitint1.C: New test. * g++.dg/ext/bitint2.C: New test. * g++.dg/ext/bitint3.C: New test. * g++.dg/ext/bitint4.C: New test. libcpp/ * expr.cc (cpp_classify_number): Diagnose wb literal suffixes for -pedantic* before C2X or -Wc11-c2x-compat. Jakub --- gcc/c/c-decl.cc.jj 2023-08-10 09:26:39.776509713 +0200 +++ gcc/c/c-decl.cc 2023-08-10 11:14:12.686238299 +0200 @@ -12933,8 +12933,15 @@ finish_declspecs (struct c_declspecs *sp if (specs->u.bitint_prec == -1) specs->type = integer_type_node; else - specs->type = build_bitint_type (specs->u.bitint_prec, - specs->unsigned_p); + { + pedwarn_c11 (specs->locations[cdw_typespec], OPT_Wpedantic, + "ISO C does not support %<%s_BitInt(%d)%> before C2X", + specs->unsigned_p ? "unsigned " + : specs->signed_p ? "signed " : "", + specs->u.bitint_prec); + specs->type = build_bitint_type (specs->u.bitint_prec, + specs->unsigned_p); + } break; default: gcc_unreachable (); --- gcc/c/c-typeck.cc.jj 2023-08-10 09:26:39.781509641 +0200 +++ gcc/c/c-typeck.cc 2023-08-10 10:03:00.722917789 +0200 @@ -819,6 +819,12 @@ c_common_type (tree t1, tree t2) return t1; else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype) return t2; + else if (TREE_CODE (subtype) == BITINT_TYPE) + { + sorry ("%<_Complex _BitInt(%d)%> unsupported", + TYPE_PRECISION (subtype)); + return code1 == COMPLEX_TYPE ? t1 : t2; + } else return build_complex_type (subtype); } --- gcc/c-family/c-attribs.cc.jj 2023-06-03 15:32:04.311412926 +0200 +++ gcc/c-family/c-attribs.cc 2023-08-10 10:07:05.222377604 +0200 @@ -4366,7 +4366,8 @@ type_valid_for_vector_size (tree type, t && GET_MODE_CLASS (orig_mode) != MODE_INT && !ALL_SCALAR_FIXED_POINT_MODE_P (orig_mode)) || !tree_fits_uhwi_p (TYPE_SIZE_UNIT (type)) - || TREE_CODE (type) == BOOLEAN_TYPE) + || TREE_CODE (type) == BOOLEAN_TYPE + || TREE_CODE (type) == BITINT_TYPE) { if (error_p) error ("invalid vector type for attribute %qE", atname); --- gcc/testsuite/gcc.dg/bitint-19.c.jj 2023-08-10 09:33:49.205287806 +0200 +++ gcc/testsuite/gcc.dg/bitint-19.c 2023-08-10 09:36:43.312765194 +0200 @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ - 1) bi = 0wb; + _BitInt(__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1) bl = 0wb; + static_assert (expr_has_type (ci + bi, _Complex int)); + static_assert (expr_has_type (cl + bl, _Complex long long)); + static_assert (expr_has_type (bi + ci, _Complex int)); + static_assert (expr_has_type (bl + cl, _Complex long long)); +} --- gcc/testsuite/gcc.dg/bitint-20.c.jj 2023-08-10 09:40:14.340707650 +0200 +++ gcc/testsuite/gcc.dg/bitint-20.c 2023-08-10 10:04:35.306548279 +0200 @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ + 1) bi = 0wb; + ci + bi; /* { dg-message "unsupported" } */ + bi + ci; /* { dg-message "unsupported" } */ +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) bw = 0wb; + cl + bw; /* { dg-message "unsupported" "" { target bitint575 } } */ + bw + cl; /* { dg-message "unsupported" "" { target bitint575 } } */ +#endif +} --- gcc/testsuite/gcc.dg/bitint-21.c.jj 2023-08-10 10:07:31.393998652 +0200 +++ gcc/testsuite/gcc.dg/bitint-21.c 2023-08-10 10:14:14.303164800 +0200 @@ -0,0 +1,11 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +#define IB __SIZEOF_INT__ * __CHAR_BIT__ +typedef _BitInt(IB) V1 __attribute__((vector_size (sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +typedef _BitInt(IB) V2 __attribute__((vector_size (8 * sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +#if __BITINT_MAXWIDTH__ >= 575 +typedef _BitInt(575) V3 __attribute__((vector_size (sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +typedef _BitInt(575) V3 __attribute__((vector_size (16 * sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +#endif --- gcc/testsuite/gcc.dg/bitint-22.c.jj 2023-08-10 11:51:51.975802981 +0200 +++ gcc/testsuite/gcc.dg/bitint-22.c 2023-08-10 11:52:16.923446548 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c2x -pedantic-errors" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif --- gcc/testsuite/gcc.dg/bitint-23.c.jj 2023-08-10 11:52:29.611265273 +0200 +++ gcc/testsuite/gcc.dg/bitint-23.c 2023-08-10 11:55:03.702063742 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } + +_BitInt(63) a; /* { dg-warning "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-warning "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-warning "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif --- gcc/testsuite/gcc.dg/bitint-24.c.jj 2023-08-10 11:56:03.403210774 +0200 +++ gcc/testsuite/gcc.dg/bitint-24.c 2023-08-10 11:56:13.037073138 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif --- gcc/testsuite/gcc.dg/bitint-25.c.jj 2023-08-10 11:56:21.499952227 +0200 +++ gcc/testsuite/gcc.dg/bitint-25.c 2023-08-10 11:56:36.468738364 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -Wno-c11-c2x-compat -pedantic-errors" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif --- gcc/testsuite/gcc.dg/bitint-26.c.jj 2023-08-10 11:56:56.423453266 +0200 +++ gcc/testsuite/gcc.dg/bitint-26.c 2023-08-10 11:57:41.335811588 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -pedantic" } + +_BitInt(63) a; /* { dg-warning "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-warning "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-warning "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif --- gcc/testsuite/gcc.dg/bitint-27.c.jj 2023-08-10 11:57:23.690063697 +0200 +++ gcc/testsuite/gcc.dg/bitint-27.c 2023-08-10 11:57:57.352582755 +0200 @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -pedantic-errors" } + +_BitInt(63) a; /* { dg-error "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-error "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-error "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif --- gcc/testsuite/g++.dg/ext/bitint1.C.jj 2023-08-10 10:42:33.884601671 +0200 +++ gcc/testsuite/g++.dg/ext/bitint1.C 2023-08-10 10:41:44.595312345 +0200 @@ -0,0 +1,9 @@ +// PR c/102989 +// { dg-do compile } + +_BitInt(63) a; // { dg-error "expected" } +unsigned _BitInt(31) b; // { dg-error "expected" } +int c = 21wb; // { dg-error "invalid suffix \"wb\" on integer constant" "" { target c++98_only } } + // { dg-error "unable to find numeric literal operator 'operator\"\"wb'" "" { target c++11 } .-1 } +long long d = 60594869054uwb; // { dg-error "invalid suffix \"uwb\" on integer constant" "" { target c++98_only } } + // { dg-error "unable to find numeric literal operator 'operator\"\"uwb'" "" { target c++11 } .-1 } --- gcc/testsuite/g++.dg/ext/bitint2.C.jj 2023-08-10 10:42:41.950485375 +0200 +++ gcc/testsuite/g++.dg/ext/bitint2.C 2023-08-10 10:42:57.033267905 +0200 @@ -0,0 +1,10 @@ +// PR c/102989 +// { dg-do compile } +// { dg-options "" } + +_BitInt(63) a; // { dg-error "expected" } +unsigned _BitInt(31) b; // { dg-error "expected" } +int c = 21wb; // { dg-error "invalid suffix \"wb\" on integer constant" "" { target c++98_only } } + // { dg-error "unable to find numeric literal operator 'operator\"\"wb'" "" { target c++11 } .-1 } +long long d = 60594869054uwb; // { dg-error "invalid suffix \"uwb\" on integer constant" "" { target c++98_only } } + // { dg-error "unable to find numeric literal operator 'operator\"\"uwb'" "" { target c++11 } .-1 } --- gcc/testsuite/g++.dg/ext/bitint3.C.jj 2023-08-10 10:43:51.410483886 +0200 +++ gcc/testsuite/g++.dg/ext/bitint3.C 2023-08-10 10:50:06.969068962 +0200 @@ -0,0 +1,8 @@ +// PR c/102989 +// { dg-do compile { target c++11 } } + +constexpr int operator""wb (unsigned long long) { return 0; } // { dg-warning "reserved for future standardization" } +constexpr int operator""uwb (unsigned long long) { return 1; } // { dg-warning "reserved for future standardization" } + +static_assert (-42wb == 0, ""); +static_assert (81uwb == 1, ""); --- gcc/testsuite/g++.dg/ext/bitint4.C.jj 2023-08-10 10:45:20.503199319 +0200 +++ gcc/testsuite/g++.dg/ext/bitint4.C 2023-08-10 10:50:21.345861685 +0200 @@ -0,0 +1,9 @@ +// PR c/102989 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +constexpr int operator""wb (unsigned long long) { return 0; } // { dg-warning "reserved for future standardization" } +constexpr int operator""uwb (unsigned long long) { return 1; } // { dg-warning "reserved for future standardization" } + +static_assert (-42wb == 0, ""); +static_assert (81uwb == 1, ""); --- libcpp/expr.cc.jj 2023-08-10 09:26:39.782509626 +0200 +++ libcpp/expr.cc 2023-08-10 11:44:29.337127064 +0200 @@ -856,6 +856,29 @@ cpp_classify_number (cpp_reader *pfile, virtual_location, 0, message); } + if ((result & CPP_N_BITINT) != 0 + && CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) != 0) + { + if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0) + { + const char *message = N_("ISO C does not support literal " + "% suffixes before C2X"); + if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, true_false)) + cpp_pedwarning_with_line (pfile, CPP_W_C11_C2X_COMPAT, + virtual_location, 0, message); + else + cpp_warning_with_line (pfile, CPP_W_C11_C2X_COMPAT, + virtual_location, 0, message); + } + else if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, true_false)) + { + const char *message = N_("ISO C does not support literal " + "% suffixes before C2X"); + cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, + message); + } + } + result |= CPP_N_INTEGER; }