Subject: bug#55595: 29.0.50; Compilation warnings on macOS

From: Rudolf Adamkovič <[email-masked]>
Date: Sun, 05 Jun 2022 12:51:43 +0200

Eli Zaretskii <[email-masked]> writes:

> I'm sorry, I'm flying blind here, as I have no access to this
> compiler.  I've now tried a more radical solution, please see if the
> latest master branch solves this.

I still see the first four warnings at 6011d39b6a:

  CC       comp.o
comp.c:2816:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
comp.c:4698:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
comp.c:4714:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
comp.c:4967:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^

I wonder, why not add the missing pushes?  When I apply the patch below,
Clang reports 0 warnings.  Would that break some other compiler or
something?

Rudy

>From 7ae3ef0ad33062128858c29645f641230092f26d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <[email-masked]>
Date: Sun, 5 Jun 2022 12:04:49 +0200
Subject: [PATCH] Fix diagnostic push/pop compiler warnings on macOS

* src/comp.c: Add missing "#pragma diagnostic" pushes.
* configure.ac: Revert previous attempts to fix Clang warnings.
---
 configure.ac | 2 --
 src/comp.c   | 4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 313a1436b5..1d2d1f190b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1024,7 +1024,6 @@ AC_DEFUN
      gl_WARN_ADD([-Wno-pointer-sign])
      gl_WARN_ADD([-Wno-string-plus-int])
      gl_WARN_ADD([-Wno-unknown-attributes])
-     gl_WARN_ADD([-Wno-unknown-pragmas])
    ])
  ],[
   isystem='-isystem '
@@ -1085,7 +1084,6 @@ AC_DEFUN
 
   if test "$emacs_cv_clang" = yes; then
     nw="$nw -Wdouble-promotion"
-    nm="$nm -Wunknown-pragmas"
   fi
 
   # This causes too much noise in the MinGW build.
diff --git a/src/comp.c b/src/comp.c
index 97bc6a5f9d..ea376a4370 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -2626,6 +2626,7 @@ emit_maybe_gc_or_quit (Lisp_Object insn)
 
 /* This is in charge of serializing an object and export a function to
    retrieve it at load time.  */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Waddress"
 static void
 emit_static_object (const char *name, Lisp_Object obj)
@@ -4681,6 +4682,7 @@ DEFUN ("comp--release-ctxt", Fcomp__release_ctxt, Scomp__release_ctxt,
   return Qt;
 }
 
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Waddress"
 DEFUN ("comp-native-driver-options-effective-p",
        Fcomp_native_driver_options_effective_p,
@@ -4697,6 +4699,7 @@ DEFUN ("comp-native-driver-options-effective-p",
 }
 #pragma GCC diagnostic pop
 
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Waddress"
 DEFUN ("comp-native-compiler-options-effective-p",
        Fcomp_native_compiler_options_effective_p,
@@ -4943,6 +4946,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
   return filename;
 }
 
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Waddress"
 DEFUN ("comp-libgccjit-version", Fcomp_libgccjit_version,
        Scomp_libgccjit_version, 0, 0, 0,
-- 
2.36.1

-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič <[email-masked]> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia