From d3090a3a3e22c4b0f4e0e833942f5942eb392c51 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 2 Feb 2018 20:46:35 +0000 Subject: [PATCH] CC Mode: Fix an enum intro being parsed as defun-block-intro * 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 | 14 ++++++-------- lisp/progmodes/cc-fonts.el | 7 +++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index ceeee6b357d..be7e86beefc 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -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 diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index fa9b8f354ef..7cac55e057f 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -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)) -- 2.39.2