]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: Improve accuracy of recognition of bitfields
authorAlan Mackenzie <acm@muc.de>
Tue, 8 Nov 2022 14:55:40 +0000 (14:55 +0000)
committerAlan Mackenzie <acm@muc.de>
Tue, 8 Nov 2022 14:55:40 +0000 (14:55 +0000)
* 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.

lisp/progmodes/cc-engine.el

index 145f0cacd13cc8341fd66c19d3882b7597cc0b83..a13a0c838afb993b528a1f4766b06bf99f8a2ab9 100644 (file)
@@ -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)))