1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/1b5c372f3b60/
Changeset: 1b5c372f3b60
User: acm
Date: 2018-01-21 18:05:41+00:00
Summary: Handle C99 Compound Literals in return statements and argument lists.
* cc-engine.el (c-looking-at-or-maybe-in-bracelist): Recognize a brace list
when preceded by "return" or inside parentheses, either immediately after the
"(" or following a comma.
(c-looking-at-inexpr-block): Test c-has-compound-literals rather than hard
coded C++ Mode.
(c-guess-basic-syntax, CASE 7B): Test additionally for not being just inside a
parenthesis or being at a Java "new" keyword. CASE 9: Remove the simple
minded test on the contents of a block to determine a brace list.
* cc-langs.el (c-has-compound-literals): New lang const and lang var.
Affected #: 2 files
diff -r 47ceda16abc59b73d2bed96eb6eb93499eacc9f7 -r
1b5c372f3b60eea55165c6d04738f98905cd5a11 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -10534,6 +10534,17 @@
((and class-key
(looking-at class-key))
(setq braceassignp nil))
+ ((and c-has-compound-literals
+ (looking-at c-return-key))
+ (setq braceassignp t)
+ nil)
+ ((and c-has-compound-literals
+ (eq (char-after) ?,))
+ (save-excursion
+ (when (and (c-go-up-list-backward nil lim)
+ (eq (char-after) ?\())
+ (setq braceassignp t)
+ nil)))
((eq (char-after) ?=)
;; We've seen a =, but must check earlier tokens so
;; that it isn't something that should be ignored.
@@ -10572,9 +10583,14 @@
))))
nil)
(t t))))))
- (if (and (eq braceassignp 'dontknow)
- (/= (c-backward-token-2 1 t lim) 0))
- (setq braceassignp nil)))
+ (when (and (eq braceassignp 'dontknow)
+ (/= (c-backward-token-2 1 t lim) 0))
+ (if (save-excursion
+ (and c-has-compound-literals
+ (eq (c-backward-token-2 1 nil lim) 0)
+ (eq (char-after) ?\()))
+ (setq braceassignp t)
+ (setq braceassignp nil))))
(cond
(braceassignp
@@ -10939,7 +10955,7 @@
(c-on-identifier)))
(and c-special-brace-lists
(c-looking-at-special-brace-list))
- (and (c-major-mode-is 'c++-mode)
+ (and c-has-compound-literals
(save-excursion
(goto-char block-follows)
(not (c-looking-at-statement-block)))))
@@ -12449,6 +12465,11 @@
;; in-expression block or brace list. C.f. cases 4, 16A
;; and 17E.
((and (eq char-after-ip ?{)
+ (or (not (eq (char-after containing-sexp) ?\())
+ (save-excursion
+ (and c-opt-inexpr-brace-list-key
+ (eq (c-beginning-of-statement-1 lim t nil t) 'same)
+ (looking-at c-opt-inexpr-brace-list-key))))
(progn
(setq placeholder (c-inside-bracelist-p (point)
paren-state
@@ -12575,11 +12596,7 @@
(save-excursion
(goto-char containing-sexp)
(c-looking-at-special-brace-list)))
- (c-inside-bracelist-p containing-sexp paren-state t)
- (save-excursion
- (goto-char containing-sexp)
- (and (eq (char-after) ?{)
- (not (c-looking-at-statement-block)))))))
+ (c-inside-bracelist-p containing-sexp paren-state t))))
(cond
;; CASE 9A: In the middle of a special brace list opener.
diff -r 47ceda16abc59b73d2bed96eb6eb93499eacc9f7 -r
1b5c372f3b60eea55165c6d04738f98905cd5a11 cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -600,6 +600,12 @@
c++ t)
(c-lang-defvar c-has-quoted-numbers (c-lang-const c-has-quoted-numbers))
+(c-lang-defconst c-has-compound-literals
+ "Whether literal initializers {...} are used other than in initializations."
+ t nil
+ (c c++) t)
+(c-lang-defvar c-has-compound-literals (c-lang-const c-has-compound-literals))
+
(c-lang-defconst c-modified-constant
"Regexp that matches a \"modified\" constant literal such as
\"L'a'\",
a \"long character\". In particular, this recognizes forms of constant
Repository URL:
https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.