diff options
| author | Alan Mackenzie | 2007-01-01 22:11:28 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2007-01-01 22:11:28 +0000 |
| commit | 51c9af45fee2a756cacbbcdb0628db558ca342e5 (patch) | |
| tree | 5fefce5428785a69a53b15dd8f904cb7af2c473c /lisp/progmodes/cc-engine.el | |
| parent | d8a4fc444aae4582e22a2bd674d58c230a516b10 (diff) | |
| download | emacs-51c9af45fee2a756cacbbcdb0628db558ca342e5.tar.gz emacs-51c9af45fee2a756cacbbcdb0628db558ca342e5.zip | |
Update CC Mode to version 5.31.4. The detailed changes are those
recorded in the ChangeLog for 2007-01-01.
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 319 |
1 files changed, 207 insertions, 112 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 5cb00929007..bacb4670ea0 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -255,6 +255,18 @@ comment at the start of cc-engine.el for more info." | |||
| 255 | (forward-char) | 255 | (forward-char) |
| 256 | t)))) | 256 | t)))) |
| 257 | 257 | ||
| 258 | (defun c-forward-over-cpp-define-id () | ||
| 259 | ;; Assuming point is at the "#" that introduces a preprocessor | ||
| 260 | ;; directive, it's moved forward to the end of the identifier which is | ||
| 261 | ;; "#define"d (or whatever c-opt-cpp-macro-define specifies). Non-nil | ||
| 262 | ;; is returned in this case, in all other cases nil is returned and | ||
| 263 | ;; point isn't moved. | ||
| 264 | ;; | ||
| 265 | ;; This function might do hidden buffer changes. | ||
| 266 | (when (and c-opt-cpp-macro-define-id | ||
| 267 | (looking-at c-opt-cpp-macro-define-id)) | ||
| 268 | (goto-char (match-end 0)))) | ||
| 269 | |||
| 258 | (defun c-forward-to-cpp-define-body () | 270 | (defun c-forward-to-cpp-define-body () |
| 259 | ;; Assuming point is at the "#" that introduces a preprocessor | 271 | ;; Assuming point is at the "#" that introduces a preprocessor |
| 260 | ;; directive, it's moved forward to the start of the definition body | 272 | ;; directive, it's moved forward to the start of the definition body |
| @@ -2442,14 +2454,14 @@ comment at the start of cc-engine.el for more info." | |||
| 2442 | (= (c-backward-token-2 0) 0)) | 2454 | (= (c-backward-token-2 0) 0)) |
| 2443 | 2455 | ||
| 2444 | (cond ((and (looking-at c-overloadable-operators-regexp) | 2456 | (cond ((and (looking-at c-overloadable-operators-regexp) |
| 2445 | (or (not c-opt-op-identitier-prefix) | 2457 | (or (not c-opt-op-identifier-prefix) |
| 2446 | (and (= (c-backward-token-2 1) 0) | 2458 | (and (= (c-backward-token-2 1) 0) |
| 2447 | (looking-at c-opt-op-identitier-prefix)))) | 2459 | (looking-at c-opt-op-identifier-prefix)))) |
| 2448 | (point)) | 2460 | (point)) |
| 2449 | 2461 | ||
| 2450 | ((save-excursion | 2462 | ((save-excursion |
| 2451 | (and c-opt-op-identitier-prefix | 2463 | (and c-opt-op-identifier-prefix |
| 2452 | (looking-at c-opt-op-identitier-prefix) | 2464 | (looking-at c-opt-op-identifier-prefix) |
| 2453 | (= (c-forward-token-2 1) 0) | 2465 | (= (c-forward-token-2 1) 0) |
| 2454 | (looking-at c-overloadable-operators-regexp))) | 2466 | (looking-at c-overloadable-operators-regexp))) |
| 2455 | (point)))) | 2467 | (point)))) |
| @@ -3843,7 +3855,7 @@ comment at the start of cc-engine.el for more info." | |||
| 3843 | ;; good start position for the search, so do it. | 3855 | ;; good start position for the search, so do it. |
| 3844 | (c-find-decl-prefix-search))) | 3856 | (c-find-decl-prefix-search))) |
| 3845 | 3857 | ||
| 3846 | ;; Now loop. We already got the first match. | 3858 | ;; Now loop. Round what? (ACM, 2006/7/5). We already got the first match. |
| 3847 | 3859 | ||
| 3848 | (while (progn | 3860 | (while (progn |
| 3849 | (while (and | 3861 | (while (and |
| @@ -4534,41 +4546,42 @@ comment at the start of cc-engine.el for more info." | |||
| 4534 | (goto-char start) | 4546 | (goto-char start) |
| 4535 | nil) | 4547 | nil) |
| 4536 | 4548 | ||
| 4537 | (while (and | 4549 | (while (progn |
| 4538 | (c-syntactic-skip-backward "^<;{}" limit t) | 4550 | (c-syntactic-skip-backward "^<;{}" limit t) |
| 4539 | 4551 | ||
| 4540 | (if (eq (char-before) ?<) | 4552 | (and |
| 4541 | t | 4553 | (if (eq (char-before) ?<) |
| 4542 | ;; Stopped at bob or a char that isn't allowed in an | 4554 | t |
| 4543 | ;; arglist, so we've failed. | 4555 | ;; Stopped at bob or a char that isn't allowed in an |
| 4544 | (goto-char start) | 4556 | ;; arglist, so we've failed. |
| 4545 | nil) | 4557 | (goto-char start) |
| 4558 | nil) | ||
| 4546 | 4559 | ||
| 4547 | (if (> (point) | 4560 | (if (> (point) |
| 4548 | (progn (c-beginning-of-current-token) | 4561 | (progn (c-beginning-of-current-token) |
| 4549 | (point))) | 4562 | (point))) |
| 4550 | ;; If we moved then the "<" was part of some | 4563 | ;; If we moved then the "<" was part of some |
| 4551 | ;; multicharacter token. | 4564 | ;; multicharacter token. |
| 4552 | t | 4565 | t |
| 4553 | 4566 | ||
| 4554 | (backward-char) | 4567 | (backward-char) |
| 4555 | (let ((beg-pos (point))) | 4568 | (let ((beg-pos (point))) |
| 4556 | (if (c-forward-<>-arglist all-types) | 4569 | (if (c-forward-<>-arglist all-types) |
| 4557 | (cond ((= (point) start) | 4570 | (cond ((= (point) start) |
| 4558 | ;; Matched the arglist. Break the while. | 4571 | ;; Matched the arglist. Break the while. |
| 4559 | (goto-char beg-pos) | 4572 | (goto-char beg-pos) |
| 4560 | nil) | 4573 | nil) |
| 4561 | ((> (point) start) | 4574 | ((> (point) start) |
| 4562 | ;; We started from a non-paren ">" inside an | 4575 | ;; We started from a non-paren ">" inside an |
| 4563 | ;; arglist. | 4576 | ;; arglist. |
| 4564 | (goto-char start) | 4577 | (goto-char start) |
| 4565 | nil) | 4578 | nil) |
| 4566 | (t | 4579 | (t |
| 4567 | ;; Matched a shorter arglist. Can be a nested | 4580 | ;; Matched a shorter arglist. Can be a nested |
| 4568 | ;; one so continue looking. | 4581 | ;; one so continue looking. |
| 4569 | (goto-char beg-pos) | 4582 | (goto-char beg-pos) |
| 4570 | t)) | 4583 | t)) |
| 4571 | t))))) | 4584 | t)))))) |
| 4572 | 4585 | ||
| 4573 | (/= (point) start)))) | 4586 | (/= (point) start)))) |
| 4574 | 4587 | ||
| @@ -5793,17 +5806,32 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5793 | nil)))) | 5806 | nil)))) |
| 5794 | 5807 | ||
| 5795 | (defun c-forward-label (&optional assume-markup preceding-token-end limit) | 5808 | (defun c-forward-label (&optional assume-markup preceding-token-end limit) |
| 5796 | ;; Assuming the point is at the beginning of a token, check if it | 5809 | ;; Assuming that point is at the beginning of a token, check if it starts a |
| 5797 | ;; starts a label and if so move over it and return t, otherwise | 5810 | ;; label and if so move over it and return t, otherwise don't move and |
| 5798 | ;; don't move and return nil. The end of the label is taken to be | 5811 | ;; return nil. "Label" here means "most things with a colon". |
| 5799 | ;; the end of the first submatch in `c-opt-extra-label-key' if it | 5812 | ;; |
| 5800 | ;; matched, otherwise it's the colon. The point is directly after | 5813 | ;; More precisely, a "label" is regarded as one of: |
| 5801 | ;; the end on return. The terminating char is marked with | 5814 | ;; (i) a goto target like "foo:"; |
| 5802 | ;; `c-decl-end' to improve recognition of the following declaration | 5815 | ;; (ii) A case label - either the entire construct "case FOO:" or just the |
| 5803 | ;; or statement. | 5816 | ;; bare "case", should the colon be missing; |
| 5817 | ;; (iii) a keyword which needs a colon, like "default:" or "private:"; | ||
| 5818 | ;; (iv) One of QT's "extended" C++ variants of | ||
| 5819 | ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:". | ||
| 5820 | ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any | ||
| 5821 | ;; colon). Currently (2006-03), this applies only to Objective C's | ||
| 5822 | ;; keywords "@private", "@protected", and "@public". | ||
| 5823 | ;; | ||
| 5824 | ;; One of the things which will NOT be recognised as a label is a bit-field | ||
| 5825 | ;; element of a struct, something like "int foo:5". | ||
| 5826 | ;; | ||
| 5827 | ;; The end of the label is taken to be just after the colon, or the end of | ||
| 5828 | ;; the first submatch in `c-opt-extra-label-key'. The point is directly | ||
| 5829 | ;; after the end on return. The terminating char gets marked with | ||
| 5830 | ;; `c-decl-end' to improve recognition of the following declaration or | ||
| 5831 | ;; statement. | ||
| 5804 | ;; | 5832 | ;; |
| 5805 | ;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding | 5833 | ;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding |
| 5806 | ;; label, if any, has been marked up like that. | 5834 | ;; label, if any, has already been marked up like that. |
| 5807 | ;; | 5835 | ;; |
| 5808 | ;; If PRECEDING-TOKEN-END is given, it should be the first position | 5836 | ;; If PRECEDING-TOKEN-END is given, it should be the first position |
| 5809 | ;; after the preceding token, i.e. on the other side of the | 5837 | ;; after the preceding token, i.e. on the other side of the |
| @@ -5819,8 +5847,11 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5819 | ;; | 5847 | ;; |
| 5820 | ;; This function might do hidden buffer changes. | 5848 | ;; This function might do hidden buffer changes. |
| 5821 | 5849 | ||
| 5822 | (let ((start (point))) | 5850 | (let ((start (point)) |
| 5851 | qt-symbol-idx | ||
| 5852 | macro-start) ; if we're in one. | ||
| 5823 | (cond | 5853 | (cond |
| 5854 | ;; "case" or "default" (Doesn't apply to AWK). | ||
| 5824 | ((looking-at c-label-kwds-regexp) | 5855 | ((looking-at c-label-kwds-regexp) |
| 5825 | (let ((kwd-end (match-end 1))) | 5856 | (let ((kwd-end (match-end 1))) |
| 5826 | ;; Record only the keyword itself for fontification, since in | 5857 | ;; Record only the keyword itself for fontification, since in |
| @@ -5840,7 +5871,7 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5840 | (match-beginning 2)) | 5871 | (match-beginning 2)) |
| 5841 | 5872 | ||
| 5842 | (progn | 5873 | (progn |
| 5843 | (goto-char (match-beginning 2)) | 5874 | (goto-char (match-beginning 2)) ; just after the : |
| 5844 | (c-put-c-type-property (1- (point)) 'c-decl-end) | 5875 | (c-put-c-type-property (1- (point)) 'c-decl-end) |
| 5845 | t) | 5876 | t) |
| 5846 | 5877 | ||
| @@ -5851,6 +5882,7 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5851 | (goto-char kwd-end) | 5882 | (goto-char kwd-end) |
| 5852 | t))) | 5883 | t))) |
| 5853 | 5884 | ||
| 5885 | ;; @private, @protected, @public, in Objective C, or similar. | ||
| 5854 | ((and c-opt-extra-label-key | 5886 | ((and c-opt-extra-label-key |
| 5855 | (looking-at c-opt-extra-label-key)) | 5887 | (looking-at c-opt-extra-label-key)) |
| 5856 | ;; For a `c-opt-extra-label-key' match, we record the whole | 5888 | ;; For a `c-opt-extra-label-key' match, we record the whole |
| @@ -5862,7 +5894,8 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5862 | (c-put-c-type-property (1- (point)) 'c-decl-end) | 5894 | (c-put-c-type-property (1- (point)) 'c-decl-end) |
| 5863 | t) | 5895 | t) |
| 5864 | 5896 | ||
| 5865 | ((and c-recognize-colon-labels | 5897 | ;; All other cases of labels. |
| 5898 | ((and c-recognize-colon-labels ; nil for AWK and IDL, otherwise t. | ||
| 5866 | 5899 | ||
| 5867 | ;; A colon label must have something before the colon. | 5900 | ;; A colon label must have something before the colon. |
| 5868 | (not (eq (char-after) ?:)) | 5901 | (not (eq (char-after) ?:)) |
| @@ -5890,7 +5923,8 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5890 | (save-excursion | 5923 | (save-excursion |
| 5891 | (goto-char (1- preceding-token-end)) | 5924 | (goto-char (1- preceding-token-end)) |
| 5892 | (c-beginning-of-current-token) | 5925 | (c-beginning-of-current-token) |
| 5893 | (looking-at c-label-prefix-re)) | 5926 | (or (looking-at c-label-prefix-re) |
| 5927 | (looking-at c-block-stmt-1-key))) | ||
| 5894 | 5928 | ||
| 5895 | (and (eq (char-before preceding-token-end) ?\)) | 5929 | (and (eq (char-before preceding-token-end) ?\)) |
| 5896 | (c-after-conditional))) | 5930 | (c-after-conditional))) |
| @@ -5899,7 +5933,8 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5899 | (save-excursion | 5933 | (save-excursion |
| 5900 | (goto-char (1- preceding-token-end)) | 5934 | (goto-char (1- preceding-token-end)) |
| 5901 | (c-beginning-of-current-token) | 5935 | (c-beginning-of-current-token) |
| 5902 | (looking-at c-label-prefix-re)) | 5936 | (or (looking-at c-label-prefix-re) |
| 5937 | (looking-at c-block-stmt-1-key))) | ||
| 5903 | 5938 | ||
| 5904 | (cond | 5939 | (cond |
| 5905 | ((eq (char-before preceding-token-end) ?\)) | 5940 | ((eq (char-before preceding-token-end) ?\)) |
| @@ -5907,26 +5942,52 @@ y ;; True if there's a suffix match outside the outermost | |||
| 5907 | 5942 | ||
| 5908 | ((eq (char-before preceding-token-end) ?:) | 5943 | ((eq (char-before preceding-token-end) ?:) |
| 5909 | ;; Might be after another label, so check it recursively. | 5944 | ;; Might be after another label, so check it recursively. |
| 5910 | (save-excursion | 5945 | (save-restriction |
| 5911 | (goto-char (1- preceding-token-end)) | 5946 | (save-excursion |
| 5912 | ;; Essentially the same as the | 5947 | (goto-char (1- preceding-token-end)) |
| 5913 | ;; `c-syntactic-re-search-forward' regexp below. | 5948 | ;; Essentially the same as the |
| 5914 | (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t) | 5949 | ;; `c-syntactic-re-search-forward' regexp below. |
| 5915 | (let ((pte (point)) | 5950 | (setq macro-start |
| 5916 | ;; If the caller turned on recording for us, | 5951 | (save-excursion (and (c-beginning-of-macro) |
| 5917 | ;; it shouldn't apply when we check the | 5952 | (point)))) |
| 5918 | ;; preceding label. | 5953 | (if macro-start (narrow-to-region macro-start (point-max))) |
| 5919 | c-record-type-identifiers) | 5954 | (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t) |
| 5920 | (c-forward-syntactic-ws) | 5955 | ;; Note: the following should work instead of the |
| 5921 | (c-forward-label nil pte start)))))))) | 5956 | ;; narrow-to-region above. Investigate why not, |
| 5922 | 5957 | ;; sometime. ACM, 2006-03-31. | |
| 5923 | ;; Check that the next nonsymbol token is ":". Allow '(' | 5958 | ;; (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" |
| 5924 | ;; for the sake of macro arguments. FIXME: Should build | 5959 | ;; macro-start t) |
| 5925 | ;; this regexp from the language constants. | 5960 | (let ((pte (point)) |
| 5926 | (c-syntactic-re-search-forward | 5961 | ;; If the caller turned on recording for us, |
| 5927 | "[[:?;{=*/%&|,<>!@+-]" limit t t) | 5962 | ;; it shouldn't apply when we check the |
| 5928 | (eq (char-before) ?:) | 5963 | ;; preceding label. |
| 5929 | (not (eq (char-after) ?:))) | 5964 | c-record-type-identifiers) |
| 5965 | ;; A label can't start at a cpp directive. Check for | ||
| 5966 | ;; this, since c-forward-syntactic-ws would foul up on it. | ||
| 5967 | (unless (and c-opt-cpp-prefix (looking-at c-opt-cpp-prefix)) | ||
| 5968 | (c-forward-syntactic-ws) | ||
| 5969 | (c-forward-label nil pte start)))))))))) | ||
| 5970 | |||
| 5971 | ;; Check that the next nonsymbol token is ":", or that we're in one | ||
| 5972 | ;; of QT's "slots" declarations. Allow '(' for the sake of macro | ||
| 5973 | ;; arguments. FIXME: Should build this regexp from the language | ||
| 5974 | ;; constants. | ||
| 5975 | (when (c-syntactic-re-search-forward | ||
| 5976 | "[ \t[:?;{=*/%&|,<>!@+-]" limit t t) ; not at EOB | ||
| 5977 | (backward-char) | ||
| 5978 | (setq qt-symbol-idx | ||
| 5979 | (and (c-major-mode-is 'c++-mode) | ||
| 5980 | (string-match | ||
| 5981 | "\\(p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|more\\)\\>" | ||
| 5982 | (buffer-substring start (point))))) | ||
| 5983 | (c-forward-syntactic-ws limit) | ||
| 5984 | (when (or (looking-at ":\\([^:]\\|\\'\\)") ; A single colon. | ||
| 5985 | (and qt-symbol-idx | ||
| 5986 | (search-forward-regexp "\\=slots\\>" limit t) | ||
| 5987 | (progn (c-forward-syntactic-ws limit) | ||
| 5988 | (looking-at ":\\([^:]\\|\\'\\)")))) ; A single colon | ||
| 5989 | (forward-char) ; to after the colon. | ||
| 5990 | t))) | ||
| 5930 | 5991 | ||
| 5931 | (save-restriction | 5992 | (save-restriction |
| 5932 | (narrow-to-region start (point)) | 5993 | (narrow-to-region start (point)) |
| @@ -6145,8 +6206,8 @@ comment at the start of cc-engine.el for more info." | |||
| 6145 | ;; so that we don't get stuck on that instead of the | 6206 | ;; so that we don't get stuck on that instead of the |
| 6146 | ;; function arglist. | 6207 | ;; function arglist. |
| 6147 | (c-forward-sexp)) | 6208 | (c-forward-sexp)) |
| 6148 | ((and c-opt-op-identitier-prefix | 6209 | ((and c-opt-op-identifier-prefix |
| 6149 | (looking-at c-opt-op-identitier-prefix)) | 6210 | (looking-at c-opt-op-identifier-prefix)) |
| 6150 | ;; Don't trip up on "operator ()". | 6211 | ;; Don't trip up on "operator ()". |
| 6151 | (c-forward-token-2 2 t))) | 6212 | (c-forward-token-2 2 t))) |
| 6152 | (and (< (point) beg) | 6213 | (and (< (point) beg) |
| @@ -6263,10 +6324,10 @@ comment at the start of cc-engine.el for more info." | |||
| 6263 | (and c-overloadable-operators-regexp | 6324 | (and c-overloadable-operators-regexp |
| 6264 | (zerop (c-backward-token-2 1 nil lim)) | 6325 | (zerop (c-backward-token-2 1 nil lim)) |
| 6265 | (looking-at c-overloadable-operators-regexp) | 6326 | (looking-at c-overloadable-operators-regexp) |
| 6266 | (or (not c-opt-op-identitier-prefix) | 6327 | (or (not c-opt-op-identifier-prefix) |
| 6267 | (and | 6328 | (and |
| 6268 | (zerop (c-backward-token-2 1 nil lim)) | 6329 | (zerop (c-backward-token-2 1 nil lim)) |
| 6269 | (looking-at c-opt-op-identitier-prefix))) | 6330 | (looking-at c-opt-op-identifier-prefix))) |
| 6270 | (point)))) | 6331 | (point)))) |
| 6271 | 6332 | ||
| 6272 | (defsubst c-backward-to-block-anchor (&optional lim) | 6333 | (defsubst c-backward-to-block-anchor (&optional lim) |
| @@ -6314,7 +6375,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6314 | ;; operator token preceded by "operator". | 6375 | ;; operator token preceded by "operator". |
| 6315 | (save-excursion | 6376 | (save-excursion |
| 6316 | (and (c-safe (c-backward-sexp) t) | 6377 | (and (c-safe (c-backward-sexp) t) |
| 6317 | (looking-at c-opt-op-identitier-prefix))) | 6378 | (looking-at c-opt-op-identifier-prefix))) |
| 6318 | (and (eq (char-before) ?<) | 6379 | (and (eq (char-before) ?<) |
| 6319 | (c-with-syntax-table c++-template-syntax-table | 6380 | (c-with-syntax-table c++-template-syntax-table |
| 6320 | (if (c-safe (goto-char (c-up-list-forward (point)))) | 6381 | (if (c-safe (goto-char (c-up-list-forward (point)))) |
| @@ -6354,6 +6415,10 @@ comment at the start of cc-engine.el for more info." | |||
| 6354 | ;; construct, i.e. if it isn't preceded by ';', '}', ':', bob, | 6415 | ;; construct, i.e. if it isn't preceded by ';', '}', ':', bob, |
| 6355 | ;; or an open paren. | 6416 | ;; or an open paren. |
| 6356 | (let ((beg (point)) tentative-move) | 6417 | (let ((beg (point)) tentative-move) |
| 6418 | ;; Go back one "statement" each time round the loop until we're just | ||
| 6419 | ;; after a ;, }, or :, or at BOB or the start of a macro or start of | ||
| 6420 | ;; an ObjC method. This will move over a multiple declaration whose | ||
| 6421 | ;; components are comma separated. | ||
| 6357 | (while (and | 6422 | (while (and |
| 6358 | ;; Must check with c-opt-method-key in ObjC mode. | 6423 | ;; Must check with c-opt-method-key in ObjC mode. |
| 6359 | (not (and c-opt-method-key | 6424 | (not (and c-opt-method-key |
| @@ -6397,25 +6462,39 @@ comment at the start of cc-engine.el for more info." | |||
| 6397 | knr-argdecl-start)) | 6462 | knr-argdecl-start)) |
| 6398 | (goto-char fallback-pos)))) | 6463 | (goto-char fallback-pos)))) |
| 6399 | 6464 | ||
| 6400 | ;; `c-beginning-of-statement-1' counts each brace block as a | 6465 | ;; `c-beginning-of-statement-1' counts each brace block as a separate |
| 6401 | ;; separate statement, so the result will be 'previous if we've | 6466 | ;; statement, so the result will be 'previous if we've moved over any. |
| 6402 | ;; moved over any. If they were brace list initializers we might | 6467 | ;; So change our result back to 'same if necessary. |
| 6403 | ;; not have moved over a declaration boundary though, so change it | 6468 | ;; |
| 6404 | ;; to 'same if we've moved past a '=' before '{', but not ';'. | 6469 | ;; If they were brace list initializers we might not have moved over a |
| 6405 | ;; (This ought to be integrated into `c-beginning-of-statement-1', | 6470 | ;; declaration boundary though, so change it to 'same if we've moved |
| 6406 | ;; so we avoid this extra pass which potentially can search over a | 6471 | ;; past a '=' before '{', but not ';'. (This ought to be integrated |
| 6407 | ;; large amount of text.) | 6472 | ;; into `c-beginning-of-statement-1', so we avoid this extra pass which |
| 6473 | ;; potentially can search over a large amount of text.). Take special | ||
| 6474 | ;; pains not to get mislead by C++'s "operator=", and the like. | ||
| 6408 | (if (and (eq move 'previous) | 6475 | (if (and (eq move 'previous) |
| 6409 | (c-with-syntax-table (if (c-major-mode-is 'c++-mode) | 6476 | (c-with-syntax-table (if (c-major-mode-is 'c++-mode) |
| 6410 | c++-template-syntax-table | 6477 | c++-template-syntax-table |
| 6411 | (syntax-table)) | 6478 | (syntax-table)) |
| 6412 | (save-excursion | 6479 | (save-excursion |
| 6413 | (and (c-syntactic-re-search-forward "[;={]" start t t t) | 6480 | (and |
| 6414 | (eq (char-before) ?=) | 6481 | (progn |
| 6415 | (c-syntactic-re-search-forward "[;{]" start t t) | 6482 | (while ; keep going back to "[;={"s until we either find |
| 6416 | (eq (char-before) ?{) | 6483 | ; no more, or get to one which isn't an "operator =" |
| 6417 | (c-safe (goto-char (c-up-list-forward (point))) t) | 6484 | (and (c-syntactic-re-search-forward "[;={]" start t t t) |
| 6418 | (not (c-syntactic-re-search-forward ";" start t t)))))) | 6485 | (eq (char-before) ?=) |
| 6486 | c-overloadable-operators-regexp | ||
| 6487 | c-opt-op-identifier-prefix | ||
| 6488 | (save-excursion | ||
| 6489 | (eq (c-backward-token-2) 0) | ||
| 6490 | (looking-at c-overloadable-operators-regexp) | ||
| 6491 | (eq (c-backward-token-2) 0) | ||
| 6492 | (looking-at c-opt-op-identifier-prefix)))) | ||
| 6493 | (eq (char-before) ?=)) | ||
| 6494 | (c-syntactic-re-search-forward "[;{]" start t t) | ||
| 6495 | (eq (char-before) ?{) | ||
| 6496 | (c-safe (goto-char (c-up-list-forward (point))) t) | ||
| 6497 | (not (c-syntactic-re-search-forward ";" start t t)))))) | ||
| 6419 | (cons 'same nil) | 6498 | (cons 'same nil) |
| 6420 | (cons move nil))))) | 6499 | (cons move nil))))) |
| 6421 | 6500 | ||
| @@ -6725,8 +6804,8 @@ comment at the start of cc-engine.el for more info." | |||
| 6725 | (setq braceassignp | 6804 | (setq braceassignp |
| 6726 | (cond | 6805 | (cond |
| 6727 | ;; Check for operator = | 6806 | ;; Check for operator = |
| 6728 | ((and c-opt-op-identitier-prefix | 6807 | ((and c-opt-op-identifier-prefix |
| 6729 | (looking-at c-opt-op-identitier-prefix)) | 6808 | (looking-at c-opt-op-identifier-prefix)) |
| 6730 | nil) | 6809 | nil) |
| 6731 | ;; Check for `<opchar>= in Pike. | 6810 | ;; Check for `<opchar>= in Pike. |
| 6732 | ((and (c-major-mode-is 'pike-mode) | 6811 | ((and (c-major-mode-is 'pike-mode) |
| @@ -7000,6 +7079,11 @@ comment at the start of cc-engine.el for more info." | |||
| 7000 | stop-at-boi-only | 7079 | stop-at-boi-only |
| 7001 | containing-sexp | 7080 | containing-sexp |
| 7002 | paren-state) | 7081 | paren-state) |
| 7082 | ;; Add the indicated SYNTAX-SYMBOL to `c-syntactic-context', extending it as | ||
| 7083 | ;; needed with further syntax elements of the types `substatement', | ||
| 7084 | ;; `inexpr-statement', `arglist-cont-nonempty', `statement-block-intro', and | ||
| 7085 | ;; `defun-block-intro'. | ||
| 7086 | ;; | ||
| 7003 | ;; Do the generic processing to anchor the given syntax symbol on | 7087 | ;; Do the generic processing to anchor the given syntax symbol on |
| 7004 | ;; the preceding statement: Skip over any labels and containing | 7088 | ;; the preceding statement: Skip over any labels and containing |
| 7005 | ;; statements on the same line, and then search backward until we | 7089 | ;; statements on the same line, and then search backward until we |
| @@ -8085,7 +8169,9 @@ comment at the start of cc-engine.el for more info." | |||
| 8085 | (and (eq (char-before) ?}) | 8169 | (and (eq (char-before) ?}) |
| 8086 | (save-excursion | 8170 | (save-excursion |
| 8087 | (let ((start (point))) | 8171 | (let ((start (point))) |
| 8088 | (if c-state-cache | 8172 | (if (and c-state-cache |
| 8173 | (consp (car c-state-cache)) | ||
| 8174 | (eq (cdar c-state-cache) (point))) | ||
| 8089 | ;; Speed up the backward search a bit. | 8175 | ;; Speed up the backward search a bit. |
| 8090 | (goto-char (caar c-state-cache))) | 8176 | (goto-char (caar c-state-cache))) |
| 8091 | (c-beginning-of-decl-1 containing-sexp) | 8177 | (c-beginning-of-decl-1 containing-sexp) |
| @@ -8103,26 +8189,30 @@ comment at the start of cc-engine.el for more info." | |||
| 8103 | 8189 | ||
| 8104 | ;; CASE 5J: we are at the topmost level, make | 8190 | ;; CASE 5J: we are at the topmost level, make |
| 8105 | ;; sure we skip back past any access specifiers | 8191 | ;; sure we skip back past any access specifiers |
| 8106 | ((save-excursion | 8192 | ((and |
| 8107 | (setq placeholder (point)) | 8193 | ;; A macro continuation line is never at top level. |
| 8108 | (or (memq char-before-ip '(?\; ?{ ?} nil)) | 8194 | (not (and macro-start |
| 8109 | (c-at-vsemi-p before-ws-ip) | 8195 | (> indent-point macro-start))) |
| 8110 | (when (and (eq char-before-ip ?:) | 8196 | (save-excursion |
| 8111 | (eq (c-beginning-of-statement-1 lim) | 8197 | (setq placeholder (point)) |
| 8112 | 'label)) | 8198 | (or (memq char-before-ip '(?\; ?{ ?} nil)) |
| 8113 | (c-backward-syntactic-ws lim) | 8199 | (c-at-vsemi-p before-ws-ip) |
| 8114 | (setq placeholder (point))) | 8200 | (when (and (eq char-before-ip ?:) |
| 8115 | (and (c-major-mode-is 'objc-mode) | 8201 | (eq (c-beginning-of-statement-1 lim) |
| 8116 | (catch 'not-in-directive | 8202 | 'label)) |
| 8117 | (c-beginning-of-statement-1 lim) | 8203 | (c-backward-syntactic-ws lim) |
| 8118 | (setq placeholder (point)) | 8204 | (setq placeholder (point))) |
| 8119 | (while (and (c-forward-objc-directive) | 8205 | (and (c-major-mode-is 'objc-mode) |
| 8120 | (< (point) indent-point)) | 8206 | (catch 'not-in-directive |
| 8121 | (c-forward-syntactic-ws) | 8207 | (c-beginning-of-statement-1 lim) |
| 8122 | (if (>= (point) indent-point) | 8208 | (setq placeholder (point)) |
| 8123 | (throw 'not-in-directive t)) | 8209 | (while (and (c-forward-objc-directive) |
| 8124 | (setq placeholder (point))) | 8210 | (< (point) indent-point)) |
| 8125 | nil)))) | 8211 | (c-forward-syntactic-ws) |
| 8212 | (if (>= (point) indent-point) | ||
| 8213 | (throw 'not-in-directive t)) | ||
| 8214 | (setq placeholder (point))) | ||
| 8215 | nil))))) | ||
| 8126 | ;; For historic reasons we anchor at bol of the last | 8216 | ;; For historic reasons we anchor at bol of the last |
| 8127 | ;; line of the previous declaration. That's clearly | 8217 | ;; line of the previous declaration. That's clearly |
| 8128 | ;; highly bogus and useless, and it makes our lives hard | 8218 | ;; highly bogus and useless, and it makes our lives hard |
| @@ -8177,6 +8267,11 @@ comment at the start of cc-engine.el for more info." | |||
| 8177 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) | 8267 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
| 8178 | (c-add-syntax 'template-args-cont (c-point 'boi))) | 8268 | (c-add-syntax 'template-args-cont (c-point 'boi))) |
| 8179 | 8269 | ||
| 8270 | ;; CASE 5Q: we are at a statement within a macro. | ||
| 8271 | (macro-start | ||
| 8272 | (c-beginning-of-statement-1 containing-sexp) | ||
| 8273 | (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) | ||
| 8274 | |||
| 8180 | ;; CASE 5M: we are at a topmost continuation line | 8275 | ;; CASE 5M: we are at a topmost continuation line |
| 8181 | (t | 8276 | (t |
| 8182 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) | 8277 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |