changeset 45049:11c11cb2b8a8

(c-beginning-of-decl-1): Better way to handle protection labels, one which doesn't get confused by inherit colons. (c-end-of-decl-1): Don't treat functions that have "class" or "struct" in the return type as classes or structs.
author Martin Stjernholm <mast@lysator.liu.se>
date Tue, 30 Apr 2002 23:00:54 +0000
parents 6bd149ec8b77
children 2cc4536a69b6
files lisp/progmodes/cc-engine.el
diffstat 1 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cc-engine.el	Tue Apr 30 22:48:27 2002 +0000
+++ b/lisp/progmodes/cc-engine.el	Tue Apr 30 23:00:54 2002 +0000
@@ -1608,7 +1608,7 @@
   (catch 'return
     (let* ((start (point))
 	 (last-stmt-start (point))
-	 (move (c-beginning-of-statement-1 lim nil t)))
+	 (move (c-beginning-of-statement-1 lim t t)))
 
     (while (and (/= last-stmt-start (point))
 		(save-excursion
@@ -1618,7 +1618,7 @@
       ;; want to continue if the block doesn't begin a top level
       ;; construct, i.e. if it isn't preceded by ';', '}', ':', or bob.
       (setq last-stmt-start (point)
-	    move (c-beginning-of-statement-1 lim nil t)))
+	    move (c-beginning-of-statement-1 lim t t)))
 
     (when c-recognize-knr-p
       (let ((fallback-pos (point)) knr-argdecl-start)
@@ -1634,7 +1634,7 @@
 		 (< knr-argdecl-start start)
 		 (progn
 		   (goto-char knr-argdecl-start)
-		   (not (eq (c-beginning-of-statement-1 lim nil t) 'macro))))
+		   (not (eq (c-beginning-of-statement-1 lim t t) 'macro))))
 	    (throw 'return
 		   (cons (if (eq (char-after fallback-pos) ?{)
 			     'previous
@@ -1642,6 +1642,17 @@
 			 knr-argdecl-start))
 	  (goto-char fallback-pos))))
 
+    (when c-opt-access-key
+      ;; Might have ended up before a protection label.  This should
+      ;; perhaps be checked before `c-recognize-knr-p' to be really
+      ;; accurate, but we know that no language has both.
+      (while (looking-at c-opt-access-key)
+	(goto-char (match-end 0))
+	(c-forward-syntactic-ws)
+	(when (>= (point) start)
+	  (goto-char start)
+	  (throw 'return (cons 'same nil)))))
+
     ;; `c-beginning-of-statement-1' counts each brace block as a
     ;; separate statement, so the result will be 'previous if we've
     ;; moved over any.  If they were brace list initializers we might
@@ -1700,13 +1711,19 @@
 		  (c-with-syntax-table decl-syntax-table
 		    (let ((lim (point)))
 		      (goto-char start)
-		      (not (and (c-syntactic-re-search-forward
-				 (concat "[;=\(\[{]\\|\\<\\("
-					 c-opt-block-decls-with-vars-key
-					 "\\)")
-				 lim t 1 t)
-				(match-beginning 1)
-				(not (eq (char-before) ?_))))))))
+		      (not (and
+			    ;; Check for `c-opt-block-decls-with-vars-key'
+			    ;; before the first paren.
+			    (c-syntactic-re-search-forward
+			     (concat "[;=\(\[{]\\|\\<\\("
+				     c-opt-block-decls-with-vars-key
+				     "\\)")
+			     lim t 1 t)
+			    (match-beginning 1)
+			    (not (eq (char-before) ?_))
+			    ;; Check that the first following paren is the block.
+			    (c-syntactic-re-search-forward "[;=\(\[{]" lim t 1 t)
+			    (eq (char-before) ?{)))))))
 	    ;; The declaration doesn't have any of the
 	    ;; `c-opt-block-decls-with-vars' keywords in the
 	    ;; beginning, so it ends here at the end of the block.
@@ -3408,7 +3425,8 @@
 	      (setq lim (c-most-enclosing-brace c-state-cache (point)))
 	      (c-beginning-of-statement-1 lim)
 	      (c-add-stmt-syntax 'brace-list-close t lim
-				 (c-whack-state-after (point) paren-state) t)))
+				 (c-whack-state-after (point) paren-state)
+				 t)))
 	   (t
 	    ;; Prepare for the rest of the cases below by going to the
 	    ;; token following the opening brace