diff options
| author | Alan Mackenzie | 2018-03-28 19:39:30 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2018-03-28 19:39:30 +0000 |
| commit | b61b3c804cb7c1348097ccef18d26fa4bdd37117 (patch) | |
| tree | ea1418ebe8bb19941cddff694af29e9b40f22022 | |
| parent | 3ccbe1f43f8c73b5dbf7051b91cd850959f2a79f (diff) | |
| download | emacs-b61b3c804cb7c1348097ccef18d26fa4bdd37117.tar.gz emacs-b61b3c804cb7c1348097ccef18d26fa4bdd37117.zip | |
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.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 05926c48b04..26ce2c919e8 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." | |||
| 9847 | ;; This function might do hidden buffer changes. | 9847 | ;; This function might do hidden buffer changes. |
| 9848 | (save-excursion | 9848 | (save-excursion |
| 9849 | (and (zerop (c-backward-token-2 1 t lim)) | 9849 | (and (zerop (c-backward-token-2 1 t lim)) |
| 9850 | (if (looking-at c-block-stmt-hangon-key) | ||
| 9851 | (zerop (c-backward-token-2 1 t lim)) | ||
| 9852 | t) | ||
| 9850 | (or (looking-at c-block-stmt-1-key) | 9853 | (or (looking-at c-block-stmt-1-key) |
| 9851 | (and (eq (char-after) ?\() | 9854 | (and (eq (char-after) ?\() |
| 9852 | (zerop (c-backward-token-2 1 t lim)) | 9855 | (zerop (c-backward-token-2 1 t lim)) |
| 9856 | (if (looking-at c-block-stmt-hangon-key) | ||
| 9857 | (zerop (c-backward-token-2 1 t lim)) | ||
| 9858 | t) | ||
| 9853 | (or (looking-at c-block-stmt-2-key) | 9859 | (or (looking-at c-block-stmt-2-key) |
| 9854 | (looking-at c-block-stmt-1-2-key)))) | 9860 | (looking-at c-block-stmt-1-2-key)))) |
| 9855 | (point)))) | 9861 | (point)))) |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 98cfd2073d1..8fa253f3045 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'." | |||
| 2587 | (c-lang-const c-block-stmt-2-kwds)) | 2587 | (c-lang-const c-block-stmt-2-kwds)) |
| 2588 | :test 'string-equal)) | 2588 | :test 'string-equal)) |
| 2589 | 2589 | ||
| 2590 | (c-lang-defconst c-block-stmt-hangon-kwds | ||
| 2591 | "Keywords which may directly follow a member of `c-block-stmt-1/2-kwds'." | ||
| 2592 | t nil | ||
| 2593 | c++ '("constexpr")) | ||
| 2594 | |||
| 2595 | (c-lang-defconst c-block-stmt-hangon-key | ||
| 2596 | ;; Regexp matching a "hangon" keyword in a `c-block-stmt-1/2-kwds' | ||
| 2597 | ;; construct. | ||
| 2598 | t (c-make-keywords-re t (c-lang-const c-block-stmt-hangon-kwds))) | ||
| 2599 | (c-lang-defvar c-block-stmt-hangon-key (c-lang-const c-block-stmt-hangon-key)) | ||
| 2600 | |||
| 2590 | (c-lang-defconst c-opt-block-stmt-key | 2601 | (c-lang-defconst c-opt-block-stmt-key |
| 2591 | ;; Regexp matching the start of any statement that has a | 2602 | ;; Regexp matching the start of any statement that has a |
| 2592 | ;; substatement (except a bare block). Nil in languages that | 2603 | ;; substatement (except a bare block). Nil in languages that |