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: 1898123 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=Ze+rh+Oc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4TYvcD0BvHz23hT for ; Tue, 13 Feb 2024 19:28:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D6003858C60 for ; Tue, 13 Feb 2024 08:28: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.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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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);