emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 5a7451c: CC Mode: stop wrongly recognizing "func(


From: Alan Mackenzie
Subject: [Emacs-diffs] emacs-26 5a7451c: CC Mode: stop wrongly recognizing "func(a * 9)" as "pointer to type a"
Date: Mon, 10 Dec 2018 07:19:51 -0500 (EST)

branch: emacs-26
commit 5a7451c383be5e6be52c986a9392ff551e656f6a
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    CC Mode: stop wrongly recognizing "func(a * 9)" as "pointer to type a"
    
    * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): When testing for 
an
    identifier after "a *", on failure additionally check for a digit, setting a
    new flag variable got-number if one is found.  In the test for CASE 18, 
check
    this flag.
---
 lisp/progmodes/cc-engine.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 317968a..4bd85d7 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8514,6 +8514,8 @@ comment at the start of cc-engine.el for more info."
          got-parens
          ;; True if there is an identifier in the declarator.
          got-identifier
+         ;; True if we find a number where an identifier was expected.
+         got-number
          ;; True if there's a non-close-paren match of
          ;; `c-type-decl-suffix-key'.
          got-suffix
@@ -8591,7 +8593,9 @@ comment at the start of cc-engine.el for more info."
          (and (looking-at c-identifier-start)
               (setq pos (point))
               (setq got-identifier (c-forward-name))
-              (setq name-start pos)))
+              (setq name-start pos))
+         (when (looking-at "[0-9]")
+           (setq got-number t))) ; We've probably got an arithmetic expression.
 
       ;; Skip over type decl suffix operators and trailing noise macros.
       (while
@@ -9056,7 +9060,7 @@ comment at the start of cc-engine.el for more info."
 
           ;; CASE 18
           (when (and (not (memq context '(nil top)))
-                     (or got-prefix
+                     (or (and got-prefix (not got-number))
                          (and (eq context 'decl)
                               (not c-recognize-paren-inits)
                               (or got-parens got-suffix))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]