diff options
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 12 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 25 |
2 files changed, 35 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index a25d0595535..ed8310d0e67 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -1253,12 +1253,20 @@ comment at the start of cc-engine.el for more info." | |||
| 1253 | ;; (including a case label) or something like C++'s "public:"? | 1253 | ;; (including a case label) or something like C++'s "public:"? |
| 1254 | ;; A case label might use an expression rather than a token. | 1254 | ;; A case label might use an expression rather than a token. |
| 1255 | (setq after-case:-pos (or tok start)) | 1255 | (setq after-case:-pos (or tok start)) |
| 1256 | (if (or (looking-at c-nonlabel-token-key) ; e.g. "while" or "'a'" | 1256 | (if (or (looking-at c-nonlabel-nonparen-token-key) |
| 1257 | ; e.g. "while" or "'a'" | ||
| 1257 | ;; Catch C++'s inheritance construct "class foo : bar". | 1258 | ;; Catch C++'s inheritance construct "class foo : bar". |
| 1258 | (save-excursion | 1259 | (save-excursion |
| 1259 | (and | 1260 | (and |
| 1260 | (c-safe (c-backward-sexp) t) | 1261 | (c-safe (c-backward-sexp) t) |
| 1261 | (looking-at c-nonlabel-token-2-key)))) | 1262 | (looking-at c-nonlabel-token-2-key))) |
| 1263 | ;; Catch C++'s "case a(1):" | ||
| 1264 | (and (c-major-mode-is 'c++-mode) | ||
| 1265 | (eq (char-after) ?\() | ||
| 1266 | (save-excursion | ||
| 1267 | (not (and | ||
| 1268 | (zerop (c-backward-token-2 2)) | ||
| 1269 | (looking-at c-case-kwds-regexp)))))) | ||
| 1262 | (setq c-maybe-labelp nil) | 1270 | (setq c-maybe-labelp nil) |
| 1263 | (if after-labels-pos ; Have we already encountered a label? | 1271 | (if after-labels-pos ; Have we already encountered a label? |
| 1264 | (if (not last-label-pos) | 1272 | (if (not last-label-pos) |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 8b7e4ef7c09..30da10a6c03 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -3674,6 +3674,31 @@ i.e. before \":\". Only used if `c-recognize-colon-labels' is set." | |||
| 3674 | c++ (concat "\\s(\\|\"\\|" (c-lang-const c-nonlabel-token-key))) | 3674 | c++ (concat "\\s(\\|\"\\|" (c-lang-const c-nonlabel-token-key))) |
| 3675 | (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key)) | 3675 | (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key)) |
| 3676 | 3676 | ||
| 3677 | (c-lang-defconst c-nonlabel-nonparen-token-key | ||
| 3678 | "Regexp matching things that can't occur in generic colon labels, | ||
| 3679 | neither in a statement nor in a declaration context, with the | ||
| 3680 | exception of an open parenthesis. The regexp is tested at the | ||
| 3681 | beginning of every sexp in a suspected label, i.e. before \":\". | ||
| 3682 | Only used if `c-recognize-colon-labels' is set." | ||
| 3683 | ;; This lang const is the same as `c-nonlabel-token-key', except for a | ||
| 3684 | ;; slight difference in the c++-mode value. | ||
| 3685 | t (concat | ||
| 3686 | ;; All keywords except `c-label-kwds' and `c-protection-kwds'. | ||
| 3687 | (c-make-keywords-re t | ||
| 3688 | (c--set-difference (c-lang-const c-keywords) | ||
| 3689 | (append (c-lang-const c-label-kwds) | ||
| 3690 | (c-lang-const c-protection-kwds)) | ||
| 3691 | :test 'string-equal))) | ||
| 3692 | ;; Don't allow string literals, except in AWK and Java. Character constants are OK. | ||
| 3693 | (c objc pike idl) (concat "\"\\|" | ||
| 3694 | (c-lang-const c-nonlabel-nonparen-token-key)) | ||
| 3695 | ;; Also check for open parens in C++, to catch member init lists in | ||
| 3696 | ;; constructors. We normally allow it so that macros with arguments | ||
| 3697 | ;; work in labels. | ||
| 3698 | c++ (concat "[{[]\\|\"\\|" (c-lang-const c-nonlabel-nonparen-token-key))) | ||
| 3699 | (c-lang-defvar c-nonlabel-nonparen-token-key | ||
| 3700 | (c-lang-const c-nonlabel-nonparen-token-key)) | ||
| 3701 | |||
| 3677 | (c-lang-defconst c-nonlabel-token-2-key | 3702 | (c-lang-defconst c-nonlabel-token-2-key |
| 3678 | "Regexp matching things that can't occur two symbols before a colon in | 3703 | "Regexp matching things that can't occur two symbols before a colon in |
| 3679 | a label construct. This catches C++'s inheritance construct \"class foo | 3704 | a label construct. This catches C++'s inheritance construct \"class foo |