From 66bf12b6a1777d8dd09f8ddcefe96314555d0134 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Mon, 27 Aug 2018 20:37:49 +0000 Subject: [PATCH] CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont This happened when the type of the previous function was a struct, etc., declaration. * lisp/progmodes/cc-mode (c-guess-basic-syntax CASE 5N): Check here (for 'topmost-intro-cont) that the first opening brace after BOD is the opening brace preceding the starting point. --- lisp/progmodes/cc-engine.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index d1eb3c3d06f..278ade0560c 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12280,7 +12280,18 @@ comment at the start of cc-engine.el for more info." ;; The '}' is unbalanced. nil (c-end-of-decl-1) - (>= (point) indent-point)))))) + (>= (point) indent-point)))) + ;; Check that we only have one brace block here, i.e. that we + ;; don't have something like a function with a struct + ;; declaration as its type. + (save-excursion + (or (not (and state-cache (consp (car state-cache)))) + ;; The above probably can't happen. + (progn + (goto-char placeholder) + (and (c-syntactic-re-search-forward + "{" indent-point t) + (eq (1- (point)) (caar state-cache)))))))) (goto-char placeholder) (c-add-stmt-syntax 'topmost-intro-cont nil nil containing-sexp paren-state)) -- 2.39.5