diff options
| author | Alan Mackenzie | 2016-08-27 19:57:42 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-08-27 19:57:42 +0000 |
| commit | a1a777ffdf13afebca24793ded469b3cf0e76290 (patch) | |
| tree | c7bda59a8ee3e97c506fc5e87222be7cf1a532a1 | |
| parent | 0ca712ca3d0df4d10664d97b5f4ba9f0a21e7a4c (diff) | |
| download | emacs-a1a777ffdf13afebca24793ded469b3cf0e76290.tar.gz emacs-a1a777ffdf13afebca24793ded469b3cf0e76290.zip | |
Handle the C++ "identifiers" "final" and "override" correctly.
This fixes bug #24319, allowing destructors affixed with these identifiers to
be correctly fontified.
* lisp/progmodes/cc-engine.el (c-forward-type, c-forward-decl-or-cast-1):
After reaching the "end" of a type expression, skip over any occurrences of
c-type-decl-suffix-ws-ids-key.
* lisp/progmodes/cc-langs.el (c-type-modifier-kwds): Remove "override" and
"final" from the C++ value.
(c-type-decl-suffix-ws-ids-kwds, c-type-decl-suffix-ws-ids-key): New lang
constants/variables for "final" and "override".
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 11 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 14 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index ecee57e4016..28d6618d8a0 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -7263,6 +7263,12 @@ comment at the start of cc-engine.el for more info." | |||
| 7263 | (goto-char (match-end 1)) | 7263 | (goto-char (match-end 1)) |
| 7264 | (c-forward-syntactic-ws))) | 7264 | (c-forward-syntactic-ws))) |
| 7265 | 7265 | ||
| 7266 | ;; Skip any "WS" identifiers (e.g. "final" or "override" in C++) | ||
| 7267 | (while (looking-at c-type-decl-suffix-ws-ids-key) | ||
| 7268 | (goto-char (match-end 1)) | ||
| 7269 | (c-forward-syntactic-ws) | ||
| 7270 | (setq res t)) | ||
| 7271 | |||
| 7266 | (when c-opt-type-concat-key ; Only/mainly for pike. | 7272 | (when c-opt-type-concat-key ; Only/mainly for pike. |
| 7267 | ;; Look for a trailing operator that concatenates the type | 7273 | ;; Look for a trailing operator that concatenates the type |
| 7268 | ;; with a following one, and if so step past that one through | 7274 | ;; with a following one, and if so step past that one through |
| @@ -8165,6 +8171,11 @@ comment at the start of cc-engine.el for more info." | |||
| 8165 | (setq type-start (point)) | 8171 | (setq type-start (point)) |
| 8166 | (setq at-type (c-forward-type)))) | 8172 | (setq at-type (c-forward-type)))) |
| 8167 | 8173 | ||
| 8174 | ;; Move forward over any "WS" ids (like "final" or "override" in C++) | ||
| 8175 | (while (looking-at c-type-decl-suffix-ws-ids-key) | ||
| 8176 | (goto-char (match-end 1)) | ||
| 8177 | (c-forward-syntactic-ws)) | ||
| 8178 | |||
| 8168 | (setq | 8179 | (setq |
| 8169 | at-decl-or-cast | 8180 | at-decl-or-cast |
| 8170 | (catch 'at-decl-or-cast | 8181 | (catch 'at-decl-or-cast |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index e1ccc7924ab..ae6e6a3071f 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -1844,7 +1844,7 @@ but they don't build a type of themselves. Unlike the keywords on | |||
| 1844 | not the type face." | 1844 | not the type face." |
| 1845 | t nil | 1845 | t nil |
| 1846 | c '("const" "restrict" "volatile") | 1846 | c '("const" "restrict" "volatile") |
| 1847 | c++ '("const" "noexcept" "volatile" "throw" "final" "override") | 1847 | c++ '("const" "noexcept" "volatile" "throw") |
| 1848 | objc '("const" "volatile")) | 1848 | objc '("const" "volatile")) |
| 1849 | 1849 | ||
| 1850 | (c-lang-defconst c-opt-type-modifier-key | 1850 | (c-lang-defconst c-opt-type-modifier-key |
| @@ -1873,6 +1873,18 @@ not the type face." | |||
| 1873 | (c-lang-const c-type-modifier-kwds)) | 1873 | (c-lang-const c-type-modifier-kwds)) |
| 1874 | :test 'string-equal)) | 1874 | :test 'string-equal)) |
| 1875 | 1875 | ||
| 1876 | (c-lang-defconst c-type-decl-suffix-ws-ids-kwds | ||
| 1877 | "\"Identifiers\" that when immediately following a declarator have semantic | ||
| 1878 | effect in the declaration, but are syntactically like whitespace." | ||
| 1879 | t nil | ||
| 1880 | c++ '("final" "override")) | ||
| 1881 | |||
| 1882 | (c-lang-defconst c-type-decl-suffix-ws-ids-key | ||
| 1883 | ;; An adorned regexp matching `c-type-decl-suffix-ws-ids-kwds'. | ||
| 1884 | t (c-make-keywords-re t (c-lang-const c-type-decl-suffix-ws-ids-kwds))) | ||
| 1885 | (c-lang-defvar c-type-decl-suffix-ws-ids-key | ||
| 1886 | (c-lang-const c-type-decl-suffix-ws-ids-key)) | ||
| 1887 | |||
| 1876 | (c-lang-defconst c-class-decl-kwds | 1888 | (c-lang-defconst c-class-decl-kwds |
| 1877 | "Keywords introducing declarations where the following block (if any) | 1889 | "Keywords introducing declarations where the following block (if any) |
| 1878 | contains another declaration level that should be considered a class. | 1890 | contains another declaration level that should be considered a class. |