From: Alan Mackenzie Date: Tue, 8 Nov 2022 14:55:40 +0000 (+0000) Subject: CC Mode: Improve accuracy of recognition of bitfields X-Git-Tag: emacs-29.0.90~1616^2~241 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5fa0fcf18bb23f3a6f028a1478644b7027b02d8c;p=emacs.git CC Mode: Improve accuracy of recognition of bitfields * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): When we've got two identifiers followed by a colon, additionally check for a number (or identifier) followed by a semicolon or comma before concluding we have a bitfield. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 145f0cacd13..a13a0c838af 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10773,7 +10773,15 @@ This function might do hidden buffer changes." ((eq at-decl-or-cast t) (throw 'at-decl-or-cast t)) ((and c-has-bitfields - (eq at-decl-or-cast 'ids)) ; bitfield. + ;; Check for a bitfield. + (eq at-decl-or-cast 'ids) + (save-excursion + (forward-char) ; Over the : + (c-forward-syntactic-ws) + (and (looking-at "[[:alnum:]]") + (progn (c-forward-token-2) + (c-forward-syntactic-ws) + (memq (char-after) '(?\; ?,)))))) (setq backup-if-not-cast t) (throw 'at-decl-or-cast t)))