From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Certner Newsgroups: gmane.emacs.bugs Subject: bug#63285: Acknowledgement (30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type) Date: Thu, 04 May 2023 23:57:14 +0200 Message-ID: <2259646.viN5riZIyJ@ravel> References: <51034426.rt4x2z8vUf@ravel> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2005188.mIT35NG9lc" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31203"; mail-complaints-to="usenet@ciao.gmane.io" To: 63285@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 04 23:58:10 2023 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 1pugxm-0007sO-1A for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 May 2023 23:58:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pugxf-0001eA-OF; Thu, 04 May 2023 17:58:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pugxe-0001dr-JU for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 17:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pugxe-00066P-B8 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 17:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pugxe-00034E-79 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 17:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Olivier Certner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 May 2023 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63285 X-GNU-PR-Package: emacs Original-Received: via spool by 63285-submit@debbugs.gnu.org id=B63285.168323743911721 (code B ref 63285); Thu, 04 May 2023 21:58:02 +0000 Original-Received: (at 63285) by debbugs.gnu.org; 4 May 2023 21:57:19 +0000 Original-Received: from localhost ([127.0.0.1]:52239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pugww-00032z-JM for submit@debbugs.gnu.org; Thu, 04 May 2023 17:57:18 -0400 Original-Received: from smtp2-g21.free.fr ([212.27.42.2]:16996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pugwt-00032o-TB for 63285@debbugs.gnu.org; Thu, 04 May 2023 17:57:16 -0400 Original-Received: from ravel.localnet (unknown [90.118.140.172]) (Authenticated sender: ocert.dev@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id E9B6E2003A4 for <63285@debbugs.gnu.org>; Thu, 4 May 2023 23:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1683237435; bh=EH1u3aq4CrOiCAcY4gSfm76wCmkab6X7XFd/QiGBvdc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EL6jOVyTPcuE1KjjeyzJBbhpQMhlnrPadXWecbqAspkXL5/+jtVMFsEpaogHUuE3m owhRLkkBMiPCKdj/ZExWuI7vlqU/6snbRXdwUa2+jZ2ZeV6+xLApxjJ+fKJHqH323u 5r2AhnlwscNhhRmC64M7iBHI7+Dhxz+ZNjjcKHP9YkWk8F10dF7kBVZRdRFhl8Dcyi V0neRhxh9fEJZ1Mw3GMCEtXKcXn60swJVRSLGAyCv0uXUvtkNYFnEo7LLq6KpLWXeQ gf5kmNhQkHtYHZVhnlWNCXS0OUlR4GmR7ycJWxNwEHHNRsNCT8MZgH0UtpcexV/Pu7 n7b6yIaKVE3xw== In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261036 Archived-At: This is a multi-part message in MIME format. --nextPart2005188.mIT35NG9lc Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Proposed fix. Applies on master (b28d44d4226497c4b258). -- Olivier Certner --nextPart2005188.mIT35NG9lc Content-Disposition: attachment; filename="0001-CC-Mode-Fix-K-R-argument-declaration-misdetection-af.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="unicode-2-0-utf-8"; name="0001-CC-Mode-Fix-K-R-argument-declaration-misdetection-af.patch" >From 249226b450b88c423b8d395c220ddf5a00ef9332 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Wed, 3 May 2023 11:44:43 +0200 Subject: [PATCH] CC Mode: Fix K&R argument declaration misdetection after parenthesized type * lisp/progmodes/cc-engine.el (c-in-knr-argdecl): When trying to loop over candidate declarations (between the function declaration's identifier list's end and point) to check whether the names of their identifiers correspond with that of the identifier list, actually fail as soon as stumbling on something other than a declaration instead of silently succeeding, which causes some constructs to be erroneously recognized as K&R argument declarations. (Bug#63285) --- lisp/progmodes/cc-engine.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 8b34daf03c2..0d9f0fec03b 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12039,17 +12039,25 @@ c-in-knr-argdecl ;; Each time around the following checks one ;; declaration (which may contain several identifiers). (while (and - (consp (setq decl-or-cast + (or + (and + (consp + (setq decl-or-cast (c-forward-decl-or-cast-1 after-prec-token nil ; Or 'arglist ??? nil))) - (memq (char-after) '(?\; ?\,)) - (goto-char (car decl-or-cast)) - (save-excursion - (setq semi-position+1 - (c-syntactic-re-search-forward - ";" (+ (point) 1000) t))) + (memq (char-after) '(?\; ?\,)) + (goto-char (car decl-or-cast)) + (save-excursion + (setq semi-position+1 + (1+ (or + (c-syntactic-re-search-forward + ";" (point) t) + (1- (point-max))))))) + ;; Can't parse declarations correctly, + ;; bail out. + (throw 'knr nil)) (c-do-declarators semi-position+1 t nil nil (lambda (id-start id-end _next _not-top -- 2.39.2 --nextPart2005188.mIT35NG9lc--