From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: #2 [Was: Re: Function attributes for make-docfile] Date: Wed, 14 Jan 2015 11:44:26 -0800 Organization: UCLA Computer Science Department Message-ID: <54B6C71A.1040101@cs.ucla.edu> References: <54B348E8.7080203@yandex.ru> <54B3604E.9020304@cs.ucla.edu> <54B3BDE3.8030602@yandex.ru> <54B4C971.7010209@cs.ucla.edu> <54B5A991.8010509@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030709000306000801080303" X-Trace: ger.gmane.org 1421264698 7286 80.91.229.3 (14 Jan 2015 19:44:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Jan 2015 19:44:58 +0000 (UTC) Cc: Dmitry Antipov , Emacs development discussions To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 14 20:44:52 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YBTs3-0007Kh-PT for ged-emacs-devel@m.gmane.org; Wed, 14 Jan 2015 20:44:52 +0100 Original-Received: from localhost ([::1]:47890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBTs3-0005pK-97 for ged-emacs-devel@m.gmane.org; Wed, 14 Jan 2015 14:44:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBTrz-0005p1-Ba for emacs-devel@gnu.org; Wed, 14 Jan 2015 14:44:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBTrv-0005E0-6N for emacs-devel@gnu.org; Wed, 14 Jan 2015 14:44:47 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:50050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBTru-0005Ds-R1 for emacs-devel@gnu.org; Wed, 14 Jan 2015 14:44:43 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0D79B39E801F; Wed, 14 Jan 2015 11:44:42 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wj1ZTSaffrGi; Wed, 14 Jan 2015 11:44:40 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 064CBA6012B; Wed, 14 Jan 2015 11:44:40 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181265 Archived-At: This is a multi-part message in MIME format. --------------030709000306000801080303 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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? --------------030709000306000801080303 Content-Type: text/x-patch; name="0001-Give-up-on-Wredundant-decls.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Give-up-on-Wredundant-decls.patch" >From ed8c06dcd1442d2543a5272e741e1ec97f9f9090 Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 + + Give up on -Wredundant-decls + * configure.ac (WARN_CFLAGS): Omit -Wredundant-decls. + 2015-01-11 Paul Eggert 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 + + 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 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 + + 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 * 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 --------------030709000306000801080303--