summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-langs.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2018-01-28 17:53:07 +0000
committerAlan Mackenzie <acm@muc.de>2018-01-28 17:53:07 +0000
commita718e1593ae7332fafe734f880181e2d8ecc34df (patch)
tree0c5fba91628217df4bba90f25ee6dace9572f901 /lisp/progmodes/cc-langs.el
parent36c8128e740ce91af10769bef46a21a72dafc56c (diff)
downloademacs-a718e1593ae7332fafe734f880181e2d8ecc34df.tar.gz
Fix some errors in c-display-defun-name when the type is "struct {..}", etc.
Also fix some errors with c-display-defun-name when there are nested classes. * lisp/progmodes/cc-cmds.el (c-in-function-trailer-p): Deal with a struct {..} being merely the type of a function. (c-where-wrt-brace-construct): Deal with a struct {..} being merely the type of a function. Rearrange the order of some Lisp forms. Insert a check for c-protection-key ("private", etc.) alongside the checking for a label. (c-defun-name-1): New function extracted form c-defun-name, which works within the existing restriction. Don't regard 'at-function-end as being within the defun any more. Recognize "struct", etc., with the new c-defun-type-name-decl-key rather than c-type-prefix-key. Make the recognition of a normal function more accurate. (c-defun-name): Part left after extracting the above function. It now just widens and calls c-defun-name-1. (c-declaration-limits-1): New function extracted from c-declaration-limits, which works within the existing restriction. Move LIM back one block to account for the possibility of struct {..} as a function type. Check we're not inside a declaration without braces. (c-declaration-limits): Part left after extracting the above function. It now just narrows to an enclosing decl block and calls c-declaration-limits-1. (c-defun-name-and-limits): New function which identifies the name and limits of the most nested enclosing declaration or macro. (c-display-defun-name): Use c-defun-name-and-limits rather than two separate functions (which didn't always agree on which function). * lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): If we have struct {..} as the type of a function, go back over this, too. * lisp/progmodes/cc-langs.el (c-defun-type-name-decl-kwds) (c-defun-type-name-decl-key): New lang const/var.
Diffstat (limited to 'lisp/progmodes/cc-langs.el')
-rw-r--r--lisp/progmodes/cc-langs.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index c06dd2164db..f1ef89a76ad 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2107,6 +2107,18 @@ will be handled."
"Alist associating keywords in c-other-decl-block-decl-kwds with
their matching \"in\" syntactic symbols.")
+(c-lang-defconst c-defun-type-name-decl-kwds
+ "Keywords introducing a named block, where the name is a \"defun\"
+ name."
+ t (append (c-lang-const c-class-decl-kwds)
+ (c-lang-const c-brace-list-decl-kwds)))
+
+(c-lang-defconst c-defun-type-name-decl-key
+ ;; Regexp matching a keyword in `c-defun-name-decl-kwds'.
+ t (c-make-keywords-re t (c-lang-const c-defun-type-name-decl-kwds)))
+(c-lang-defvar c-defun-type-name-decl-key
+ (c-lang-const c-defun-type-name-decl-key))
+
(c-lang-defconst c-typedef-decl-kwds
"Keywords introducing declarations where the identifier(s) being
declared are types.