diff options
author | Alan Mackenzie <acm@muc.de> | 2016-04-30 16:37:41 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2016-04-30 16:40:08 +0000 |
commit | 01cdbcf8347f5c4a48b231abd497c9e6060e4545 (patch) | |
tree | f63e1ea090f8caf8f90341c4db69ba1b2d3fa9d2 /lisp | |
parent | 9dc5f6d830e72420dc4d41c8f6ca1ca6b28609c0 (diff) | |
download | emacs-01cdbcf8347f5c4a48b231abd497c9e6060e4545.tar.gz |
CC Mode: Recognize a noise macro with parens after a declarator's identifier
* lisp/progmodes/cc-engine (c-forward-decl-or-cast-1): In the while loop
following comment "Skip over type decl suffix operators." insert code also
to check for noise macros with parentheses.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/cc-engine.el | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index f7a850f4118..c6aa56e11ff 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7433,36 +7433,42 @@ comment at the start of cc-engine.el for more info." (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) + ;; Skip over type decl suffix operators and trailing noise macros. + (while + (cond + ((and c-opt-cpp-prefix + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause)) - (if (eq (char-after) ?\)) - (when (> paren-depth 0) - (setq paren-depth (1- paren-depth)) - (forward-char) - t) - (when (if (save-match-data (looking-at "\\s(")) - (c-safe (c-forward-sexp 1) t) - (goto-char (match-end 1)) - t) - (when (and (not got-suffix-after-parens) - (= paren-depth 0)) - (setq got-suffix-after-parens (match-beginning 0))) - (setq got-suffix t))) - - ;; No suffix matched. We might have matched the - ;; identifier as a type and the open paren of a - ;; function arglist as a type decl prefix. In that - ;; case we should "backtrack": Reinterpret the last - ;; type as the identifier, move out of the arglist and - ;; continue searching for suffix operators. - ;; - ;; Do this even if there's no preceding type, to cope - ;; with old style function declarations in K&R C, - ;; (con|de)structors in C++ and `c-typeless-decl-kwds' - ;; style declarations. That isn't applicable in an - ;; arglist context, though. - (when (and (= paren-depth 1) + ((looking-at c-type-decl-suffix-key) + (if (eq (char-after) ?\)) + (when (> paren-depth 0) + (setq paren-depth (1- paren-depth)) + (forward-char) + t) + (when (if (save-match-data (looking-at "\\s(")) + (c-safe (c-forward-sexp 1) t) + (goto-char (match-end 1)) + t) + (when (and (not got-suffix-after-parens) + (= paren-depth 0)) + (setq got-suffix-after-parens (match-beginning 0))) + (setq got-suffix t)))) + + (t + ;; No suffix matched. We might have matched the + ;; identifier as a type and the open paren of a + ;; function arglist as a type decl prefix. In that + ;; case we should "backtrack": Reinterpret the last + ;; type as the identifier, move out of the arglist and + ;; continue searching for suffix operators. + ;; + ;; Do this even if there's no preceding type, to cope + ;; with old style function declarations in K&R C, + ;; (con|de)structors in C++ and `c-typeless-decl-kwds' + ;; style declarations. That isn't applicable in an + ;; arglist context, though. + (when (and (= paren-depth 1) (not got-prefix-before-parens) (not (eq at-type t)) (or backup-at-type @@ -7474,7 +7480,7 @@ comment at the start of cc-engine.el for more info." (eq (char-before pos) ?\))) (c-fdoc-shift-type-backward) (goto-char pos) - t)) + t))) (c-forward-syntactic-ws)) |