bug#59233: CC Mode 5.35.2 (C/*l); (A different type of) incorrect fontification of variables as types while typing
Alan Mackenzie <[email protected]> Sun, 13 Nov 2022 14:06:13 +0000
| Newsgroups | gmane.emacs.cc-mode.general |
|---|---|
| Message-ID | <Y3D51bMB5Tp63I53@ACM> |
Hello, Po.
Thanks for the most recent two bug reports!
On Sun, Nov 13, 2022 at 09:24:28 +0800, Po Lu via CC-Mode-help wrote:
> Package: cc-mode
> Hello. If you put the following in a C mode buffer:
> foo (void)
> {
> Window root;
> xcb_randr_get_providers_cookie_t cookie;
> xcb_randr_get_providers_reply_t *reply;
> xcb_randr_provider_t *providers;
> int nproviders;
> xcb_dri3_open_cookie_t *open_cookies;
> xcb_dri3_open_reply_t *open_replies;
> int ndevices;
> root = DefaultRootWindow (compositor.display);
> /* Get a list of all providers on the default screen. */
> cookie = xcb_randr_get_providers (compositor.conn,
> root,
> XCB_CURRENT_TIME);
> reply = xcb_randr_get_providers_reply (compositor.conn,
> cookie, NULL);
> if (!reply)
> return NULL;
> providers = xcb_randr_get_providers_providers (reply);
> nproviders = xcb_randr_get_providers_providers_length (reply);
> /* Now, open each and every provider. */
> open_cookies = alloca (nproviders * sizeof *open_cookies);
> open_replies = alloca (nproviders )
> }
> place point after the last "nproviders", and type:
> SPC * SPC s i z e o f SPC * o p e n _ r e p l i e s
> nproviders will be mistakenly recognized as a type. I guess because it
> looks like a pointer to nproviders to CC Mode.
It looks like a function declaration int foo (nproviders *), declaring a
function taking one argument, with type a pointer to nproviders.
This is very similar to a previous bug, hence easy to correct. Would
you please do the usual with the attached patch. Thanks!
> Thanks.
> Emacs : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu)
> of 2022-11-12
> Package: CC Mode 5.35.2 (C/*l)
> Buffer Style: gnu
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit)
[ .... ]
--
Alan Mackenzie (Nuremberg, Germany).
diff.20221113.diff
(text/plain, 619 B)
diff -r d83cff83c20e cc-engine.el --- a/cc-engine.el Thu Nov 10 09:56:38 2022 +0000 +++ b/cc-engine.el Sun Nov 13 13:28:20 2022 +0000 @@ -11099,6 +11099,11 @@ ;; `got-parens' or `got-suffix' is set it's "a()", "a[]", "a()[]", ;; or similar, which we accept only if the context rules out ;; expressions. + ;; + ;; If we've got at-type 'maybe, we cannot confidently promote the + ;; possible type to a found type. + (when (and (eq at-type 'maybe)) + (setq unsafe-maybe t)) (throw 'at-decl-or-cast t))) ;; If we had a complete symbol table here (which rules out