]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix c-in-knr-argdecl to avoid false recognition of K&R
authorAlan Mackenzie <acm@muc.de>
Fri, 13 Oct 2023 14:27:18 +0000 (14:27 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 13 Oct 2023 14:27:18 +0000 (14:27 +0000)
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

index e687f44d6570bf0cf66314ef21503ab192cda445..f5e0d21108f12bf884e36012cd98bb0b14f118f9 100644 (file)
@@ -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