'c-decl-id-start)))))
(c-font-lock-declarators
- (point-max) decl-list (cadr decl-or-cast)))
+ (min limit (point-max)) decl-list (cadr decl-or-cast)))
;; A declaration has been successfully identified, so do all the
;; fontification of types and refs that've been recorded.
(c-fontify-recorded-types-and-refs)
nil))
- ;; Restore point, since at this point in the code it has been
- ;; left undefined by c-forward-decl-or-cast-1 above.
- ((progn (goto-char start-pos) nil))
-
- ;; If point is inside a bracelist, there's no point checking it
- ;; being at a declarator.
- ((let ((paren-state (c-parse-state)))
- (setq lbrace (c-cheap-inside-bracelist-p paren-state)))
- ;; Move past this bracelist to prevent an endless loop.
- (goto-char lbrace)
- (unless (c-safe (progn (forward-list) t))
- (goto-char start-pos)
- (c-forward-token-2))
- nil)
-
- ;; If point is just after a ")" which is followed by an
- ;; identifier which isn't a label, or at the matching "(", we're
- ;; at either a macro invocation, a cast, or a
- ;; for/while/etc. statement. The cast case is handled above.
- ;; None of these cases can contain a declarator.
- ((or (and (eq (char-before match-pos) ?\))
- (c-on-identifier)
- (save-excursion (not (c-forward-label))))
- (and (eq (char-after) ?\()
- (save-excursion
- (and
- (progn (c-backward-token-2) (c-on-identifier))
- (save-excursion (not (c-forward-label)))
- (progn (c-backward-token-2)
- (eq (char-after) ?\())))))
- (c-forward-token-2) ; Must prevent looping.
- nil)
-
- ((and (not c-enums-contain-decls)
- ;; An optimization quickly to eliminate scans of long enum
- ;; declarations in the next cond arm.
- (let ((paren-state (c-parse-state)))
- (and
- (numberp (car paren-state))
- (save-excursion
- (goto-char (car paren-state))
- (c-backward-over-enum-header)))))
- (c-forward-token-2)
- nil)
(t t)))
;; It was a false alarm. Check if we're in a label (or other
(unless (or (eobp)
(looking-at "\\s(\\|\\s)"))
(forward-char))
- (setq bod-res (car (c-beginning-of-decl-1 decl-search-lim)))
- (if (and (eq bod-res 'same)
- (save-excursion
- (c-backward-syntactic-ws)
- (eq (char-before) ?\})))
- (c-beginning-of-decl-1 decl-search-lim))
-
- ;; We're now putatively at the declaration.
- (setq paren-state (c-parse-state))
- ;; At top level or inside a "{"?
- (if (or (not (setq encl-pos
- (c-most-enclosing-brace paren-state)))
- (eq (char-after encl-pos) ?\{))
- (progn
- (when (looking-at c-typedef-key) ; "typedef"
- (setq is-typedef t)
- (goto-char (match-end 0))
- (c-forward-syntactic-ws))
- ;; At a real declaration?
- (if (memq (c-forward-type t) '(t known found decltype))
- (c-font-lock-declarators (point-max) t is-typedef)))
- nil)))))
+ (c-syntactic-skip-backward "^;{}" decl-search-lim t)
+ (when (eq (char-before) ?})
+ (c-go-list-backward) ; brace block of struct, etc.?
+ (c-syntactic-skip-backward "^;{}" decl-search-lim t))
+ (when (or (bobp)
+ (memq (char-before) '(?\; ?{ ?})))
+ (c-forward-syntactic-ws)
+ ;; We're now putatively at the declaration.
+ (setq paren-state (c-parse-state))
+ ;; At top level or inside a "{"?
+ (if (or (not (setq encl-pos
+ (c-most-enclosing-brace paren-state)))
+ (eq (char-after encl-pos) ?\{))
+ (progn
+ (when (looking-at c-typedef-key) ; "typedef"
+ (setq is-typedef t)
+ (goto-char (match-end 0))
+ (c-forward-syntactic-ws))
+ ;; At a real declaration?
+ (if (memq (c-forward-type t) '(t known found decltype))
+ (c-font-lock-declarators limit t is-typedef)))))))
+ nil))
(defun c-font-lock-enclosing-decls (limit)
;; Fontify the declarators of (nested) declarations we're in the middle of.
;; Fontification".
(let* ((paren-state (c-parse-state))
(decl-search-lim (c-determine-limit 1000))
- decl-context in-typedef ps-elt)
+ in-typedef ps-elt)
;; Are we in any nested struct/union/class/etc. braces?
(while paren-state
(setq ps-elt (car paren-state)
(when (and (atom ps-elt)
(eq (char-after ps-elt) ?\{))
(goto-char ps-elt)
- (setq decl-context (c-beginning-of-decl-1 decl-search-lim)
- in-typedef (looking-at c-typedef-key))
- (if in-typedef (c-forward-token-2))
- (when (and c-opt-block-decls-with-vars-key
- (looking-at c-opt-block-decls-with-vars-key))
- (goto-char ps-elt)
- (when (c-safe (c-forward-sexp))
- (c-forward-syntactic-ws)
- (c-font-lock-declarators limit t in-typedef)))))))
+ (c-syntactic-skip-backward "^;{}" decl-search-lim)
+ (when (or (bobp)
+ (memq (char-before) '(?\; ?})))
+ (c-forward-syntactic-ws)
+ (setq in-typedef (looking-at c-typedef-key))
+ (if in-typedef (c-forward-token-2))
+ (when (and c-opt-block-decls-with-vars-key
+ (looking-at c-opt-block-decls-with-vars-key))
+ (goto-char ps-elt)
+ (when (c-safe (c-forward-sexp))
+ (c-forward-syntactic-ws)
+ (c-font-lock-declarators limit t in-typedef))))))))
(defun c-font-lock-raw-strings (limit)
;; Fontify C++ raw strings.
'font-lock-comment-face)
;; Handle the case when the fontified region starts inside a
;; comment.
- (let ((range (c-literal-limits)))
+ (let ((start (c-literal-start)))
(setq region-beg (point))
- (when range
- (goto-char (car range)))
+ (when start
+ (goto-char start))
(when (looking-at prefix)
(setq comment-beg (point)))))