aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2016-12-29 15:34:36 +0000
committerAlan Mackenzie2016-12-29 15:34:36 +0000
commit11b81a54d538e8deca3cd64521cf85409efb617b (patch)
tree566d97547ea1057db231857c9f4a1cebbb34f032
parent0d19e69184cd3068279677fb04aa9fb2da6895e4 (diff)
downloademacs-11b81a54d538e8deca3cd64521cf85409efb617b.tar.gz
emacs-11b81a54d538e8deca3cd64521cf85409efb617b.zip
Partially correct fontification of "(b*3)", and the like, in C++ Mode
This problem is caused by the fundamental ambiguity in C++ between argument declarations and initialisation clauses. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): If we have an open paren preceded by an arithmetic operator, we give this the context nil, not 'arglist. * lisp/progmodes/cc-langs.el (c-arithmetic-operators, c-arithmetic-op-regexp): New lang consts and vars.
-rw-r--r--lisp/progmodes/cc-fonts.el7
-rw-r--r--lisp/progmodes/cc-langs.el16
2 files changed, 23 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 26a002ac8a1..39e68f0b871 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1311,6 +1311,13 @@ casts and declarations are fontified. Used on level 2 and higher."
1311 ;; multiline declaration. 1311 ;; multiline declaration.
1312 (c-put-char-property (1- match-pos) 1312 (c-put-char-property (1- match-pos)
1313 'c-type 'c-decl-arg-start)) 1313 'c-type 'c-decl-arg-start))
1314 ;; Got an open paren preceded by an arith operator.
1315 ((and (eq (char-before match-pos) ?\()
1316 (save-excursion
1317 (and (zerop (c-backward-token-2 2))
1318 (looking-at c-arithmetic-op-regexp))))
1319 (setq context nil
1320 c-restricted-<>-arglists nil))
1314 (t (setq context 'arglist 1321 (t (setq context 'arglist
1315 c-restricted-<>-arglists t)))) 1322 c-restricted-<>-arglists t))))
1316 1323
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 3c328489ec1..83b8db3657e 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1248,6 +1248,22 @@ operators."
1248(c-lang-defvar c-assignment-op-regexp 1248(c-lang-defvar c-assignment-op-regexp
1249 (c-lang-const c-assignment-op-regexp)) 1249 (c-lang-const c-assignment-op-regexp))
1250 1250
1251(c-lang-defconst c-arithmetic-operators
1252 "List of all arithmetic operators, including \"+=\", etc."
1253 ;; Note: in the following, there are too many operators for AWK and IDL.
1254 t (append (c-lang-const c-assignment-operators)
1255 '("+" "-" "*" "/" "%"
1256 "<<" ">>"
1257 "<" ">" "<=" ">="
1258 "==" "!="
1259 "&" "^" "|"
1260 "&&" "||")))
1261
1262(c-lang-defconst c-arithmetic-op-regexp
1263 t (c-make-keywords-re nil
1264 (c-lang-const c-arithmetic-operators)))
1265(c-lang-defvar c-arithmetic-op-regexp (c-lang-const c-arithmetic-op-regexp))
1266
1251(c-lang-defconst c-:$-multichar-token-regexp 1267(c-lang-defconst c-:$-multichar-token-regexp
1252 ;; Regexp matching all tokens ending in ":" which are longer than one char. 1268 ;; Regexp matching all tokens ending in ":" which are longer than one char.
1253 ;; Currently (2016-01-07) only used in C++ Mode. 1269 ;; Currently (2016-01-07) only used in C++ Mode.