From 97959349651a8fb170c1c754e73a4d86ed24d018 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 13 Oct 2023 14:27:18 +0000 Subject: [PATCH] Fix c-in-knr-argdecl to avoid false recognition of K&R In the OP's test case, the type of a declaration was a macro with parentheses, which confused c-in-knr-argdecl. * lisp/progmodes/cc-engine.el (c-in-knr-argdecl): Amend this function to return nil if a "parameter declaration" can't be parsed as a declaration. --- lisp/progmodes/cc-engine.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index e687f44d657..f5e0d21108f 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12266,11 +12266,14 @@ comment at the start of cc-engine.el for more info." ;; 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 -- 2.39.5