emacs-devel
[Top][All Lists]
Advanced

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

Re: Calling C++ hackers. Please try out the new handling of C++11 lambd


From: Alan Mackenzie
Subject: Re: Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode.
Date: Sun, 21 Aug 2016 12:24:22 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Matthias.

On Sun, Aug 21, 2016 at 12:06:30AM +0200, Matthias Meulien wrote:
> > I'm hoping to get C++11 uniform initialisation working sometime in
> > the next few days.

> Interesting. As I am using this style of initialization now., so I'll
> test your work on my code base.

Many thanks in advance!

> To test your implementation of C++ lambda functions handling, I've had
> to build Emacs from a fresh checkout and just realized that it now
> handles C++11 keywords like `nullptr' or `override'; Many thanks to
> those who are bringing Emacs to modern C++!

> By the way, did you experience the same strange behavior of font
> locking when the `override' keyword is added to a constructor? I mean
> in:

> struct foo : public bar {
>   foo() {}

>   ~foo() override {}

>   void do_something() {}
> };

> the function name `~foo' is not fontified. It is if the `override'
> keyword is removed...

Yes.  That's something I've not seen before.

> Shall I fill a bug report?

If you would, yes please.

Would you also please try out on your real code the following patch
which is intended to fix the problem.  Please either confirm that the
bug is fixed, or let me know what's still not working properly.  Thanks!

After applying the patch (in directory .../lisp/progmodes, you will need
to recompile all of cc-*.el, since changes have been made in low level
macros.  Please send me a private mail if you want any help with the
patching or recompilation.



diff -r f6121546a9bc cc-engine.el
--- a/cc-engine.el      Sat Aug 20 20:40:26 2016 +0000
+++ b/cc-engine.el      Sun Aug 21 12:04:18 2016 +0000
@@ -7266,6 +7266,12 @@
          (goto-char (match-end 1))
          (c-forward-syntactic-ws)))
 
+      ;; Skip any "WS" identifiers (e.g. "final" or "override" in C++)
+      (while (looking-at c-type-decl-suffix-ws-ids-key)
+       (goto-char (match-end 1))
+       (c-forward-syntactic-ws)
+       (setq res t))
+
       (when c-opt-type-concat-key      ; Only/mainly for pike.
        ;; Look for a trailing operator that concatenates the type
        ;; with a following one, and if so step past that one through
@@ -8140,6 +8146,11 @@
          (setq type-start (point))
          (setq at-type (c-forward-type))))
 
+      ;; Move forward over any "WS" ids (like "final" or "override" in C++)
+      (while (looking-at c-type-decl-suffix-ws-ids-key)
+       (goto-char (match-end 1))
+       (c-forward-syntactic-ws))
+
       (setq
        at-decl-or-cast
        (catch 'at-decl-or-cast
diff -r f6121546a9bc cc-langs.el
--- a/cc-langs.el       Sat Aug 20 20:40:26 2016 +0000
+++ b/cc-langs.el       Sun Aug 21 12:04:18 2016 +0000
@@ -1817,7 +1817,7 @@
 not the type face."
   t    nil
   c    '("const" "restrict" "volatile")
-  c++  '("const" "noexcept" "volatile" "throw" "final" "override")
+  c++  '("const" "noexcept" "volatile" "throw")
   objc '("const" "volatile"))
 
 (c-lang-defconst c-opt-type-modifier-key
@@ -1846,6 +1846,18 @@
                                  (c-lang-const c-type-modifier-kwds))
                          :test 'string-equal))
 
+(c-lang-defconst c-type-decl-suffix-ws-ids-kwds
+  "\"Identifiers\" that when immediately following a declarator have semantic
+effect in the declaration, but are syntactically like whitespace."
+  t    nil
+  c++  '("final" "override"))
+
+(c-lang-defconst c-type-decl-suffix-ws-ids-key
+  ;; An adorned regexp matching `c-type-decl-suffix-ws-ids-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-type-decl-suffix-ws-ids-kwds)))
+(c-lang-defvar c-type-decl-suffix-ws-ids-key
+  (c-lang-const c-type-decl-suffix-ws-ids-key))
+
 (c-lang-defconst c-class-decl-kwds
   "Keywords introducing declarations where the following block (if any)
 contains another declaration level that should be considered a class.




> -- 
> Matthias

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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