From patchwork Tue Feb 13 08:26:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 200273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp398196dyb; Tue, 13 Feb 2024 00:30:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLqCxCx1o69Q2rOySfMRlOS3ioQFLCOXirBLYjKKnjZBxH/fHsKKE9TIHFTEaZmX+uIcHSeMB7gJisGGyYnm+OwneZBg== X-Google-Smtp-Source: AGHT+IEbg1D/2N2tonfse841cb1OwlzgweKGg92YkZJGgl12nRGrzLmkuxJ1xbtIpaGIRsqRVHso X-Received: by 2002:a05:6830:2aac:b0:6e2:f68d:e474 with SMTP id s44-20020a0568302aac00b006e2f68de474mr891643otu.36.1707813057570; Tue, 13 Feb 2024 00:30:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707813057; cv=pass; d=google.com; s=arc-20160816; b=Ws8+ZTFyXF+nS+vYJJjANxliBLx5B4vLZjcG4lUpY71JoBpZAMcKLxfgd1Vxy0u9HP ebWfgLEipw5p63QemoQaN2ijOqDF/uh2A1WIsJBk57OFDueGf9Ud/DGdi35Qy0hO9vTX rxY+a20c2DQNihh4ZZfdWgP6Ywt1c6/tnhehEmo1Bu+vPN8cUz+kwyrF2MXNCmmAs8xM /aCvbLujF+67QKG/CzEfnLfYagfSQcwKwljf01Nn4s62QNmOEC/FGqGH2mybJ8tIzWFz Aeh3WAtum0smF5aGRIM3f7lGVciUOt+btHZ3piNbnkPnjIHD1WrU1DU6rizydrl6PXaI u3xQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to: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:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=s7BP3EEOc+T4obZJ8f1g9S52EqGKUTUggVzntx17OZM=; fh=18EJfEXaZRiKF6RTayj+T1xX/lRVnIX0fQN1okHrhI4=; b=ixoWx4PmPIdrl496LlBEhlNNh7RE2RVxGC1HpyR3OEI9pkBi96BYHiZTzF1tYWwXMS uesaaykVhyvNKNm3RGOczWW7lLlmQCBGdshS5ng93Rfmzj24dliTSFFFFjAnPhgqvAGZ L35caA9W2RW+UmbJ0CYOdhK+u/HUxlYBnW0CFmQnKk4pi2FFrGs9v27I+H4GwzvvuCEE zK6gjeMXUllTJt0P+ZO2aqAgOdm4F8kpthCrEmMNX5waMhbZD96uYla4Azjtsa852iXv a5TnG1COX+As5C00P556alECFUsy/I4IU23viH9pEZcPgMuzOJVZDtl+u9k2FUtgpPTJ Khvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ze+rh+Oc; arc=pass (i=1); 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=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCXYgT2dPOxhQeRnNjfxHFQmSgmj4gc97brLUi7KHnoi1ALXduMSU/7T0IBB1ggtDaUvCKQXQbPiIOSZb5LTUsdVWMf6MA== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p16-20020ac87410000000b0042c6ea58fa2si2202983qtq.529.2024.02.13.00.30.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 00:30:57 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Ze+rh+Oc; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C07E3858C33 for ; Tue, 13 Feb 2024 08:30:57 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id E41CC3858D20 for ; Tue, 13 Feb 2024 08:26:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E41CC3858D20 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 E41CC3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707812814; cv=none; b=Wnc8JG31PY6OXB0/0iFOC02JBH8EIvPNJGskEvAYFgpiPn8JdXNqvqReF3h1uwsBBLIt5kugNbOEnMv+inenfYEbZdqvTIlzBbhBeqUApOKB+Ny9fW2bKwjlGC5iaGGSezAehkIwzLOUJikD341MecDqw9nelo4Gf88Afl5HWdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707812814; c=relaxed/simple; bh=cHnxYWLU7xez3pAlxx+Y8SPLsomEt3Ac5Nx3e8hO/k4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=swinkdzCNUsA7o2PBL+BGWgtEfK+EJkbQhxsKX5WrWmDBVuQ1qUorsCUM9tz6MhT78gQv39lPZPPpw4kXFLAlnPQY2Qpvin95Kb4G90Gm2iwMOUKWfs/7SZD67W12ot742p7lVgfQpJnNfrgEiIO0dU75BQ/jBSlp6koy43E9rw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707812809; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=s7BP3EEOc+T4obZJ8f1g9S52EqGKUTUggVzntx17OZM=; b=Ze+rh+OcY6V5JU/+tzn8OaqJALV2XHp2cL3totHlnXwjBTjzHEWh1xBnUw8cF0xancjQrP +S4lSWLqt4ndomBOdMjU8PL2BUfTNTimt/TnOgeb58EcdsC0K0QkBfX+VQ959/AuBc+xvB Gu7hfdlaW/+02Ue3ISZuD8Bi3HDLJ38= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-8TVR5jSBPFOfBUhCNze2kg-1; Tue, 13 Feb 2024 03:26:44 -0500 X-MC-Unique: 8TVR5jSBPFOfBUhCNze2kg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 884AD101FA2E for ; Tue, 13 Feb 2024 08:26:43 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BFB42166B35; Tue, 13 Feb 2024 08:26:43 +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 41D8Qfi71327651 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 09:26:41 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41D8Qed61327650; Tue, 13 Feb 2024 09:26:40 +0100 Date: Tue, 13 Feb 2024 09:26:40 +0100 From: Jakub Jelinek To: Joseph Myers Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Add %[zt][diox] tests to gcc.dg/format/ Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.2 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, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790771784778561840 X-GMAIL-MSGID: 1790771784778561840 On Mon, Feb 12, 2024 at 04:10:33PM +0000, Joseph Myers wrote: > On Sat, 10 Feb 2024, Jakub Jelinek wrote: > > > * c-format.cc (gcc_diag_length_specs): Add t and z modifiers. > > (PP_FORMAT_CHAR_TABLE, gcc_gfc_char_table): Add entries for t and > > z modifiers. > > Please also add some tests of format checking for these modifiers in > gcc.dg/format/gcc_*.c. The following patch does that. Haven't added tests for bad type (but I think we don't have them in c99-printf* either) for these because it is hard to figure out what type from {,unsigned }{int,long,long long} size_t/ptrdiff_t certainly is not, guess one could do that with preprocessor conditionals, e.g. comparing __PTRDIFF_MAX__ with __INT_MAX__, __LONG_MAX__ and __LONG_LONG_MAX__ and pick up the one which is different; but we'd need to find out corresponding effective targets for the expected diagnostics. Tested on x86_64-linux and i686-linux, ok for trunk? 2024-02-13 Jakub Jelinek * gcc.dg/format/gcc_diag-1.c (foo): Add tests for z and t modifiers. * gcc.dg/format/gcc_gfc-1.c (foo): Add tests for ll, z and t modifiers. Jakub --- gcc/testsuite/gcc.dg/format/gcc_diag-1.c.jj 2020-01-12 11:54:37.423398171 +0100 +++ gcc/testsuite/gcc.dg/format/gcc_diag-1.c 2024-02-12 19:41:55.512559836 +0100 @@ -33,7 +33,8 @@ foo (int i, int i1, int i2, unsigned int ullong ull, unsigned int *un, const int *cn, signed char *ss, unsigned char *us, const signed char *css, unsigned int u1, unsigned int u2, location_t *loc, tree t1, union tree_node *t2, - tree *t3, tree t4[], int *v, unsigned v_len) + tree *t3, tree t4[], int *v, unsigned v_len, size_t sz, ptrdiff_t pd, + ssize_t ssz, unsigned_ptrdiff_t upd) { /* Acceptable C90 specifiers, flags and modifiers. */ diag ("%%"); @@ -66,6 +67,16 @@ foo (int i, int i1, int i2, unsigned int cdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); cxxdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); dump ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); + diag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + tdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + cdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + cxxdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + dump ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + diag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + tdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + cdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + cxxdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + dump ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); diag ("%.*s", i, s); tdiag ("%.*s", i, s); cdiag ("%.*s", i, s); --- gcc/testsuite/gcc.dg/format/gcc_gfc-1.c.jj 2020-01-11 16:31:55.136291982 +0100 +++ gcc/testsuite/gcc.dg/format/gcc_gfc-1.c 2024-02-12 19:46:26.139775018 +0100 @@ -12,13 +12,19 @@ extern int gfc_warn (const char *, ...) void foo (unsigned int u, int i, char *s, unsigned long int ul, long int l, - llong ll, locus *loc) + llong ll, unsigned long long int ull, locus *loc, size_t sz, + ptrdiff_t pd, ssize_t ssz, unsigned_ptrdiff_t upd) { /* Acceptable C90 specifiers, flags and modifiers. */ gfc_warn ("%%"); gfc_warn ("%u%d%i%c%s%%", u, i, i, i, s); gfc_warn ("%lu%ld%li%%", ul, l, l); + /* Acceptable C99 specifiers, flags and modifiers. */ + gfc_warn ("%llu%lld%lli%%", ull, ll, ll); + gfc_warn ("%zu%zd%zi%%", sz, ssz, ssz); + gfc_warn ("%tu%td%ti%%", upd, pd, pd); + /* Extensions provided in gfc_warn. */ gfc_warn ("%C"); gfc_warn ("%L", loc);