summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2013-10-19 15:11:07 +0000
committerAlan Mackenzie <acm@muc.de>2013-10-19 15:11:07 +0000
commit033f22ddadf6c11b4d35108f3c299692bb3bbc60 (patch)
tree30720b2a9f090a33972c681db7026c37f13d277e
parent8d02f0ad3ba4cb4863f99579454c29e55149ffd9 (diff)
downloademacs-033f22ddadf6c11b4d35108f3c299692bb3bbc60.tar.gz
Fix fontification bugs with constructors and const.
* progmodes/cc-engine.el (c-forward-decl-or-cast-1): (Just after CASE 2) Remove the check for the absence of a suffix construct after a function declaration with only types (no identifiers) in the parentheses. Also, accept a function declaration with just a type inside the parentheses, if this type can be positively recognised as such, or if a prefix keyword like "explicit" nails down the construct as a declaration.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/cc-engine.el48
2 files changed, 41 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 883b5d7b21e..402ef8062a1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2013-10-19 Alan Mackenzie <acm@muc.de>
+
+ Fix fontification bugs with constructors and const.
+
+ * progmodes/cc-engine.el (c-forward-decl-or-cast-1): (Just after
+ CASE 2) Remove the check for the absence of a suffix construct
+ after a function declaration with only types (no identifiers) in
+ the parentheses. Also, accept a function declaration with just a
+ type inside the parentheses, if this type can be positively
+ recognised as such, or if a prefix keyword like "explicit" nails
+ down the construct as a declaration.
+
2013-10-19 Eli Zaretskii <eliz@gnu.org>
* menu-bar.el (tty-menu-navigation-map): Bind mouse-N to perform
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index d624d1eaed2..0d25e1355e7 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6917,7 +6917,9 @@ comment at the start of cc-engine.el for more info."
;; can happen since we don't know if
;; `c-restricted-<>-arglists' will be correct inside the
;; arglist paren that gets entered.
- c-parse-and-markup-<>-arglists)
+ c-parse-and-markup-<>-arglists
+ ;; Start of the identifier for which `got-identifier' was set.
+ name-start)
(goto-char id-start)
@@ -6935,7 +6937,9 @@ comment at the start of cc-engine.el for more info."
;; If the third submatch matches in C++ then
;; we're looking at an identifier that's a
;; prefix only if it specifies a member pointer.
- (when (setq got-identifier (c-forward-name))
+ (when (progn (setq pos (point))
+ (setq got-identifier (c-forward-name)))
+ (setq name-start pos)
(if (looking-at "\\(::\\)")
;; We only check for a trailing "::" and
;; let the "*" that should follow be
@@ -6961,7 +6965,9 @@ comment at the start of cc-engine.el for more info."
;; Skip over an identifier.
(or got-identifier
(and (looking-at c-identifier-start)
- (setq got-identifier (c-forward-name))))
+ (setq pos (point))
+ (setq got-identifier (c-forward-name))
+ (setq name-start pos)))
;; Skip over type decl suffix operators.
(while (if (looking-at c-type-decl-suffix-key)
@@ -7052,23 +7058,27 @@ comment at the start of cc-engine.el for more info."
;; declaration.
(throw 'at-decl-or-cast t))
- (when (and got-parens
- (not got-prefix)
- (not got-suffix-after-parens)
- (or backup-at-type
- maybe-typeless
- backup-maybe-typeless))
- ;; Got a declaration of the form "foo bar (gnu);" where we've
- ;; recognized "bar" as the type and "gnu" as the declarator.
- ;; In this case it's however more likely that "bar" is the
- ;; declarator and "gnu" a function argument or initializer (if
- ;; `c-recognize-paren-inits' is set), since the parens around
- ;; "gnu" would be superfluous if it's a declarator. Shift the
- ;; type one step backward.
- (c-fdoc-shift-type-backward)))
-
- ;; Found no identifier.
+ (when (and got-parens
+ (not got-prefix)
+ ;; (not got-suffix-after-parens)
+ (or backup-at-type
+ maybe-typeless
+ backup-maybe-typeless
+ (eq at-decl-or-cast t)
+ (save-excursion
+ (goto-char name-start)
+ (not (memq (c-forward-type) '(nil maybe))))))
+ ;; Got a declaration of the form "foo bar (gnu);" or "bar
+ ;; (gnu);" where we've recognized "bar" as the type and "gnu"
+ ;; as the declarator. In this case it's however more likely
+ ;; that "bar" is the declarator and "gnu" a function argument
+ ;; or initializer (if `c-recognize-paren-inits' is set),
+ ;; since the parens around "gnu" would be superfluous if it's
+ ;; a declarator. Shift the type one step backward.
+ (c-fdoc-shift-type-backward)))
+
+ ;; Found no identifier.
(if backup-at-type
(progn