Make c-defun-name analyze more thoroughly a function type which is a struct
This fixes bug #29293. * lisp/progmodes/cc-cmds.el (c-defun-name): When a struct (etc.) type is encountered, check whether it is the return type of a function rather than a declaration of the struct itself. Similarly adapt the cond arm which deals with functions properly to recognize struct return types.
This commit is contained in:
parent
92f0c4cd56
commit
735c8b516e
1 changed files with 19 additions and 3 deletions
|
@ -1849,7 +1849,15 @@ with a brace block."
|
|||
;; Pick out the defun name, according to the type of defun.
|
||||
(cond
|
||||
;; struct, union, enum, or similar:
|
||||
((looking-at c-type-prefix-key)
|
||||
((save-excursion
|
||||
(and
|
||||
(looking-at c-type-prefix-key)
|
||||
(consp (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil))
|
||||
(or (not (or (eq (char-after) ?{)
|
||||
(and c-recognize-knr-p
|
||||
(c-in-knr-argdecl))))
|
||||
(progn (c-backward-syntactic-ws)
|
||||
(not (eq (char-before) ?\)))))))
|
||||
(let ((key-pos (point)))
|
||||
(c-forward-over-token-and-ws) ; over "struct ".
|
||||
(cond
|
||||
|
@ -1897,8 +1905,16 @@ with a brace block."
|
|||
|
||||
(t
|
||||
;; Normal function or initializer.
|
||||
(when (c-syntactic-re-search-forward "[{(]" nil t)
|
||||
(backward-char)
|
||||
(when
|
||||
(and
|
||||
(consp (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil))
|
||||
(or (eq (char-after) ?{)
|
||||
(and c-recognize-knr-p
|
||||
(c-in-knr-argdecl)))
|
||||
(progn
|
||||
(c-backward-syntactic-ws)
|
||||
(eq (char-before) ?\)))
|
||||
(c-go-list-backward))
|
||||
(c-backward-syntactic-ws)
|
||||
(when (eq (char-before) ?\=) ; struct foo bar = {0, 0} ;
|
||||
(c-backward-token-2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue