From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 59FFA3858D28 for ; Tue, 27 Feb 2024 17:55:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59FFA3858D28 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 59FFA3858D28 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=1709056501; cv=none; b=TyY0CatSA9e/NrickhbytVb7LOJybl8rtjFTzgEo5z7eaarSRAFcAmdWNUU+N9Y3RxpxYu/5uooX/IXoGurSRvniiB0oOUuRSuMnpRH/bhfOttyegxCitw6YEsEbLdwq5k8gUCANLKUTwi/JmKHA3qHiwHRowqUsrzAr1+jb6mE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709056501; c=relaxed/simple; bh=NLDSEDgbeZCbLFraETAu23FouZxte6nljuWLgVmR/uE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=XQus9XjzU8FG1DIzsPFFE7vzTloUSD/KPV90EN8gbv82ER22icNInuInc3NpoHal013VzTNcFS76ndvczOtx1/yfXsIRas07uEvWn9Yc/eRSQ8lMXtckIKVVsPi1i6NV26hCIn1UxHzli0GFM3kvRVrm8LdAxUHQKl1uuj0jeo8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709056500; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ucMbheU7q+VpX/USih3bYkYfDLBHBAjQtJDbDelJNkg=; b=HAlpa5Hpq35yR5nHAhDJMQ9TfESe7MZNJ4PCCWMy1r7sFSTtCAW1bmW+Yxv+SwKOwFRunO oiqCW8ZcT0aWxTKmzUdUhDWEdewN1mwairpDARWRj0VjHu0/6zSm0filfnsT7uG7pbPVxc sIC7g+xJ1nXj7wZ5kQSpNsg+QmQFaac= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-lioLuuXlPbSb645sBM_zgw-1; Tue, 27 Feb 2024 12:54:57 -0500 X-MC-Unique: lioLuuXlPbSb645sBM_zgw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 C7FA838135F0; Tue, 27 Feb 2024 17:54:56 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6D1817FC; Tue, 27 Feb 2024 17:54:55 +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 41RHsqgf141730 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Feb 2024 18:54:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41RHsodJ141729; Tue, 27 Feb 2024 18:54:50 +0100 Date: Tue, 27 Feb 2024 18:54:49 +0100 From: Jakub Jelinek To: Richard Earnshaw , "Joseph S. Myers" , Richard Biener , Jeff Law , gcc-patches@gcc.gnu.org, Alexandre Ferreira , =?iso-8859-1?Q?Torbj=F6rn?= SVENSSON Subject: Re: [PATCH] calls: Fix up TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453] Message-ID: Reply-To: Jakub Jelinek References: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_MANYTO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Feb 27, 2024 at 06:25:21PM +0100, Jakub Jelinek wrote: > I guess we need some testsuite coverage for caller/callee ABI match of > struct S { char p[64]; }; > struct S foo (...); Maybe the test below? Passes on x86_64 -m32/-m64, but I guess that doesn't care at all about the named vs. not named distinction. The test is a copy of c23-stdarg-4.c, just with all the functions returning a large struct. 2024-02-27 Jakub Jelinek * gcc.dg/c23-stdarg-6.c: New test. --- gcc/testsuite/gcc.dg/c23-stdarg-6.c.jj 2024-02-27 18:39:04.807821107 +0100 +++ gcc/testsuite/gcc.dg/c23-stdarg-6.c 2024-02-27 18:51:44.706308490 +0100 @@ -0,0 +1,217 @@ +/* Test C23 variadic functions with no named parameters, or last named + parameter with a declaration not allowed in C17. Execution tests. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +#include + +extern void abort (void); +extern void exit (int); +struct s { char c[1000]; }; + +struct s +f (...) +{ + va_list ap; + va_start (ap); + double r = va_arg (ap, int); + r += va_arg (ap, double); + r += va_arg (ap, int); + r += va_arg (ap, double); + va_end (ap); + struct s ret = {}; + ret.c[0] = r; + ret.c[999] = 42; + return ret; +} + +struct s +g (...) +{ + va_list ap; + va_start (ap, random ! ignored, ignored ** text); + for (int i = 0; i < 10; i++) + if (va_arg (ap, double) != i) + abort (); + va_end (ap); + struct s ret = {}; + ret.c[0] = 17; + ret.c[999] = 58; + return ret; +} + +struct s +h1 (register int x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 32; + ret.c[999] = 95; + return ret; +} + +struct s +h2 (int x(), ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 5; + ret.c[999] = 125; + return ret; +} + +struct s +h3 (int x[10], ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 8; + ret.c[999] = 12; + return ret; +} + +struct s +h4 (char x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 18; + ret.c[999] = 28; + return ret; +} + +struct s +h5 (float x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 38; + ret.c[999] = 48; + return ret; +} + +struct s +h6 (volatile long x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 58; + ret.c[999] = 68; + return ret; +} + +struct s +h7 (volatile struct s x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); + struct s ret = {}; + ret.c[0] = 78; + ret.c[999] = 88; + return ret; +} + +int +main () +{ + struct s x = f (1, 2.0, 3, 4.0); + if (x.c[0] != 10 || x.c[999] != 42) + abort (); + x = g (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); + if (x.c[0] != 17 || x.c[999] != 58) + abort (); + x = g (0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); + if (x.c[0] != 17 || x.c[999] != 58) + abort (); + x = h1 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 32 || x.c[999] != 95) + abort (); + x = h2 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 5 || x.c[999] != 125) + abort (); + x = h3 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 8 || x.c[999] != 12) + abort (); + x = h4 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 18 || x.c[999] != 28) + abort (); + x = h5 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 38 || x.c[999] != 48) + abort (); + x = h6 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 58 || x.c[999] != 68) + abort (); + x = h7 ((struct s) {}, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + if (x.c[0] != 78 || x.c[999] != 88) + abort (); + exit (0); +} Jakub