[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b61b3c8: Handle C++17's constexpr keyword in if sta
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] master b61b3c8: Handle C++17's constexpr keyword in if statements |
Date: |
Wed, 28 Mar 2018 15:41:21 -0400 (EDT) |
branch: master
commit b61b3c804cb7c1348097ccef18d26fa4bdd37117
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
Handle C++17's constexpr keyword in if statements
* lisp/progmodes/cc-engine.el (c-after-conditional): Test for matches to
c-block-stmt-hangon-key.
* lisp/progmodes/cc-langs.el (c-block-stmt-hangon-kwds): New lang const.
(c-block-stmt-hangon-key): New lang const/var matching any element of the
above.
---
lisp/progmodes/cc-engine.el | 6 ++++++
lisp/progmodes/cc-langs.el | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 05926c4..26ce2c9 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9847,9 +9847,15 @@ comment at the start of cc-engine.el for more info."
;; This function might do hidden buffer changes.
(save-excursion
(and (zerop (c-backward-token-2 1 t lim))
+ (if (looking-at c-block-stmt-hangon-key)
+ (zerop (c-backward-token-2 1 t lim))
+ t)
(or (looking-at c-block-stmt-1-key)
(and (eq (char-after) ?\()
(zerop (c-backward-token-2 1 t lim))
+ (if (looking-at c-block-stmt-hangon-key)
+ (zerop (c-backward-token-2 1 t lim))
+ t)
(or (looking-at c-block-stmt-2-key)
(looking-at c-block-stmt-1-2-key))))
(point))))
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 98cfd20..8fa253f 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2587,6 +2587,17 @@ Keywords here should also be in `c-block-stmt-1-kwds'."
(c-lang-const c-block-stmt-2-kwds))
:test 'string-equal))
+(c-lang-defconst c-block-stmt-hangon-kwds
+ "Keywords which may directly follow a member of `c-block-stmt-1/2-kwds'."
+ t nil
+ c++ '("constexpr"))
+
+(c-lang-defconst c-block-stmt-hangon-key
+ ;; Regexp matching a "hangon" keyword in a `c-block-stmt-1/2-kwds'
+ ;; construct.
+ t (c-make-keywords-re t (c-lang-const c-block-stmt-hangon-kwds)))
+(c-lang-defvar c-block-stmt-hangon-key (c-lang-const c-block-stmt-hangon-key))
+
(c-lang-defconst c-opt-block-stmt-key
;; Regexp matching the start of any statement that has a
;; substatement (except a bare block). Nil in languages that
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b61b3c8: Handle C++17's constexpr keyword in if statements,
Alan Mackenzie <=