From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#21466: [PATCH] Avoid defining (temporarily) vars and functions Date: Sat, 26 Mar 2022 14:45:40 +0000 Message-ID: References: <87eeeestgu.fsf@gnus.org> <87y2105swg.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39806"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, Stefan Monnier , 21466@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 26 15:46:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nY7gG-000AAr-Ei for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Mar 2022 15:46:16 +0100 Original-Received: from localhost ([::1]:49282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY7gF-000460-3e for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Mar 2022 10:46:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY7g8-00045p-B9 for bug-gnu-emacs@gnu.org; Sat, 26 Mar 2022 10:46:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY7g1-0000QZ-Ln; Sat, 26 Mar 2022 10:46:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nY7g1-0007eO-KQ; Sat, 26 Mar 2022 10:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 26 Mar 2022 14:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21466 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: patch Original-Received: via spool by 21466-submit@debbugs.gnu.org id=B21466.164830595029388 (code B ref 21466); Sat, 26 Mar 2022 14:46:01 +0000 Original-Received: (at 21466) by debbugs.gnu.org; 26 Mar 2022 14:45:50 +0000 Original-Received: from localhost ([127.0.0.1]:54479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nY7fp-0007du-VB for submit@debbugs.gnu.org; Sat, 26 Mar 2022 10:45:50 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:19826 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1nY7fo-0007dd-39 for 21466@debbugs.gnu.org; Sat, 26 Mar 2022 10:45:48 -0400 Original-Received: (qmail 20127 invoked by uid 3782); 26 Mar 2022 14:45:41 -0000 Original-Received: from acm.muc.de (p2e5d5498.dip0.t-ipconnect.de [46.93.84.152]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 26 Mar 2022 15:45:40 +0100 Original-Received: (qmail 6063 invoked by uid 1000); 26 Mar 2022 14:45:40 -0000 Content-Disposition: inline In-Reply-To: <87y2105swg.fsf@gnus.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228973 Archived-At: Hello again, Lars. On Wed, Mar 23, 2022 at 21:13:35 +0100, Lars Ingebrigtsen wrote: > Alan Mackenzie writes: > > So, I don't object on principle to the principle of the patch, just > > there are these little irritations about it, and it will need me to > > study it more closely to check nothing subtle would get lost (I doubt it > > would). > The patch no longer applied to Emacs 29, so I've respun it. [ .... ] > However, it leads to a number of warnings when compiling, so either my > respin is faulty, or something's changed to make it not work any more? Maybe it didn't work properly back in 2015, I didn't actually get around to trying it out, then. > In c-fontify-recorded-types-and-refs: > progmodes/cc-fonts.el:491:8: Warning: function `c-fontify-recorded-types-and-refs' defined multiple times in this file > ELC progmodes/cc-styles.elc > In c-font-lock-declarators: > progmodes/cc-fonts.el:1063:8: Warning: function `c-font-lock-declarators' defined multiple times in this file > progmodes/cc-fonts.el:2300:35: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2300:35: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2496:37: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2496:37: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2501:37: Warning: reference to free variable `c-reference-face-name' > In c-font-lock-objc-method: > progmodes/cc-fonts.el:2527:8: Warning: function `c-font-lock-objc-method' defined multiple times in this file > progmodes/cc-fonts.el:2602:38: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2602:38: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2650:38: Warning: reference to free variable `c-reference-face-name' > progmodes/cc-fonts.el:2678:37: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2678:37: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2683:37: Warning: reference to free variable `c-reference-face-name' > progmodes/cc-fonts.el:2711:38: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2711:38: Warning: reference to free variable `c-preprocessor-face-name' > progmodes/cc-fonts.el:2716:38: Warning: reference to free variable `c-reference-face-name' The patch is essentially replacing cc-bytecomp-defvar by (defvar foo), and cc-bytecomp-defun by (declare-function 'foo nil). These are only approximately similar. cc-bytecomp-def{var,fun} are like C's extern. They say "this variable/function will be defined somewhere else". By contrast, (defvar foo) doesn't really do anything (?except marking any possible foo as a special variable). (declare-function 'foo nil) says "This function HAS ALREADY been defined somewhere else (and don't you dare redefine it!)." These explain the "free variable" warnings for the variables and the "defined multiple times" warnings for the functions. To sort out this bug properly, we really need Lisp functions equivalent to C's extern. (defvar foo) and (declare-function 'foo nil) currently don't fill this need. -- Alan Mackenzie (Nuremberg, Germany).