From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id EB8221F47C for ; Sat, 28 Jan 2023 08:40:02 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=fR/JoUm+; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLgkX-0004Zz-Cl; Sat, 28 Jan 2023 03:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLgkL-0004Zk-1h for bug-gnulib@gnu.org; Sat, 28 Jan 2023 03:39:37 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.217]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLgkI-0003W8-Ej for bug-gnulib@gnu.org; Sat, 28 Jan 2023 03:39:36 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1674895171; cv=none; d=strato.com; s=strato-dkim-0002; b=spJRbdGFaEB+IHGgIfVnycunW3updyGh6bTsBNXC0FN5MaRo0x+E/w5cHC7LHlE7kA NRHaarFb+PLSe91sgUQyA2j3dxhnuTkorfg4W3+5AYCvPi5EikbIWuIggXU28hdMudlq dzQO0QjlHcfmt4knmF7RkEM4fL49DS1rFliQqtyRhNus7Cl2TDk9uRFVqlVcNfkxZZMV 8At4StsoqtJ2cOK4cFKdTRdpBWxCCR+y1kxGh+fegPTguVRVmiUpXaM07RmXlASWVoz0 RSk/VPVp1aZo28hkHKQzO03xOJB/T157yxA5dFDDBlopCMsHhxJniJDvyz+Cacry9xme kSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1674895171; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=ctbjBpcrKbqI0r73XGPZ9o+oG+gAbCr0SYBeLDwnnrA=; b=rq0W33QIfhv8q10ZeEcjVRnWOKWOa9gujU3aSnNV4KRbCMK9mgVyR/b/BeD4k+b7CF JoRe5/1zmos4I2O990JV47z1HGE60CG0tuqcWhmGTqjK4kN010xfz9patE1MEnJy9k5T t+XpDur5mSDnTqhoJmEcmX1I9zNUScU5WSg6nxUINQ8nImg/RQCx/R5zNSx86w5X5ikc qvuR+AlNHBxayqEW5vkoL3Ormsi7Y2GsqQMkBQ2TwxyZPdia7iyIrRX2b52XzigDRdyV W/Oqvh8E/UMgzl6EeVPz98q1VPwLqLKs0dSzVY34qu3iIHrgwI/eDeyLylBQZJSQ/SN0 zMdg== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1674895171; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=ctbjBpcrKbqI0r73XGPZ9o+oG+gAbCr0SYBeLDwnnrA=; b=fR/JoUm+bDuCKm7x6zRvWnp5OshW31MVt+0pFXo5y1xBABwHGdaPpL48RsLXT89eYP 1eS74LtJ61X9KGLBMmU2t1D7dIR0/zjc1NpWQ1C/1ldzDFzxi9p6VwSdgSahz+W/1s/B 3CEqbVlzkJ0yRzVCWaB0c3A0ytiBzypRA2hxavnutgJaBiLHStPcBYbFrNMe/yxUevME DsSQNr9gqPX9BDo807TEMbiXZCujzlAn0B8N+N90l52FnkL1Wgs9P3iqp1/usiwiruYV YiexVdol9a0kkM47YHvFlOFwi/oMd0gzAZWcLv6K307DG7LNIzMvSeafVSwsjV0cl43E csNg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPDjvwA7022TV+YfjovfFy3RIl4" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z0S8dVMiG (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sat, 28 Jan 2023 09:39:31 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Avoid clang warnings regarding [[__maybe_unused__]] Date: Sat, 28 Jan 2023 09:39:31 +0100 Message-ID: <8503261.SR6Mq5HPT2@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=81.169.146.217; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Building a Gnulib testdir on FreeBSD 12.0, which uses clang 6.0.1, I see many warnings such as =2E./../gltests/test-dirent-c++.cc:28:1: warning: unknown attribute '__mayb= e_unused__' ignored [-Wunknown-attributes] The cause is that in this version of clang, __has_c_attribute(__maybe_unuse= d__) apparently returns true, and the use of [[__maybe_unused__]] does not elici= t a syntax error. But it elicits a warning. Here's how it depends on the clang version: clang result =2D---- ------- 4.0.0 error 5.0.2 error 6.0.1 warning 7.0.1 warning 8.0.0 warning 9.0.0 warning 10.0.0 ok This patch fixes the warnings, by choosing a different (more conservative) expansion of _GL_ATTRIBUTE_MAYBE_UNUSED. 2023-01-28 Bruno Haible Avoid clang warnings regarding [[__maybe_unused__]]. * m4/gnulib-common.m4 (gl_COMMON_BODY): For clang versions =E2=89=A5 6, < = 10, in C++ mode, ignore the __has_c_attribute value and define _GL_ATTRIBUTE_MAYBE_UNUSED to __attribute__ ((__unused__)), not [[__maybe_unused__]]. diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 0f1a6ac1ea..cf0fc5a1e7 100644 =2D-- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ =2D# gnulib-common.m4 serial 78 +# gnulib-common.m4 serial 79 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -351,9 +351,15 @@ AC_DEFUN([gl_COMMON_BODY], [ in C++ also: class. */ /* In C++ and C23, this is spelled [[__maybe_unused__]]. GCC's syntax is __attribute__ ((__unused__)). =2D clang supports both syntaxes. */ + clang supports both syntaxes. Except that with clang =E2=89=A5 6, < 10= , in C++ mode, + __has_c_attribute (__maybe_unused__) yields true but the use of + [[__maybe_unused__]] nevertheless produces a warning. */ #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED =2D# ifdef __has_c_attribute +# if defined __clang__ && defined __cplusplus +# if __clang_major__ >=3D 10 +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# elif defined __has_c_attribute # if __has_c_attribute (__maybe_unused__) # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] # endif