]> git.eshelyaron.com Git - emacs.git/commitdiff
(c-beginning-of-decl-1): Better way to handle protection labels, one
authorMartin Stjernholm <mast@lysator.liu.se>
Tue, 30 Apr 2002 23:02:19 +0000 (23:02 +0000)
committerMartin Stjernholm <mast@lysator.liu.se>
Tue, 30 Apr 2002 23:02:19 +0000 (23:02 +0000)
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.

lisp/ChangeLog
lisp/progmodes/cc-engine.el

index b81ebc84d077f158e971b632e11374e6810181af..1608b0e6dd08cede82d218e11f5a1b42f8c133d2 100644 (file)
@@ -1,3 +1,13 @@
+2002-05-01  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+       * progmodes/cc-engine.el (c-beginning-of-decl-1): Better way
+       to handle protection labels, one which doesn't get confused by
+       inherit colons.
+
+       * progmodes/cc-engine.el (c-end-of-decl-1): Don't treat
+       functions that have "class" or "struct" in the return type as
+       classes or structs.
+
 2002-04-30  Kim F. Storm  <storm@cua.dk>
 
        * menu-bar.el (menu-bar-custom-menu): Change "Recently Changed
index 25346dad97e497156ba67caba1397183eeabf4bf..fd5340f190d4bc0635af3cd4f1b52c4b29dae151 100644 (file)
@@ -1608,7 +1608,7 @@ brace."
   (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 @@ brace."
       ;; 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 @@ brace."
                 (< 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 @@ brace."
                         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 @@ brace."
                  (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 @@ Keywords are recognized and not considered identifiers."
              (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