CC Mode: Fix an enum intro being parsed as defun-block-intro
authorAlan Mackenzie <acm@muc.de>
Fri, 2 Feb 2018 20:46:35 +0000 (20:46 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 2 Feb 2018 20:46:35 +0000 (20:46 +0000)
* lisp/progmodes/cc-engine.el (c-inside-bracelist-p): Return a bufpos rather
than t for the enum case.
(c-add-stmt-syntax, c-guess-continued-construct): Replace
c-looking-at-or-maybe-in-bracelist by c-inside-bracelist-p, since the former
does not recognize enum brace lists, but the latter does.

* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Replace
c-looking-at-or-maybe-in-bracelist by c-inside-bracelist-p.

lisp/progmodes/cc-engine.el
lisp/progmodes/cc-fonts.el

index ceeee6b357dbdcfd32d331acccbc603a905e2624..be7e86beefc0fc938ea672b7fe8f05cb14385d75 100644 (file)
@@ -10665,7 +10665,8 @@ comment at the start of cc-engine.el for more info."
    ;; This will pick up brace list declarations.
    (save-excursion
      (goto-char containing-sexp)
-     (c-backward-over-enum-header))
+     (and (c-backward-over-enum-header)
+         (point)))
    ;; this will pick up array/aggregate init lists, even if they are nested.
    (save-excursion
      (let ((bufpos t)
@@ -11290,9 +11291,7 @@ comment at the start of cc-engine.el for more info."
                     (cdr (assoc (match-string 1)
                                 c-other-decl-block-key-in-symbols-alist))
                     (max (c-point 'boi paren-pos) (point))))
-                  ((save-excursion
-                     (goto-char paren-pos)
-                     (c-looking-at-or-maybe-in-bracelist containing-sexp))
+                  ((c-inside-bracelist-p paren-pos paren-state nil)
                    (if (save-excursion
                          (goto-char paren-pos)
                          (c-looking-at-statement-block))
@@ -11384,10 +11383,9 @@ comment at the start of cc-engine.el for more info."
 
        ;; CASE B.2: brace-list-open
        ((or (consp special-brace-list)
-           (consp
-            (c-looking-at-or-maybe-in-bracelist
-             containing-sexp beg-of-same-or-containing-stmt))
-           )
+           (c-inside-bracelist-p (point)
+                                 (cons containing-sexp paren-state)
+                                 nil))
        ;; The most semantically accurate symbol here is
        ;; brace-list-open, but we normally report it simply as a
        ;; statement-cont.  The reason is that one normally adjusts
index fa9b8f354ef6195b81db557f6e2601b054637096..7cac55e057f31418c9aee35b6e2e04188f590a17 100644 (file)
@@ -1234,10 +1234,9 @@ casts and declarations are fontified.  Used on level 2 and higher."
           (cons 'decl nil))
          ;; We're inside a brace list.
          ((and (eq (char-before match-pos) ?{)
-               (save-excursion
-                 (goto-char (1- match-pos))
-                 (consp
-                  (c-looking-at-or-maybe-in-bracelist))))
+               (c-inside-bracelist-p (1- match-pos)
+                                     (cdr (c-parse-state))
+                                     nil))
           (c-put-char-property (1- match-pos) 'c-type
                                'c-not-decl)
           (cons 'not-decl nil))