GNU bug report logs - #63285
30.0.50; CC Mode: K&R argument declaration misdetection after parenthesized type

Previous Next

Package: emacs;

Reported by: Olivier Certner <ocert.dev <at> free.fr>

Date: Thu, 4 May 2023 21:55:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 63285 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 63285 <at> debbugs.gnu.org, Olivier Certner <ocert.dev <at> free.fr>
Subject: Re: bug#63285: 30.0.50; CC Mode: K&R argument declaration
 misdetection after parenthesized type
Date: Thu, 5 Oct 2023 20:43:24 +0000
Olivier Certner <ocert.dev <at> free.fr> 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 <olce.emacs <at> certner.fr>
> 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




This bug report was last modified 1 year and 225 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.