aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2016-04-30 16:37:41 +0000
committerAlan Mackenzie2016-04-30 16:40:08 +0000
commit01cdbcf8347f5c4a48b231abd497c9e6060e4545 (patch)
treef63e1ea090f8caf8f90341c4db69ba1b2d3fa9d2
parent9dc5f6d830e72420dc4d41c8f6ca1ca6b28609c0 (diff)
downloademacs-01cdbcf8347f5c4a48b231abd497c9e6060e4545.tar.gz
emacs-01cdbcf8347f5c4a48b231abd497c9e6060e4545.zip
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.
-rw-r--r--lisp/progmodes/cc-engine.el66
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."
7433 (setq got-identifier (c-forward-name)) 7433 (setq got-identifier (c-forward-name))
7434 (setq name-start pos))) 7434 (setq name-start pos)))
7435 7435
7436 ;; Skip over type decl suffix operators. 7436 ;; Skip over type decl suffix operators and trailing noise macros.
7437 (while (if (looking-at c-type-decl-suffix-key) 7437 (while
7438 (cond
7439 ((and c-opt-cpp-prefix
7440 (looking-at c-noise-macro-with-parens-name-re))
7441 (c-forward-noise-clause))
7438 7442
7439 (if (eq (char-after) ?\)) 7443 ((looking-at c-type-decl-suffix-key)
7440 (when (> paren-depth 0) 7444 (if (eq (char-after) ?\))
7441 (setq paren-depth (1- paren-depth)) 7445 (when (> paren-depth 0)
7442 (forward-char) 7446 (setq paren-depth (1- paren-depth))
7443 t) 7447 (forward-char)
7444 (when (if (save-match-data (looking-at "\\s(")) 7448 t)
7445 (c-safe (c-forward-sexp 1) t) 7449 (when (if (save-match-data (looking-at "\\s("))
7446 (goto-char (match-end 1)) 7450 (c-safe (c-forward-sexp 1) t)
7447 t) 7451 (goto-char (match-end 1))
7448 (when (and (not got-suffix-after-parens) 7452 t)
7449 (= paren-depth 0)) 7453 (when (and (not got-suffix-after-parens)
7450 (setq got-suffix-after-parens (match-beginning 0))) 7454 (= paren-depth 0))
7451 (setq got-suffix t))) 7455 (setq got-suffix-after-parens (match-beginning 0)))
7452 7456 (setq got-suffix t))))
7453 ;; No suffix matched. We might have matched the 7457
7454 ;; identifier as a type and the open paren of a 7458 (t
7455 ;; function arglist as a type decl prefix. In that 7459 ;; No suffix matched. We might have matched the
7456 ;; case we should "backtrack": Reinterpret the last 7460 ;; identifier as a type and the open paren of a
7457 ;; type as the identifier, move out of the arglist and 7461 ;; function arglist as a type decl prefix. In that
7458 ;; continue searching for suffix operators. 7462 ;; case we should "backtrack": Reinterpret the last
7459 ;; 7463 ;; type as the identifier, move out of the arglist and
7460 ;; Do this even if there's no preceding type, to cope 7464 ;; continue searching for suffix operators.
7461 ;; with old style function declarations in K&R C, 7465 ;;
7462 ;; (con|de)structors in C++ and `c-typeless-decl-kwds' 7466 ;; Do this even if there's no preceding type, to cope
7463 ;; style declarations. That isn't applicable in an 7467 ;; with old style function declarations in K&R C,
7464 ;; arglist context, though. 7468 ;; (con|de)structors in C++ and `c-typeless-decl-kwds'
7465 (when (and (= paren-depth 1) 7469 ;; style declarations. That isn't applicable in an
7470 ;; arglist context, though.
7471 (when (and (= paren-depth 1)
7466 (not got-prefix-before-parens) 7472 (not got-prefix-before-parens)
7467 (not (eq at-type t)) 7473 (not (eq at-type t))
7468 (or backup-at-type 7474 (or backup-at-type
@@ -7474,7 +7480,7 @@ comment at the start of cc-engine.el for more info."
7474 (eq (char-before pos) ?\))) 7480 (eq (char-before pos) ?\)))
7475 (c-fdoc-shift-type-backward) 7481 (c-fdoc-shift-type-backward)
7476 (goto-char pos) 7482 (goto-char pos)
7477 t)) 7483 t)))
7478 7484
7479 (c-forward-syntactic-ws)) 7485 (c-forward-syntactic-ws))
7480 7486