bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Sam James <sam@gentoo.org>
Cc: "Gnulib bugs" <bug-gnulib@gnu.org>, "Arsen Arsenović" <arsen@aarsen.me>
Subject: Re: Making _Noreturn a no-op in < Clang 16?
Date: Thu, 19 Jan 2023 19:40:13 -0800	[thread overview]
Message-ID: <540715fe-d55f-ab64-0d0e-9942ab04fbc1@cs.ucla.edu> (raw)
In-Reply-To: <ED095B6B-D147-4707-B95D-A193742774B0@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

On 1/19/23 13:30, Sam James wrote:
> Right, I just meant that we don't tend to care about quieting warnings with older compilers,
> and it's not useful from a static analysis perspective here either given that older Clangs can't be trusted.
> 
> It is of course useful as an attribute in general. I don't think either of these things are really
> a downside to committing the workaround here. If we get folks who get build failures with extra warnings
> enabled, we can tell them to upgrade their compiler.

But clang 16 isn't out yet, so we can't reasonably tell people to upgrade.

And even if it clang 16 were out, I can't reasonably tell all Emacs 
developers to switch to it right away. Many of them are using Apple's 
compiler and will upgrade whenever. Plain './configure; make' on a 
bleeding-edge Emacs built from Git with Clang 15 would generate 270 
false alarms if we simply did "#define _Noreturn /**/", and I expect 
many Emacs developers would be annoyed by that (or would stop paying 
attention to any correct diagnostics mixed in with the flood of false 
positives).

With that in mind, how about the attached Gnulib patch? (I haven't 
installed it.) The basic idea is to "#define _Noreturn /**/" on buggy 
clangs if a cautious builder compiles with -D_GL_WORK_AROUND_LLVM_BUG_5979.

[-- Attachment #2: 0001-snippet-_Noreturn-work-around-Clang-_Noreturn-bug.patch --]
[-- Type: text/x-patch, Size: 3442 bytes --]

From 9d3f533586e07eba2c094501c83a22b561cc755c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 19 Jan 2023 19:39:03 -0800
Subject: [PROPOSED] snippet/_Noreturn: work around Clang _Noreturn bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a bigger-hammer workaround for the clang _Noreturn issue
fix for dfa.c on 2023-01-01.  Unfortunately, it causes 270
-Wreturn-type and -Wsometimes-uninitialized warnings when building
bleeding-edge GNU Emacs from Git on Fedora 37 with plain
‘./configure && make’.  So the workaround is enabled only if you
compile with -D_GL_WORK_AROUND_LLVM_BUG_59792.
* lib/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
#define _Noreturn to be empty if it is Clang 15 or earlier,
and if _GL_WORK_AROUND_LLVM_BUG_59792 is defined.
---
 ChangeLog           | 14 ++++++++++++++
 lib/_Noreturn.h     |  5 +++++
 m4/gnulib-common.m4 |  5 +++++
 3 files changed, 24 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index ddd9e2b1aa..5d0c8f7cd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-01-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+	snippet/_Noreturn: work around Clang _Noreturn bug
+	This is a bigger-hammer workaround for the clang _Noreturn issue
+	fix for dfa.c on 2023-01-01.  Unfortunately, it causes 270
+	-Wreturn-type and -Wsometimes-uninitialized warnings when building
+	bleeding-edge GNU Emacs from Git on Fedora 37 with plain
+	‘./configure && make’.  So the workaround is enabled only if you
+	compile with -D_GL_WORK_AROUND_LLVM_BUG_59792.
+	* lib/_Noreturn.h (_Noreturn):
+	* m4/gnulib-common.m4 (gl_COMMON_BODY):
+	#define _Noreturn to be empty if it is Clang 15 or earlier,
+	and if _GL_WORK_AROUND_LLVM_BUG_59792 is defined.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 34.
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index fa15b1b25e..6ecea98b54 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -26,6 +26,11 @@
        AIX system header files and several gnulib header files use precisely
        this syntax with 'extern'.  */
 #  define _Noreturn [[noreturn]]
+# elif (defined __clang__ && __clang_major__ < 16 \
+        && defined _GL_WORK_AROUND_LLVM_BUG_59792)
+   /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
+      that rare LLVM bug, though you may get many false-alarm warnings.  */
+#  define _Noreturn
 # elif ((!defined __cplusplus || defined __clang__) \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
             || (!defined __STRICT_ANSI__ \
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 2db3376b01..fa814222ce 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -38,6 +38,11 @@ AC_DEFUN([gl_COMMON_BODY], [
        AIX system header files and several gnulib header files use precisely
        this syntax with 'extern'.  */
 #  define _Noreturn [[noreturn]]
+# elif (defined __clang__ && __clang_major__ < 16 \
+        && defined _GL_WORK_AROUND_LLVM_BUG_59792)
+   /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
+      that rare LLVM bug, though you may get many false-alarm warnings.  */
+#  define _Noreturn
 # elif ((!defined __cplusplus || defined __clang__) \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
             || (!defined __STRICT_ANSI__ \
-- 
2.39.0


  reply	other threads:[~2023-01-20  3:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  2:09 Making _Noreturn a no-op in < Clang 16? Sam James
2023-01-19  4:17 ` Paul Eggert
2023-01-19 20:44   ` Sam James
2023-01-19 21:20     ` Paul Eggert
2023-01-19 21:30       ` Sam James
2023-01-20  3:40         ` Paul Eggert [this message]
2023-01-20  4:20           ` Sam James
2023-01-20  9:16             ` Paul Eggert
2023-01-20 10:25               ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540715fe-d55f-ab64-0d0e-9942ab04fbc1@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=arsen@aarsen.me \
    --cc=bug-gnulib@gnu.org \
    --cc=sam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).