emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b733a91: Fix fontification of "operator~" in C++ Mo


From: Alan Mackenzie
Subject: [Emacs-diffs] master b733a91: Fix fontification of "operator~" in C++ Mode.
Date: Sun, 3 Sep 2017 05:48:18 -0400 (EDT)

branch: master
commit b733a910091c426de0d831f1ce0cda4ae736ab69
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    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.
---
 lisp/progmodes/cc-engine.el |  7 ++++++-
 lisp/progmodes/cc-langs.el  | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index bf95dc1..5ac4a76 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 93e8df1..d4eae06 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]