From: Alan Mackenzie Date: Sun, 3 Sep 2017 09:40:31 +0000 (+0000) Subject: Fix fontification of "operator~" in C++ Mode. X-Git-Tag: emacs-26.0.90~269 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b733a910091c426de0d831f1ce0cda4ae736ab69;p=emacs.git Fix fontification of "operator~" in C++ Mode. * lisp/progmodes/cc-langs.el (c-ambiguous-overloadable-or-identifier-prefices) (c-ambiguous-overloadable-or-identifier-prefix-re): New c-lang-defconsts/vars. * lisp/progmodes/cc-engine.el (c-forward-name): Do not try to parse "~" (and two other symbols) as a cast without good evidence. Prefer an overloaded operator in ambiguous cases. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index bf95dc1e3ce..5ac4a769337 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7387,7 +7387,12 @@ comment at the start of cc-engine.el for more info." (setq pos (point) res subres)))) - ((looking-at c-identifier-start) + ((and (looking-at c-identifier-start) + (or (not (looking-at + c-ambiguous-overloadable-or-identifier-prefix-re)) + (save-excursion + (and (eq (c-forward-token-2) 0) + (not (eq (char-after) ?\()))))) ;; Got a cast operator. (when (c-forward-type) (setq pos (point) diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 93e8df16c16..d4eae06f290 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -1185,6 +1185,24 @@ This regexp is assumed to not match any non-operator identifier." (make-obsolete-variable 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix "CC Mode 5.31.4, 2006-04-14") +(c-lang-defconst c-ambiguous-overloadable-or-identifier-prefices + ;; A list of strings which can be either overloadable operators or + ;; identifier prefixes. + t (c--intersection + (c-filter-ops (c-lang-const c-identifier-ops) + '(prefix) + t) + (c-lang-const c-overloadable-operators) + :test 'string-equal)) + +(c-lang-defconst c-ambiguous-overloadable-or-identifier-prefix-re + ;; A regexp matching strings which can be either overloadable operators + ;; or identifier prefixes. + t (c-make-keywords-re + t (c-lang-const c-ambiguous-overloadable-or-identifier-prefices))) +(c-lang-defvar c-ambiguous-overloadable-or-identifier-prefix-re + (c-lang-const c-ambiguous-overloadable-or-identifier-prefix-re)) + (c-lang-defconst c-other-op-syntax-tokens "List of the tokens made up of characters in the punctuation or parenthesis syntax classes that have uses other than as expression