]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix fontification of "operator~" in C++ Mode.
authorAlan Mackenzie <acm@muc.de>
Sun, 3 Sep 2017 09:40:31 +0000 (09:40 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 3 Sep 2017 09:40:31 +0000 (09:40 +0000)
* 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.

lisp/progmodes/cc-engine.el
lisp/progmodes/cc-langs.el

index bf95dc1e3ce2f45e5ffad0cae7ca80ba2ebb0317..5ac4a76933724bf3909f0ac88b39f867fbe8d202 100644 (file)
@@ -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)
index 93e8df16c162c97f73edbace245dd61dbfd1a53d..d4eae06f290991921d06c9fb1c9568ad544e4c27 100644 (file)
@@ -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