* bug#33649: 26.1.50; variable is highlighted as type in c++ mode @ 2018-12-06 11:21 Shanavas [not found] ` <mailman.5279.1544110157.1284.bug-gnu-emacs@gnu.org> 0 siblings, 1 reply; 4+ messages in thread From: Shanavas @ 2018-12-06 11:21 UTC (permalink / raw) To: 33649 [-- Attachment #1: Type: text/plain, Size: 321 bytes --] For the following snippet, ``` int a = 9; func(a); func(a * 9); ``` `a` is highlighted differently in two function calls. In `func(a)` it is highlighted as a variable where in `func(a * 9)` it is highlighted as a type. Major mode: C++//l -- ഷാനവാസ് Sent from my Android device with K-9 Mail. [-- Attachment #2: Type: text/html, Size: 373 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.5279.1544110157.1284.bug-gnu-emacs@gnu.org>]
* bug#33649: 26.1.50; variable is highlighted as type in c++ mode [not found] ` <mailman.5279.1544110157.1284.bug-gnu-emacs@gnu.org> @ 2018-12-07 16:39 ` Alan Mackenzie 2018-12-10 7:42 ` Shanavas 0 siblings, 1 reply; 4+ messages in thread From: Alan Mackenzie @ 2018-12-07 16:39 UTC (permalink / raw) To: Shanavas; +Cc: 33649 Hello Shanavas. In article <mailman.5279.1544110157.1284.bug-gnu-emacs@gnu.org> you wrote: > [-- text/plain, encoding quoted-printable, charset: utf-8, 15 lines --] > For the following snippet, > ``` > int a = 9; > func(a); > func(a * 9); > ``` > `a` is highlighted differently in two function calls. > In `func(a)` it is highlighted as a variable where in `func(a * 9)` it is highlighted as a type. Yes. It is due to CC Mode parsing "a *" as a "pointer to type a" without taking into account the following "9". Thanks for taking the trouble to report this bug. The following patch should fix this. Would you please try it out on your real source code, and either confirm to me that it works, or tell me what is still wrong. The patch should be applied to emacs/lisp/progmodes/cc-engine.el, and you should then byte-compile the patched file. If you want any help with the patching or the byte compilation, feel free to send me private mail. Thanks again, and looking forward to hearing back from you. diff -r 021672422937 cc-engine.el --- a/cc-engine.el Sat Nov 24 10:18:12 2018 +0000 +++ b/cc-engine.el Fri Dec 07 16:23:37 2018 +0000 @@ -8551,6 +8551,8 @@ 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 @@ -8628,7 +8630,9 @@ (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 @@ -9102,7 +9106,7 @@ ;; 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)))) > Major mode: C++//l > -- > ഷാനവാസ് > Sent from my Android device with K-9 Mail. -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#33649: 26.1.50; variable is highlighted as type in c++ mode 2018-12-07 16:39 ` Alan Mackenzie @ 2018-12-10 7:42 ` Shanavas 2018-12-10 12:20 ` Alan Mackenzie 0 siblings, 1 reply; 4+ messages in thread From: Shanavas @ 2018-12-10 7:42 UTC (permalink / raw) To: Alan Mackenzie; +Cc: 33649 [-- Attachment #1: Type: text/plain, Size: 150 bytes --] Thanks, Works great. Please apply appropriate patch to emacs-26 branch too. -- ഷാനവാസ് Sent from my Android device with K-9 Mail. [-- Attachment #2: Type: text/html, Size: 170 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#33649: 26.1.50; variable is highlighted as type in c++ mode 2018-12-10 7:42 ` Shanavas @ 2018-12-10 12:20 ` Alan Mackenzie 0 siblings, 0 replies; 4+ messages in thread From: Alan Mackenzie @ 2018-12-10 12:20 UTC (permalink / raw) To: Shanavas; +Cc: 33649-done Hello, Shanavas. On Mon, Dec 10, 2018 at 13:12:54 +0530, Shanavas wrote: > Thanks, Works great. Thank you for the testing! > Please apply appropriate patch to emacs-26 branch too. I've applied the patch to the emacs-26 branch. It will filter through to the master branch in due course when "somebody" activates the movement of bug fixes from emacs-26 to master. I'm closing the bug, now. > -- > ഷാനവാസ് > Sent from my Android device with K-9 Mail. -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-10 12:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-12-06 11:21 bug#33649: 26.1.50; variable is highlighted as type in c++ mode Shanavas [not found] ` <mailman.5279.1544110157.1284.bug-gnu-emacs@gnu.org> 2018-12-07 16:39 ` Alan Mackenzie 2018-12-10 7:42 ` Shanavas 2018-12-10 12:20 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).