From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 1BDDF3857C41 for ; Mon, 7 Aug 2023 09:28:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BDDF3857C41 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy05.your-server.de ([78.46.172.2]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSwXM-000HdM-KH for newlib@sourceware.org; Mon, 07 Aug 2023 11:28:28 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qSwXM-000IdL-HC for newlib@sourceware.org; Mon, 07 Aug 2023 11:28:28 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 2A0DD480189 for ; Mon, 7 Aug 2023 11:28:28 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10032) with ESMTP id TrKlQk_FjUSN for ; Mon, 7 Aug 2023 11:28:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id DC1C9480136 for ; Mon, 7 Aug 2023 11:28:27 +0200 (CEST) X-Virus-Scanned: amavis at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10026) with ESMTP id Bx56ktX4-8dT for ; Mon, 7 Aug 2023 11:28:27 +0200 (CEST) Received: from zimbra.eb.localhost (unknown [192.168.96.242]) by mail.embedded-brains.de (Postfix) with ESMTPSA id B7F8148017C for ; Mon, 7 Aug 2023 11:28:27 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 1/2] : Decay expression passed to fallback version of __generic() Date: Mon, 7 Aug 2023 11:28:24 +0200 Message-Id: <20230807092825.24459-2-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230807092825.24459-1-sebastian.huber@embedded-brains.de> References: <20230807092825.24459-1-sebastian.huber@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldi-networks.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26993/Mon Aug 7 09:28:50 2023) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,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 List-Id: From: John Baldwin This ensures that __generic() more closely matches _Generic() when using the fallback version when _Generic() is not available (such as GCC). Co-authored by: jrtc27 Reviewed by: jrtc27 Differential Revision: https://reviews.freebsd.org/D38215 --- newlib/libc/include/sys/cdefs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cd= efs.h index 720e700920..808498c50b 100644 --- a/newlib/libc/include/sys/cdefs.h +++ b/newlib/libc/include/sys/cdefs.h @@ -328,6 +328,9 @@ * __generic(). Unlike _Generic(), this macro can only distinguish * between a single type, so it requires nested invocations to * distinguish multiple cases. + * + * Note that the comma operator is used to force expr to decay in + * order to match _Generic(). */ =20 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >=3D 201112L) || \ @@ -337,7 +340,7 @@ #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) #define __generic(expr, t, yes, no) \ __builtin_choose_expr( \ - __builtin_types_compatible_p(__typeof(expr), t), yes, no) + __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no) #endif =20 /* --=20 2.35.3