From debbugs-submit-bounces@debbugs.gnu.org Thu May 04 17:54:59 2023 Received: (at submit) by debbugs.gnu.org; 4 May 2023 21:54:59 +0000 Received: from localhost ([127.0.0.1]:52234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puguh-0002vp-1x for submit@debbugs.gnu.org; Thu, 04 May 2023 17:54:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:48178) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puguf-0002vb-Pl for submit@debbugs.gnu.org; Thu, 04 May 2023 17:54:58 -0400 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 1puguf-0001Ho-34 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 17:54:57 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pugud-0004CT-1l for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 17:54:56 -0400 Received: from ravel.localnet (unknown [90.118.140.172]) (Authenticated sender: ocert.dev@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id 48DE22005A2 for ; Thu, 4 May 2023 23:54:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1683237290; bh=hlmK9LEvFcX1qmdHOR3FCKgZciV9kATZj/308oNf7PA=; h=From:To:Subject:Date:From; b=kAPW4Bkc86mSHYjtvI4TNDhBK5Rncgiq34cnUYOY2ToHl4Xq47jg//MkKj9+wrQmt nEgaJKot98QXYBbDba5fh7uYZK5Xo5A33JAqxGIpxaHcZgq11FaVkvf48yA1OLLBpL NG76kmtRrof6pPRqylLTd8kBHKXGK1MgH6hZxSMA+Xh9wy7O1QGQAJ8bgRsgdjypw2 5afIObiLOfz9W3gueQ9ZsZDjWDdzlZ4q6KDQqKoOXY4mgHB0YiXiXKSiROGyidBap7 GyNumohLgz8uEeL1YwGxaE5I2c51P+NpThIN0AKIPnjXvoYRTZ/iXcG2wcHOOz74Cd BcEEIbBolIDUQ== From: Olivier Certner To: bug-gnu-emacs@gnu.org Subject: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Date: Thu, 04 May 2023 23:54:49 +0200 Message-ID: <51034426.rt4x2z8vUf@ravel> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart7159597.J8PY2HnTC3" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=212.27.42.2; envelope-from=ocert.dev@free.fr; helo=smtp2-g21.free.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) This is a multi-part message in MIME format. --nextPart7159597.J8PY2HnTC3 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Hello, See attached 2-line reproducer. E.g., type `C-c C-s' on the second line. Fix to be attached as soon as the bug is created. Regards. -- Olivier Certner --nextPart7159597.J8PY2HnTC3 Content-Disposition: attachment; filename="test.c" Content-Transfer-Encoding: 7Bit Content-Type: text/x-csrc; charset="unicode-2-0-utf-8"; name="test.c" PROD_TYPE(element) element_list; int a; --nextPart7159597.J8PY2HnTC3-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 04 17:57:19 2023 Received: (at 63285) by debbugs.gnu.org; 4 May 2023 21:57:19 +0000 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 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 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== From: Olivier Certner To: 63285@debbugs.gnu.org Subject: Re: 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> In-Reply-To: References: <51034426.rt4x2z8vUf@ravel> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2005188.mIT35NG9lc" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63285 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 04 18:14:53 2023 Received: (at 63285) by debbugs.gnu.org; 4 May 2023 22:14:53 +0000 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 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 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== From: Olivier Certner To: 63285@debbugs.gnu.org Subject: Re: 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> In-Reply-To: <51034426.rt4x2z8vUf@ravel> References: <51034426.rt4x2z8vUf@ravel> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2495327.DBfJszHHAy" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63285 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 05 16:43:52 2023 Received: (at 63285) by debbugs.gnu.org; 5 Oct 2023 20:43:52 +0000 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 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 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) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 20:43:24 +0000 From: Stefan Kangas In-Reply-To: <2329887.yEB1Cff6dg@ravel> References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> MIME-Version: 1.0 Date: Thu, 5 Oct 2023 20:43:24 +0000 Message-ID: Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63285 Cc: 63285@debbugs.gnu.org, Olivier Certner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 05 16:44:22 2023 Received: (at control) by debbugs.gnu.org; 5 Oct 2023 20:44:22 +0000 Received: from localhost ([127.0.0.1]:48621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoVCn-0006hq-OT for submit@debbugs.gnu.org; Thu, 05 Oct 2023 16:44:21 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]:49238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoVCl-0006ha-2D for control@debbugs.gnu.org; Thu, 05 Oct 2023 16:44:20 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c00df105f8so17154961fa.2 for ; Thu, 05 Oct 2023 13:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696538634; x=1697143434; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=S2v8tALoihTF9D8ywObi0opMuQYLOQvIO2Kc4zxWS3Q=; b=nk1ndn+lS8SbTdnmlQUT6VYD3dYGXaHbk616vEEzeWOLoVEJVUiez7PyU6lEeTZHe6 wmLD++y3PCJte/NS0mvPoL6iZtmZL3Vqamv3gRz5LIb3nFuigsOaH4VR7D0Z5D7c0ISE XcGyFL+SWPaCjahbg5Uiz+uvMGK+ebI7JwpoJKVmg8Yv/Su8S0hLUdB9Q+CCjtyP2rbT oidjQdXZFpad3bnlLRHQd8x5HgdatA07sTLja/vpRdSVFCb9EBRUuCUE3PaNRI1typom 90NlX7cWyEz0vjv+oLTjuKAyN2xEimUoKwdy7OQ/aoE9A4zGXlOvQS/iuWQIKEUw9T8s d9yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696538634; x=1697143434; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=S2v8tALoihTF9D8ywObi0opMuQYLOQvIO2Kc4zxWS3Q=; b=l6kXLluLp4aPNhZAdTr6MWTphq3CUJYwrgg7wXd/LQQsA6dN2EgNrPSBysEUtY9srU fC0UzdvhnVPmJH0BP1cIi5kJjAtQ07sEO9DfRh2flArZzG36yQNkGke1QwdKFMeeParL NVpnTigF082NUkrclr6Ypx0FweFH5nrNEU9AhuNI8oKGs589pVFvHoZir3eVApSzJPyY xRJrnmSRiIFBsn09zFhu6qj5UoQx75y+6igZ/85KDpvIKHw+oZogQnlGTJcnpEWOJDMg ZRYe2trDf7c0BG6KWKw1QE/IhNkS6DDtfPaqG5QjH5Dj0wi11izLVU8lm3RYlIz57Uhg 9pHg== X-Gm-Message-State: AOJu0Yy0DTi0B3HGpzQl6ypBgbtuqhx831gXRr5PX8GoAR2TbujWC756 SnBM8INuuxeyuSD6H9TEcteeXmVCMKlOTibAAGxQzpW/ X-Google-Smtp-Source: AGHT+IHvz7E2DSeHh7HUJPfasAwmTNvKqhja34oeuM/yvrsXnpLVUM376VaXdjvpBhaibBXQxwyRAXnlmmg+8uv6kq8= X-Received: by 2002:a19:ca07:0:b0:503:108:8602 with SMTP id a7-20020a19ca07000000b0050301088602mr5503433lfg.9.1696538634656; Thu, 05 Oct 2023 13:43:54 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 20:43:54 +0000 From: Stefan Kangas MIME-Version: 1.0 Date: Thu, 5 Oct 2023 20:43:54 +0000 Message-ID: Subject: To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 63285 + patch thanks Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:234 listed in] [list.dnswl.org] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 2.0 BLANK_SUBJECT Subject is present but empty X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) tags 63285 + patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 06 05:10:28 2023 Received: (at 63285) by debbugs.gnu.org; 6 Oct 2023 09:10:28 +0000 Received: from localhost ([127.0.0.1]:49118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qogqq-0008Cd-7n for submit@debbugs.gnu.org; Fri, 06 Oct 2023 05:10:28 -0400 Received: from mail.muc.de ([193.149.48.3]:27181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qogqn-0008C6-Ca for 63285@debbugs.gnu.org; Fri, 06 Oct 2023 05:10:26 -0400 Received: (qmail 47580 invoked by uid 3782); 6 Oct 2023 11:09:59 +0200 Received: from acm.muc.de (pd953a487.dip0.t-ipconnect.de [217.83.164.135]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 Oct 2023 11:09:58 +0200 Received: (qmail 4962 invoked by uid 1000); 6 Oct 2023 09:09:57 -0000 Date: Fri, 6 Oct 2023 09:09:57 +0000 To: Stefan Kangas Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Message-ID: References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63285 Cc: 63285@debbugs.gnu.org, Olivier Certner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Stefan. On Thu, Oct 05, 2023 at 20:43:24 +0000, Stefan Kangas wrote: > 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? I'm looking at the bug, now. I'll get back again once I think I understand it. ;-) > Thanks in advance. [ .... ] -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 06 09:18:30 2023 Received: (at 63285) by debbugs.gnu.org; 6 Oct 2023 13:18:30 +0000 Received: from localhost ([127.0.0.1]:49453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qokir-0003q1-NZ for submit@debbugs.gnu.org; Fri, 06 Oct 2023 09:18:30 -0400 Received: from mail.muc.de ([193.149.48.3]:34767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qokiq-0003pn-5K for 63285@debbugs.gnu.org; Fri, 06 Oct 2023 09:18:28 -0400 Received: (qmail 30135 invoked by uid 3782); 6 Oct 2023 15:18:02 +0200 Received: from acm.muc.de (pd953a487.dip0.t-ipconnect.de [217.83.164.135]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 Oct 2023 15:18:02 +0200 Received: (qmail 6610 invoked by uid 1000); 6 Oct 2023 13:18:01 -0000 Date: Fri, 6 Oct 2023 13:18:01 +0000 To: Olivier Certner , Stefan Kangas Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Message-ID: References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63285 Cc: acm@muc.de, 63285@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Olivier and Stefan. On Thu, Oct 05, 2023 at 20:43:24 +0000, Stefan Kangas wrote: > Olivier Certner writes: > > Sorry, I had clobbered the "(+ (point) 1000)" part in the previous patch. > > > > Please use this one instead. Olivier, thanks for taking the trouble to submit this bug report. Sorry it's taken me so long to getting around to looking at it. > 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. I don't think this would be quite the right way to go. It would be too rigorous in rejecting partially written K&R constructs which might cause them to be excessively reindented as commas and or semicolons get typed. It seems that (throw 'knr nil) when the c-forward-decl-or-cast-1 form fails is sufficient to prevent the wrong recognition of your test file's line 2 as a K&R declaration. Please feel free to try out my (simpler) patch below on your real C code. Also, I propose adopting your 2-line test file, reindented, as a new test in the CC Mode test suite. Please let me know if you'd prefer that not to happen. > > (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 Here's my amended patch: diff -r b680bbba3141 cc-engine.el --- a/cc-engine.el Fri Sep 29 11:15:58 2023 +0000 +++ b/cc-engine.el Fri Oct 06 11:22:31 2023 +0000 @@ -12285,11 +12285,14 @@ ;; 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))) + (not (eq (char-after) ?{)) + (or + (consp (setq decl-or-cast + (c-forward-decl-or-cast-1 + after-prec-token + nil ; Or 'arglist ??? + nil))) + (throw 'knr nil)) (memq (char-after) '(?\; ?\,)) (goto-char (car decl-or-cast)) (save-excursion -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 13 10:39:34 2023 Received: (at 63285-done) by debbugs.gnu.org; 13 Oct 2023 14:39:34 +0000 Received: from localhost ([127.0.0.1]:47049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrJKA-0004jH-JO for submit@debbugs.gnu.org; Fri, 13 Oct 2023 10:39:34 -0400 Received: from mail.muc.de ([193.149.48.3]:55073) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrJK4-0004iu-Ed for 63285-done@debbugs.gnu.org; Fri, 13 Oct 2023 10:39:32 -0400 Received: (qmail 38779 invoked by uid 3782); 13 Oct 2023 16:38:58 +0200 Received: from acm.muc.de (pd953a199.dip0.t-ipconnect.de [217.83.161.153]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 13 Oct 2023 16:38:57 +0200 Received: (qmail 16014 invoked by uid 1000); 13 Oct 2023 14:38:56 -0000 Date: Fri, 13 Oct 2023 14:38:56 +0000 To: Stefan Kangas Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type Message-ID: References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63285-done Cc: acm@muc.de, 63285-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Stefan. I've committed a patch which fixes this bug. I'm now closing it. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 13 11:05:12 2023 Received: (at 63285-done) by debbugs.gnu.org; 13 Oct 2023 15:05:12 +0000 Received: from localhost ([127.0.0.1]:47076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrJix-0005ZO-O0 for submit@debbugs.gnu.org; Fri, 13 Oct 2023 11:05:11 -0400 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]:51304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrJiu-0005Yr-5a for 63285-done@debbugs.gnu.org; Fri, 13 Oct 2023 11:05:10 -0400 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c50cd16f3bso4618381fa.2 for <63285-done@debbugs.gnu.org>; Fri, 13 Oct 2023 08:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697209478; x=1697814278; 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=ZeE0cZ/sxs0p1e7A8XwfBGwU2jgAB5abJ4m6iEsycvU=; b=RzZ3Xu6P8p4tdHzmfCOkibNZdQ0xr5LIovKrtT9I9RC8RvSM2VyNI+pMEV4FVb2K7Y aH1ms7G1lWjuXgt9y1Vo0VLsLXIk8JAZUXWAQhi3Vi8bp7oSV78tm9kkQXFhy9YowYC4 wS9B3RP1tLLgFZ8/SMM4ZxdFzCbktetbfVGei+UPfP08LUn+kXP5iibF9cy3mZbnNDZ1 QTn5D9FEL6+MpGYk5aTIeDsmHSosrfG9YxyJUNLVK46/iZMUiZKEDk9pACuQ19bfPiRs PBGPq8ZVxREFaSmW8s8oMY0FmMr8tu09Df2esJwBBDkPRhdCt7i+Oqlo1GCEUBLuIArq oeyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697209478; x=1697814278; 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=ZeE0cZ/sxs0p1e7A8XwfBGwU2jgAB5abJ4m6iEsycvU=; b=kvm7hTHVBhZBc2EM5Bxo2Biq26CMifC+19CiBTUXgD3ZB4uADzwsuCRLChtjd6eEWg J/J7Tc2HLYhPcrGJDbtbLeFjL0ba/2uVhwxpgVLvUXwR1A7Y15R1PyyN/uuER8jmKurK cR5Q6fhHP9M16mn/yTHMDs9QtLX1BWB1jtKB3nUFRvon82lIi1jlcRg46226Pr4ISFRQ 6DiH81cFpDtmxDQrNxKOpKJ6ARfAmeIKuJ+vWpHlgaXr1vy1gTzNZoOwFWds/aQiN0eU bp1HdIzy3u4133EAzkMSykpDyCLP2qLFLS6fpj1gJyqWZLTt/HE5hUgDXfW6ZQAbPMCC cx+Q== X-Gm-Message-State: AOJu0Yz2munoMGuJ5htbtn0onPvExLtesNx+uXTZfj7QBtLwKZCoiB6I kbzE/HmKsRJlsAahc5xOFLLbc1ViB7XRPrTy+9s= X-Google-Smtp-Source: AGHT+IEfqtYcKw6bWEsQmVvxQnDSgRSiMOhq5wZTZxryZPWJtG5Vljeo1S9roAQ225GM07OkUQRgP5sLbDSA3iaUwoU= X-Received: by 2002:a2e:87d0:0:b0:2bc:d5f1:b9cf with SMTP id v16-20020a2e87d0000000b002bcd5f1b9cfmr23301833ljj.27.1697209477928; Fri, 13 Oct 2023 08:04:37 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 13 Oct 2023 15:04:37 +0000 From: Stefan Kangas In-Reply-To: References: <51034426.rt4x2z8vUf@ravel> <2329887.yEB1Cff6dg@ravel> MIME-Version: 1.0 Date: Fri, 13 Oct 2023 15:04:37 +0000 Message-ID: Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63285-done Cc: 63285-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Alan Mackenzie writes: > I've committed a patch which fixes this bug. I'm now closing it. Thanks! From unknown Mon Jun 23 23:52:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 11 Nov 2023 12:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator