all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dmitry Antipov <dmantipov@yandex.ru>,
	Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: #2 [Was: Re: Function attributes for make-docfile]
Date: Wed, 14 Jan 2015 11:44:26 -0800	[thread overview]
Message-ID: <54B6C71A.1040101@cs.ucla.edu> (raw)
In-Reply-To: <jwvoaq1z21i.fsf-monnier+emacs@gnu.org>

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

On 01/14/2015 09:49 AM, Stefan Monnier wrote:
> This is hideous.  Why do we need that?

Assuming --enable-gcc-warnings, it's a combination of things. First, gcc 
-Wsuggest-attribute=const complains if it can deduce that an extern 
function is const but the function wasn't declared const. Second, this 
particular function is const on some platforms and not on others, so we 
can't simply declare it to be const everywhere. Third, the DEFUN syntax 
doesn't give us a way to declare a function const only on some 
platforms.  Fourth, gcc -Wredundant-decls won't let us supply another 
extern declaration by hand, with the const attribute on platforms that 
need const, because GCC complains if there are duplicate extern declations.

There are several possibilities for how to fix this in a less-ugly way, 
including:

1.  Omit -Wsuggest-attribute=const.

2.  Omit -Wredundant-decls.

3.  Make make-docfile.c even smarter and/or trickier.

The attached patch would do (2), as I expect this is simplest. Would you 
prefer this?

[-- Attachment #2: 0001-Give-up-on-Wredundant-decls.patch --]
[-- Type: text/x-patch, Size: 4732 bytes --]

From ed8c06dcd1442d2543a5272e741e1ec97f9f9090 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 14 Jan 2015 11:42:43 -0800
Subject: [PATCH] Give up on -Wredundant-decls

This removes the need for the ugly make-docfile.c hack involving
Fnext_read_file_uses_dialog_p.
* configure.ac (WARN_CFLAGS): Omit -Wredundant-decls.
* lib-src/make-docfile.c (write_globals): Undo previous change.
* src/fileio.c (READ_FILE_NAME_MAY_USE_DIALOG): New constant.
(Fnext_read_file_uses_dialog_p): Use it instead of an #ifdef.
Use a redundant decl to declare this function to be const, on
platforms where it's const.
---
 ChangeLog              |  5 +++++
 configure.ac           |  1 -
 lib-src/ChangeLog      |  7 +++++++
 lib-src/make-docfile.c | 12 ------------
 src/ChangeLog          |  8 ++++++++
 src/fileio.c           | 14 ++++++++++----
 6 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cca9100..a28b68e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Give up on -Wredundant-decls
+	* configure.ac (WARN_CFLAGS): Omit -Wredundant-decls.
+
 2015-01-11  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Default to 'configure --enable-silent-rules'
diff --git a/configure.ac b/configure.ac
index 4cad214..3600e00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -912,7 +912,6 @@ else
   for w in $ws; do
     gl_WARN_ADD([$w])
   done
-  gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index e9205fd..e4408c0 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Give up on -Wredundant-decls
+	This removes the need for the ugly make-docfile.c hack involving
+	Fnext_read_file_uses_dialog_p.
+	* make-docfile.c (write_globals): Undo previous change.
+
 2015-01-13  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Don't say Fnext_read_file_uses_dialog_p is const
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 741fa4b..79d421a 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -729,18 +729,6 @@ write_globals (void)
 
 	  if (globals[i].flags & DEFUN_const)
 	    fputs (" ATTRIBUTE_CONST", stdout);
-	  else if (strcmp (globals[i].name, "Fnext_read_file_uses_dialog_p")
-		   == 0)
-	    {
-	      /* It would be nice to have a cleaner way to deal with this
-		 special hack.  */
-	      fputs (("\n"
-		      "#if ! (defined USE_GTK || defined USE_MOTIF \\\n"
-		      "       || defined HAVE_NS || defined HAVE_NTGUI)\n"
-		      "\tATTRIBUTE_CONST\n"
-		      "#endif\n"),
-		     stdout);
-	    }
 
 	  puts (";");
 	}
diff --git a/src/ChangeLog b/src/ChangeLog
index b2588f1..b4929d0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2015-01-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Give up on -Wredundant-decls
+	* fileio.c (READ_FILE_NAME_MAY_USE_DIALOG): New constant.
+	(Fnext_read_file_uses_dialog_p): Use it instead of an #ifdef.
+	Use a redundant decl to declare this function to be const, on
+	platforms where it's const.
+
 2015-01-14  Eli Zaretskii  <eliz@gnu.org>
 
 	* w32fns.c (w32_wnd_proc): Ignore MENUITEMINFO's dwItemData data
diff --git a/src/fileio.c b/src/fileio.c
index 6c443c9..3237d74 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5736,6 +5736,14 @@ then any auto-save counts as "recent".  */)
 
 /* Reading and completing file names.  */
 
+#if (defined USE_GTK || defined USE_MOTIF \
+     || defined HAVE_NS || defined HAVE_NTGUI)
+enum { READ_FILE_NAME_MAY_USE_DIALOG = true };
+#else
+enum { READ_FILE_NAME_MAY_USE_DIALOG = false };
+EXFUN (Fnext_read_file_uses_dialog_p, 0) ATTRIBUTE_CONST;
+#endif
+
 DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p,
        Snext_read_file_uses_dialog_p, 0, 0, 0,
        doc: /* Return t if a call to `read-file-name' will use a dialog.
@@ -5743,14 +5751,12 @@ The return value is only relevant for a call to `read-file-name' that happens
 before any other event (mouse or keypress) is handled.  */)
   (void)
 {
-#if (defined USE_GTK || defined USE_MOTIF \
-     || defined HAVE_NS || defined HAVE_NTGUI)
-  if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
+  if (READ_FILE_NAME_MAY_USE_DIALOG
+      && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
       && use_file_dialog
       && window_system_available (SELECTED_FRAME ()))
     return Qt;
-#endif
   return Qnil;
 }
 
-- 
2.1.0


  reply	other threads:[~2015-01-14 19:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  4:09 Function attributes for make-docfile Dmitry Antipov
2015-01-12  5:33 ` Stefan Monnier
2015-01-12  5:49 ` Paul Eggert
2015-01-12 12:28   ` #2 [Was: Re: Function attributes for make-docfile] Dmitry Antipov
2015-01-13  7:29     ` Paul Eggert
2015-01-13 10:21       ` Dmitry Antipov
2015-01-13 17:43         ` Paul Eggert
2015-01-13 19:45       ` Stefan Monnier
2015-01-13 23:26         ` Paul Eggert
2015-01-14 17:49           ` Stefan Monnier
2015-01-14 19:44             ` Paul Eggert [this message]
2015-01-15  3:27               ` Dmitry Antipov
2015-01-15  3:54                 ` Dmitry Antipov
2015-01-15  5:33               ` Stefan Monnier
2015-01-16  4:50                 ` Paul Eggert

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

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

  git send-email \
    --in-reply-to=54B6C71A.1040101@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.