(make-variable-buffer-local 'c-parse-state-state)
(defun c-record-parse-state-state ()
(setq c-parse-state-point (point))
+ (when (markerp (cdr (assq 'c-state-old-cpp-beg c-parse-state-state)))
+ (move-marker (cdr (assq 'c-state-old-cpp-beg c-parse-state-state)) nil)
+ (move-marker (cdr (assq 'c-state-old-cpp-end c-parse-state-state)) nil))
(setq c-parse-state-state
(mapcar
(lambda (arg)
((and c-opt-cpp-prefix
(looking-at c-noise-macro-with-parens-name-re))
(c-forward-noise-clause)))))
- (when (memq res '(t known found prefix))
- ,(when (eq type 'ref)
- `(when c-record-type-identifiers
- (c-record-ref-id c-last-identifier-range)))
+ (when (memq res '(t known found prefix maybe))
+ (when c-record-type-identifiers
+ ,(if (eq type 'type)
+ `(c-record-type-id c-last-identifier-range)
+ `(c-record-ref-id c-last-identifier-range)))
t)))
(defmacro c-forward-id-comma-list (type update-safe-pos)
(eq (char-after) ?<))
;; Maybe an angle bracket arglist.
(when (let ((c-record-type-identifiers t)
- (c-record-found-types t))
+ (c-record-found-types t)
+ (c-last-identifier-range))
(c-forward-<>-arglist nil))
- (c-add-type start (1+ pos))
(c-forward-syntactic-ws)
- (setq pos (point)
- c-last-identifier-range nil)
+ (unless (eq (char-after) ?\()
+ (setq c-last-identifier-range nil)
+ (c-add-type start (1+ pos)))
+ (setq pos (point))
(if (and c-opt-identifier-concat-key
(looking-at c-opt-identifier-concat-key))
(c-forward-syntactic-ws)
t)
- (when (and c-record-type-identifiers id-start)
+ (when (and c-record-type-identifiers id-start
+ (not (eq (char-after) ?\()))
(c-record-type-id (cons id-start id-end)))
(setq res 'template)
nil)))
;; It's an identifier that might be a type.
'maybe))))
((eq name-res 'template)
- ;; A template is a type.
+ ;; A template is sometimes a type.
(goto-char id-end)
- (setq res t))
+ (c-forward-syntactic-ws)
+ (setq res
+ (if (eq (char-after) ?\()
+ (if (c-check-type id-start id-end)
+ ;; It's an identifier that has been used as
+ ;; a type somewhere else.
+ 'found
+ ;; It's an identifier that might be a type.
+ 'maybe)
+ t)))
(t
;; Otherwise it's an operator identifier, which is not a type.
(goto-char start)
cast-end
;; Have we got a new-style C++11 "auto"?
new-style-auto
+ ;; Set when the symbol before `preceding-token-end' is known to
+ ;; terminate the previous construct, or when we're at point-min.
+ at-decl-start
;; Save `c-record-type-identifiers' and
;; `c-record-ref-identifiers' since ranges are recorded
;; speculatively and should be thrown away if it turns out
(save-rec-type-ids c-record-type-identifiers)
(save-rec-ref-ids c-record-ref-identifiers))
+ (save-excursion
+ (goto-char preceding-token-end)
+ (setq at-decl-start
+ (or (bobp)
+ (let ((tok-end (point)))
+ (c-backward-token-2)
+ (member (buffer-substring-no-properties (point) tok-end)
+ c-pre-start-tokens)))))
+
(while (c-forward-annotation)
(c-forward-syntactic-ws))
at-type
(or at-decl-end (looking-at "=[^=]"))
(not context)
- (not got-suffix))
- ;; Got something like "foo * bar;". Since we're not inside an
- ;; arglist it would be a meaningless expression because the
- ;; result isn't used. We therefore choose to recognize it as
- ;; a declaration. Do not allow a suffix since it could then
- ;; be a function call.
+ (or (not got-suffix)
+ at-decl-start))
+ ;; Got something like "foo * bar;". Since we're not inside
+ ;; an arglist it would be a meaningless expression because
+ ;; the result isn't used. We therefore choose to recognize
+ ;; it as a declaration. We only allow a suffix (which makes
+ ;; the construct look like a function call) when
+ ;; `at-decl-start' provides additional evidence that we do
+ ;; have a declaration.
(throw 'at-decl-or-cast t))
;; CASE 17