unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Matthias Meulien <orontee@gmail.com>
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <20160821122422.GA3813@acm.fritz.box> (raw)
In-Reply-To: <1471730790.1410.16.camel@gmail.com>

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	other threads:[~2016-08-21 12:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 12:24 Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode Alan Mackenzie
2016-08-15 16:17 ` Eli Zaretskii
2016-08-19 21:45 ` Matthias Meulien
2016-08-20 15:19   ` Alan Mackenzie
2016-08-20 22:06     ` Matthias Meulien
2016-08-21 12:24       ` Alan Mackenzie [this message]
2016-08-27 15:35         ` Matthias Meulien
2016-08-27 20:27           ` Alan Mackenzie
2016-08-21 16:22       ` Alan Mackenzie
2016-08-24 19:27         ` Richard Copley
2016-08-24 19:43           ` Alan Mackenzie
2016-08-24 21:10             ` Richard Copley
2016-08-27 15:37         ` Matthias Meulien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160821122422.GA3813@acm.fritz.box \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=orontee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).