Function: c-fl-decl-end

c-fl-decl-end is a byte-compiled function defined in cc-mode.el.gz.

Signature

(c-fl-decl-end POS)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-mode.el.gz
(defun c-fl-decl-end (pos)
  ;; If POS is inside a declarator, return the position of the end of the
  ;; paren pair that terminates it, or of the end of the token that follows
  ;; the declarator, otherwise return nil.  If there is no such token, the end
  ;; of the last token in the buffer is used.  POS being in a literal is now
  ;; (2022-07) handled correctly.  POINT is not preserved.
  (goto-char pos)
  (let ((lit-start (c-literal-start))
	(lim (c-determine-limit 1000))
	enclosing-attribute pos1 ml-delim)
    (if lit-start
	(goto-char lit-start))
    (when (and lit-start c-ml-string-opener-re
	       (setq ml-delim (c-ml-string-opener-around-point)))
      (goto-char (car ml-delim)))
    (c-backward-syntactic-ws lim)
    (when (setq enclosing-attribute (c-enclosing-c++-attribute))
      (goto-char (car enclosing-attribute)) ; Only happens in C or C++ Mode.
      (c-backward-syntactic-ws lim))
    (while (and (> (point) lim)
		(memq (char-before) '(?\[ ?\()))
      (backward-char)
      (c-backward-syntactic-ws lim))
    (when (setq pos1 (c-on-identifier))
      (goto-char pos1)
      (let* ((lim1 (save-excursion
		     (and (c-beginning-of-macro)
			  (progn (c-end-of-macro) (point)))))
	     (lim+ (c-determine-+ve-limit 200))
	     (decl-res (c-forward-declarator lim+)))
	(if (or (cadr (cddr (cddr decl-res))) ; We scanned an arglist.
		(and (eq (char-after) ?\()    ; Move over a non arglist (...).
		     (prog1 (c-go-list-forward)
		       (c-forward-syntactic-ws))))
	    (if (looking-at c-symbol-char-key)
		;; Deal with baz (foo((bar)) type var), where `pos'
		;; was inside foo, but foo((bar)) is not semantically
		;; valid.  The result must be after var).
		(and
		 (goto-char pos)
		 (setq pos1 (c-on-identifier))
		 (goto-char pos1)
		 (progn
		   (c-backward-syntactic-ws lim1)
		   (eq (char-before) ?\())
		 (c-fl-decl-end (1- (point))))
	      (c-forward-over-token nil lim+) ; The , or ) after the declarator.
	      (point))
	  (if (progn (c-forward-syntactic-ws)
		     (not (eobp)))
	      (progn
		(c-forward-over-token)
		;; Cope with having POS within a syntactically invalid
		;; (...), by moving backward out of the parens and trying
		;; again.
		(when (and (eq (char-before) ?\))
			   (c-go-list-backward (point) lim1))
		  (c-fl-decl-end (point))))
	    (let ((lit-start (c-literal-start)))
	      (when lit-start
		(goto-char lit-start))
	      (c-backward-syntactic-ws)))
	  (and (>= (point) pos) (point)))))))