From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Date: Thu, 5 Oct 2023 20:43:24 +0000 Message-ID: References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12031"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63285@debbugs.gnu.org, Olivier Certner To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 05 22:44:00 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 1qoVCO-0002sb-KA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Oct 2023 22:43:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoVCD-0005tD-MA; Thu, 05 Oct 2023 16:43:45 -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 1qoVCB-0005s2-Mv for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 16:43:43 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qoVCB-0006Ye-EZ for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 16:43:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qoVCT-0006h4-Q5 for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 16:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Oct 2023 20:44: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.169653863225704 (code B ref 63285); Thu, 05 Oct 2023 20:44:01 +0000 Original-Received: (at 63285) by debbugs.gnu.org; 5 Oct 2023 20:43:52 +0000 Original-Received: from localhost ([127.0.0.1]:48617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoVCK-0006gW-51 for submit@debbugs.gnu.org; Thu, 05 Oct 2023 16:43:52 -0400 Original-Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:50643) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoVCH-0006gH-HD for 63285@debbugs.gnu.org; Thu, 05 Oct 2023 16:43:50 -0400 Original-Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5046bf37daeso1870860e87.1 for <63285@debbugs.gnu.org>; Thu, 05 Oct 2023 13:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696538605; x=1697143405; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=1Fvc9PiaPUgguw2FmrvxqzlSv/Yr0LfHwnKA9nsFlZw=; b=Ig0qaze3ayCVMKYLNEBvO9LKb+UgXTIEfOSlMOij6Rdrd9W4HJ0oScKevkvbPrZDGJ MZIOXbMCoPRGcvSVu6RvEPPDS79NQNf5KtOo5/yQdDSohCiVLi/IM1F+mud9X+TjEnsC kqSavHNeFRGbflfrMJsMI1VytTLuEP/vMbdkftPZYzGiQCg4BFPG5mnXyz0me/MIdKtk IT6gtlQyzps+CPSREJGYLw+wBeFXABe78LtnqktrFghs+mZa8gsFYXlAl3DQLg8IYSVt oqkZaGP4BhX1dZ70GkqC37+k2wmivIqLzkGddKpjsynA23qz/4oEy09DGGCcmBgzj1Xp ZjMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696538605; x=1697143405; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Fvc9PiaPUgguw2FmrvxqzlSv/Yr0LfHwnKA9nsFlZw=; b=qKs2EtMOlXxpInE1sFRoPTdQ459AtvQU9j74qFItxsiMSDtRHWoJsRZFzKYMO6pcEO 5tWEeKhuwZUlqStfoZMTphOT6cY6W5w5ESII1x8WAU3xbIl1J0f89iF4o+hRwyiUS2Lw hpp5GCJwt/MP4IgEo0grkwRbf2htid3dbFw8U3XE0sz0GNP03VtLAotgkX6tFTd5B+M4 ZO2vrAZBnPNCuFMwIGIeoSRZAPn3LY44szEtBI5hXF554C5ik4eiz5Nkwvp1xj0sE8yr 2Br1ZDEeJYXnI4S36XzmfRuESdpKoVuKrUd95IDSGMFOFx4Kx8QcurDUFXLpbvL1YD7R NKmQ== X-Gm-Message-State: AOJu0Yz3clHFOCmDBv3mFKcSlOY1l7dy+vxz1HTe5rAhjDEz2rDan0Tp 9iu5dqhnkcurrWk++aWF0RRWPdNybeOtFMQ0qHs= X-Google-Smtp-Source: AGHT+IGfhWFDAVJ77hiRx4U+neFpwXyrhESOwUbVOvFChV8RMcXleCqcwMNxm0IdGu4myBBtHw1AbejfdArOxnA2q1g= X-Received: by 2002:a05:6512:3154:b0:500:a08e:2fcf with SMTP id s20-20020a056512315400b00500a08e2fcfmr4630281lfi.47.1696538604603; Thu, 05 Oct 2023 13:43:24 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 20:43:24 +0000 In-Reply-To: <2329887.yEB1Cff6dg@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:271921 Archived-At: Olivier Certner writes: > Sorry, I had clobbered the "(+ (point) 1000)" part in the previous patch. > > Please use this one instead. Alan, could you please take a look at the below patch? Thanks in advance. > 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