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: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Date: Fri, 05 May 2023 00:14:48 +0200 Message-ID: <2329887.yEB1Cff6dg@ravel> References: <51034426.rt4x2z8vUf@ravel> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2495327.DBfJszHHAy" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31867"; 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 Fri May 05 00:15:24 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 1puhER-00085M-Jb for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 May 2023 00:15:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puhE9-0004EJ-0e; Thu, 04 May 2023 18:15:05 -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 1puhE6-0004E7-IN for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 18:15: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 1puhE6-0005Vi-8M for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 18:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puhE6-0003YU-0I for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 18:15: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 22:15:01 +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.168323849313632 (code B ref 63285); Thu, 04 May 2023 22:15:01 +0000 Original-Received: (at 63285) by debbugs.gnu.org; 4 May 2023 22:14:53 +0000 Original-Received: from localhost ([127.0.0.1]:52271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puhDx-0003Xo-Bu for submit@debbugs.gnu.org; Thu, 04 May 2023 18:14:53 -0400 Original-Received: from smtp2-g21.free.fr ([212.27.42.2]:42604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puhDu-0003Xc-Ly for 63285@debbugs.gnu.org; Thu, 04 May 2023 18:14:51 -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 478F82003BE for <63285@debbugs.gnu.org>; Fri, 5 May 2023 00:14:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1683238489; bh=fcSDdab/OEcC2NYi0kV8gir2rRuKv6WwxaGkgz2OKng=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TOrfQePMq++BnSfYnvKKLNFVWpUlZHnJ+H6qGJwbk7NcZZoW6o+dKKa3zCsz5+pvH kijXLFmC0HDasuvNN7F951iiwWhyfjxA5awWvYE+DDLtPrnaL54gdM0YMNrP1UVRrK CYRV2vhc5CIk34K9/ROy2ARjxc/pzx00cgwFDuh1zQ0YCMggtDTLKz1cKHj889Ibr+ W72Nme+diRpbyjsEcHbE2EV10TTn++DdMiGVxHY2PTa2KZ8vYcNWRUFBdUx2+2/+cC uB8hwJ4T0ZxjHHgdFFf08b7jvF5yWsXtykOZXs/EjR3WVEsN9zlq1XhGm691MtXss9 TD3e8ThldXJjg== In-Reply-To: <51034426.rt4x2z8vUf@ravel> 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:261038 Archived-At: This is a multi-part message in MIME format. --nextPart2495327.DBfJszHHAy Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Sorry, I had clobbered the "(+ (point) 1000)" part in the previous patch. Please use this one instead. -- Olivier Certner --nextPart2495327.DBfJszHHAy 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 0515de23d84a48c57b456c6730f826c5d783b965 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 | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 8b34daf03c2..27740b4903c 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12039,17 +12039,24 @@ c-in-knr-argdecl ;; Each time around the following checks one ;; declaration (which may contain several identifiers). (while (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))) + (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 + (1+ (or + (c-syntactic-re-search-forward + ";" (+ (point) 1000) 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 --nextPart2495327.DBfJszHHAy--