From patchwork Wed Sep 6 16:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 137587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2411107vqo; Wed, 6 Sep 2023 09:10:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGexQAGGLRJEi7NMu0fOqGOA8yapkxPkokRRL9FhQ9IniwgzMCuP8TcC2KpA43NcYS5OvV/ X-Received: by 2002:aa7:df84:0:b0:523:3e5d:8aa2 with SMTP id b4-20020aa7df84000000b005233e5d8aa2mr2598116edy.14.1694016652303; Wed, 06 Sep 2023 09:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694016652; cv=none; d=google.com; s=arc-20160816; b=qMUVaIKWOA9VHshkTkKaZv/rUaTd9TnVjW0TEH8YKZsp+XZBROZViCx+mxksZyCrmI GBYwwI0hXoYVHQZneii8miA8GqZ1Bm+vmnF1AoXI3YpXhlWHFCjQLdGDNbSZkmYx6j7G 4AyTwIozenB2yKrSD8yfbNofYShWxmoecUpYTR/6izh9V3h58pLCp4Wo/U08C8cdNp3W 2+SOseoJ/iBgQZyK+LoNaskn8jsjN6eab3hzuX2SvAe/xrRixc3XSXakASf/PjeOgUAS 1g7zBOKevCmdcSpDLy4d2QykHE1ndbLj1/BRa/sbLbFFg4SmqhFd9QehHL18m8PQTJG4 qwww== 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:cc:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=Imdww72FAAgmtNz7byjtyTB8JlqIVXcuJv6Ad2Fie/g=; fh=Ey8LQmxBYWKCHXwTUssvYYzu6GuhSOQeCgYnneWJrpc=; b=mE92tTpooq3aigq32lrXVMSYYaSqOcGbimrSPg5nSHj0iVoqXiqqi1P8tuVC/Zekay +mNzsgUkVtUIFFAM54AjsqisleBaKUDRd719155CQGVVH4P8nGxMWqNCZlFpH36w+0Cc weljTlOfekOiUqFJJ9FV2WJwKnNl3/f0CHM2dWY40sUmzwu1l1AELlvch5Hdr90m1c0P f6rDE1PEORuju+WtiO5IG/EzngW/Dd7xpt2f+bGFBVBT0/v72AgJtIWPTc+AKlt44t6I Z89jJKrGGnBI7b3a1NiaMM8zh8zMSz218IO23WyWH2xO2PHaitQ3WOFIQChSJuDkKnlX pXmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xoNwUVvJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bc22-20020a056402205600b005237b4b5082si9425231edb.81.2023.09.06.09.10.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 09:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xoNwUVvJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 E06EE3858410 for ; Wed, 6 Sep 2023 16:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E06EE3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694016638; bh=Imdww72FAAgmtNz7byjtyTB8JlqIVXcuJv6Ad2Fie/g=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xoNwUVvJS3/oKpf4+UUdIRWdTxC16EDsdBUGW+H0fbBq18rGXc1GLN9QNJFupJ3HR cXpoHVzyNOQSh2d46O6M8ZF5iQG4ErfxCgsi7eL9lA0KE1+La0XIBSvEzbjzjKDK1v FWdl0ZCX2JdGILb4N6RH5yBbMVRI5XgVvFa+kRLQ= 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 EFD6C3858C78 for ; Wed, 6 Sep 2023 16:09:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFD6C3858C78 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-295-AsOhFz3IP1qpI9yKPZL98w-1; Wed, 06 Sep 2023 12:09:52 -0400 X-MC-Unique: AsOhFz3IP1qpI9yKPZL98w-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 CF57E3C0E238; Wed, 6 Sep 2023 16:09:51 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.225.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 771FF140E950; Wed, 6 Sep 2023 16:09:51 +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 386G9nZf1990878 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 6 Sep 2023 18:09:49 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 386G9nwZ1990877; Wed, 6 Sep 2023 18:09:49 +0200 Date: Wed, 6 Sep 2023 18:09:49 +0200 To: Joseph Myers Cc: gcc-patches@gcc.gnu.org Subject: [committed 19/12] Additional _BitInt test coverage [PR102989] Message-ID: References: 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.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_LOTSOFHASH, 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.30 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: 1776305204844999661 X-GMAIL-MSGID: 1776305204844999661 On Tue, Sep 05, 2023 at 10:40:26PM +0000, Joseph Myers wrote: > Additional tests I think should be added (for things I expect should > already work): > > * Tests for BITINT_MAXWIDTH in . Test that it's defined for > C2x, but not defined for C11/C17 (the latter independent of whether the > target has _BitInt support). Test the value as well: _BitInt > (BITINT_MAXWIDTH) should be OK (both signed and unsigned) but _BitInt > (BITINT_MAXWIDTH + 1) should not be OK. Also test that BITINT_MAXWIDTH >= > ULLONG_MAX. > > * Test _BitInt (N) where N is a constexpr variable or enum constant (I > expect these should work - the required call to convert_lvalue_to_rvalue > for constexpr to work is present - but I don't see such tests in the > testsuite). > > * Test that -funsigned-bitfields does not affect the signedness of _BitInt > (N) bit-fields (the standard wording isn't entirely clear, but that's > what's implemented in the patches). > > * Test the errors for _Sat used with _BitInt (though such a test might not > actually run at present because no target supports both features). Here is a patch which adds that test coverage. > I looked at places in c-family/ and c/ that refer to INTEGER_TYPE to > consider whether they should handle BITINT_TYPE and whether that matches > what the patch does there. I think the following places that don't handle > it probably should (with appropriate testcases added for the relevant > functionality, e.g. warnings) unless there is some specific reason in each > case why that's unnecessary or incorrect. c-pretty-print.cc: > c_pretty_printer::direct_declarator and c_pretty_printer::declarator. > c-warn.cc throughout. Maybe c-ada-spec.cc, though it might be best to ask > the Ada maintainers there. c-common.cc: unsafe_conversion_p, > c_common_truthvalue_conversion warnings, c_common_get_alias_set, > check_builtin_function_arguments BUILT_IN_ASSUME_ALIGNED case. > c-aux-info.cc (might need other support for generating appropriate names > in output). c-parser.cc:c_parser_omp_clause_schedule. c-fold.cc > throughout. c-typeck.c: the build_conditional_expr case where one operand > is EXCESS_PRECISION_EXPR; build_c_cast; convert_for_assignment checks for > integer/pointer conversions. As well as what I've managed to come up for the above changes. 2023-09-06 Jakub Jelinek PR c/102989 * gcc.dg/bitint-2.c (foo): Add tests for constexpr var or enumerator arguments of _BitInt. * gcc.dg/bitint-31.c: Remove forgotten 0 &&. * gcc.dg/bitint-32.c: New test. * gcc.dg/bitint-33.c: New test. * gcc.dg/bitint-34.c: New test. * gcc.dg/bitint-35.c: New test. * gcc.dg/bitint-36.c: New test. * gcc.dg/fixed-point/bitint-1.c: New test. Jakub --- gcc/testsuite/gcc.dg/bitint-2.c.jj 2023-09-06 10:57:48.771535739 +0200 +++ gcc/testsuite/gcc.dg/bitint-2.c 2023-09-06 12:17:39.764073758 +0200 @@ -14,6 +14,10 @@ foo (void) _BitInt(5) unsigned d = (unsigned _BitInt(5)) 4; _BitInt(32) e = (_BitInt(32)) 5; _BitInt(32) unsigned f = (unsigned _BitInt(32)) 6; + constexpr int g = 43; + enum E { F = 44 }; + _BitInt(g) h; + unsigned _BitInt(F) i; static_assert (expr_has_type (a, signed _BitInt(42)), ""); static_assert (expr_has_type (a, _BitInt(42)), ""); static_assert (!expr_has_type (a, unsigned _BitInt(42)), ""); @@ -66,6 +70,8 @@ foo (void) static_assert (expr_has_type (-1UWB, unsigned _BitInt(1)), ""); static_assert (expr_has_type (1uWB, unsigned _BitInt(1)), ""); static_assert (expr_has_type (2Uwb, unsigned _BitInt(2)), ""); + static_assert (expr_has_type (h, signed _BitInt(43)), ""); + static_assert (expr_has_type (i, unsigned _BitInt(44)), ""); static_assert (0wb == 0, ""); static_assert (-1wb == -1, ""); static_assert (0xffffffffwb == 4294967295wb, ""); --- gcc/testsuite/gcc.dg/bitint-31.c.jj 2023-09-06 10:57:48.799535349 +0200 +++ gcc/testsuite/gcc.dg/bitint-31.c 2023-09-06 11:52:57.675594550 +0200 @@ -255,7 +255,7 @@ main () check_round (testfltu_192 (340282356779733661637539395458142568448uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); check_round (testfltu_192 (6277101735386680763835789423207666416102355444464034512895uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); #endif -#if 0 && __BITINT_MAXWIDTH__ >= 575 +#if __BITINT_MAXWIDTH__ >= 575 check_round (testflt_575 (10633823015541376812058405359715352575wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); check_round (testflt_575 (10633823015541376812058405359715352576wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); check_round (testflt_575 (10633823015541376812058405359715352577wb), 0xffffffp+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); --- gcc/testsuite/gcc.dg/bitint-32.c.jj 2023-09-06 11:57:24.391907466 +0200 +++ gcc/testsuite/gcc.dg/bitint-32.c 2023-09-06 12:00:04.885688154 +0200 @@ -0,0 +1,14 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifndef BITINT_MAXWIDTH +#error BITINT_MAXWIDTH not defined +#elif BITINT_MAXWIDTH < ULLONG_WIDTH +#error BITINT_MAXWIDTH smaller than ULLONG_WIDTH +#endif + +_BitInt(BITINT_MAXWIDTH) a; +_BitInt(BITINT_MAXWIDTH + 1) b; /* { dg-error "'_BitInt' argument '\[0-9]+' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } */ --- gcc/testsuite/gcc.dg/bitint-33.c.jj 2023-09-06 12:00:13.678566566 +0200 +++ gcc/testsuite/gcc.dg/bitint-33.c 2023-09-06 12:11:52.160893347 +0200 @@ -0,0 +1,9 @@ +/* PR c/102989 */ +/* { dg-do compile } */ +/* { dg-options "-std=c17" } */ + +#include + +#ifdef BITINT_MAXWIDTH +#error BITINT_MAXWIDTH defined in C11 +#endif --- gcc/testsuite/gcc.dg/bitint-34.c.jj 2023-09-06 12:23:03.036601107 +0200 +++ gcc/testsuite/gcc.dg/bitint-34.c 2023-09-06 12:26:18.847894449 +0200 @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* Test that -funsigned-bitfields doesn't affect _BitInt bit-fields which are always signed. */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -funsigned-bitfields" } */ + +struct S { _BitInt(22) a : 7; signed _BitInt(22) b : 7; unsigned _BitInt(22) c : 7; } s; + +int +main () +{ + s.a = -64; + s.b = -64; + s.c = -64; + if (s.a != -64 || s.b != -64 || s.c != 64) + __builtin_abort (); +} --- gcc/testsuite/gcc.dg/bitint-35.c.jj 2023-09-06 12:44:39.073802523 +0200 +++ gcc/testsuite/gcc.dg/bitint-35.c 2023-09-06 13:20:45.181074316 +0200 @@ -0,0 +1,37 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && { float32 && int32 } } } } */ +/* { dg-options "-std=c2x -Wconversion -Wfloat-conversion" } */ +/* { dg-add-options float32 } */ + +void +foo (_Float32 x) +{ + _BitInt(57) a = 1.5F32; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' changes value from '1.5e\\\+0f32' to '1'" } */ + _BitInt(27) b = 76117358uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(27\\\)' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */ + unsigned _BitInt(27) c = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */ + _BitInt(27) d = -390288573wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(30\\\)' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */ + unsigned _BitInt(27) e = 309641337uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(29\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */ + _BitInt(27) f = 76117358U; /* { dg-warning "signed conversion from 'unsigned int' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */ + unsigned _BitInt(27) g = -15; /* { dg-warning "unsigned conversion from 'int' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */ + _BitInt(27) h = -390288573; /* { dg-warning "overflow in conversion from 'int' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */ + unsigned _BitInt(27) i = 309641337U; /* { dg-warning "conversion from 'unsigned int' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */ + int j = 2936216298uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(32\\\)' to 'int' changes value from '2936216298' to '-1358750998'" } */ + unsigned int k = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned int' changes value from '-15' to '4294967281'" } */ + int l = -8087431137529383656wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(64\\\)' to 'int' changes value from '-8087431137529383656' to '-1105152744'" } */ + unsigned int m = 1664073919553255778uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(61\\\)' to 'unsigned int' changes value from '1664073919553255778' to '3338058082'" } */ +#if __BITINT_MAXWIDTH__ >= 575 + _Float32 n = 51441631083309184313435496923626431699697406185384986811300218556561965470218425783308778801748592322915101142266821623326688106425864884688172114173397118407357447763009120wb; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' changes value from '0x353eab28b46b03ea99b84f9736cd8dbe5e986915a0383c3cb381c0da41e31b3621c75fd53262bfcb1b0e6251dbf00f3988784e29b08b65640c263e4d0959832a20e2ff5245be1e60' to '\\\+Inff32'" "" { target bitint575 } } */ +#endif + _BitInt(57) o = x; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' may change value" } */ + unsigned _BitInt(15) p = 32767uwb; + unsigned _BitInt(15) q = (_BitInt(42)) p; + _BitInt(17) r = 0; + _BitInt(17) s = ((_BitInt(42)) r) & 32767wb; +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) t = 0; + _Float32 u = t; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' may change value" "" { target bitint575 } } */ +#endif + _BitInt(42) v = 0; + unsigned _BitInt(17) w = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to 'unsigned _BitInt\\\(17\\\)' may change value" } */ + _BitInt(17) y = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to '_BitInt\\\(17\\\)' may change value" } */ +} --- gcc/testsuite/gcc.dg/bitint-36.c.jj 2023-09-06 13:43:35.891209025 +0200 +++ gcc/testsuite/gcc.dg/bitint-36.c 2023-09-06 14:29:17.805476679 +0200 @@ -0,0 +1,39 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint } } } */ +/* { dg-options "-std=c2x -Wint-in-bool-context -Waddress -Wpointer-to-int-cast -Wint-to-pointer-cast -Wint-conversion -Wshift-negative-value -Wshift-count-overflow -Wdiv-by-zero" } */ + +extern char *ax[]; + +void bar (int); + +void +foo (_BitInt(61) x, long long *y) +{ + if (x << 15) /* { dg-warning "'<<' in boolean context, did you mean '<'" } */ + ; + bar ((_BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 0) == 0); + bar ((unsigned _BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 1) == 0); + char *z = __builtin_assume_aligned (y, 32wb, 8wb); + *z = 42; + _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) a = (_BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) b = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) c = (_BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) d = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + void *e = (void *) a; /* { dg-warning "cast to pointer from integer of different size" } */ + void *f = (void *) b; /* { dg-warning "cast to pointer from integer of different size" } */ + void *g = (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ + void *h = (void *) d; /* { dg-warning "cast to pointer from integer of different size" } */ + a = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + b = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + c = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + d = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + e = a; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + f = b; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + g = c; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + h = d; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + _BitInt(61) i = (1wb - 1152921504606846975wb) << 1; /* { dg-warning "left shift of negative value" } */ + /* { dg-warning "result of '-1152921504606846974 << 1' requires 62 bits to represent, but '_BitInt\\\(61\\\)' only has 61 bits" "" { target *-*-* } .-1 } */ + _BitInt(61) j = i << (60 + 1); /* { dg-warning "left shift count >= width of type" } */ + _BitInt(61) k = i >> (60 + 1); /* { dg-warning "right shift count >= width of type" } */ + _BitInt(61) l = i / (51wb - 51wb); /* { dg-warning "division by zero" } */ +} --- gcc/testsuite/gcc.dg/fixed-point/bitint-1.c.jj 2023-09-06 12:32:12.152030135 +0200 +++ gcc/testsuite/gcc.dg/fixed-point/bitint-1.c 2023-09-06 12:32:30.457778458 +0200 @@ -0,0 +1,10 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +void +foo (void) +{ + _Sat _BitInt (42) a; /* { dg-error "both '_Sat' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) _Sat b; /* { dg-error "both '_Sat' and '_BitInt' in declaration specifiers" } */ +}