From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 03 18:02:30 2020 Received: (at submit) by debbugs.gnu.org; 3 Feb 2020 23:02:30 +0000 Received: from localhost ([127.0.0.1]:42304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iykjd-00045Y-Sq for submit@debbugs.gnu.org; Mon, 03 Feb 2020 18:02:30 -0500 Received: from heimdallr.csail.mit.edu ([128.30.29.50]:58296 helo=mail-csail.ecg.mit.edu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iykjc-00045J-72 for submit@debbugs.gnu.org; Mon, 03 Feb 2020 18:02:29 -0500 Received: from pc57.ecg.mit.edu (benjamin-pc.ecg.mit.edu [192.168.1.57]) by mail-csail.ecg.mit.edu (Postfix) with ESMTP id BECCB9FEE1 for ; Mon, 3 Feb 2020 18:02:22 -0500 (EST) Received: from benjamin by pc57.ecg.mit.edu with local (Exim 4.92) (envelope-from ) id 1iykjW-00021c-IK for submit@debbugs.gnu.org; Mon, 03 Feb 2020 18:02:22 -0500 From: Benjamin Moody To: submit@debbugs.gnu.org Subject: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" X-Debbugs-Package: cc-mode Date: Mon, 03 Feb 2020 18:02:22 -0500 Message-ID: <87r1zbnukh.fsf@pc57.ecg.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 3.2 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Emacs gives slightly odd fontification for the following C source: int *foo(int length) { return malloc(length * sizeof(int)); } In either C or C++ mode, the identifier 'length' in the third line is formatted as a type name (font-lock-type-face). (In ObjC mode, this doesn't happen.) Content analysis details: (3.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [128.30.29.50 listed in list.dnswl.org] 0.4 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (benjaminmoody[at]gmail.com) 1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received' headers 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different 2.0 SPOOFED_FREEMAIL No description available. X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) Emacs gives slightly odd fontification for the following C source: int *foo(int length) { return malloc(length * sizeof(int)); } In either C or C++ mode, the identifier 'length' in the third line is formatted as a type name (font-lock-type-face). (In ObjC mode, this doesn't happen.) I'm not sure if this problem is limited to "identifier followed by '*' followed by 'sizeof'", but that pattern occurs often enough to be distinctive. :) Emacs : GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-09-22, modified by Debian Package: CC Mode 5.33.1 (C/*l) Buffer Style: gnu c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-st= ring-delim gen-comment-delim syntax-properties 1-bit) current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq c-basic-offset 2 c-comment-only-line-offset '(0 . 0) c-indent-comment-alist '((anchored-comment column . 0) (end-block space . = 1) (cpp-end-block space . 2)) c-indent-comments-syntactically-p nil c-block-comment-prefix "" c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|\\**")) c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((substatement-open before after) (arglist-cont-nonempty)) c-hanging-colons-alist nil c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist) c-backslash-column 48 c-backslash-max-column 72 c-special-indent-hook '(c-gnu-impose-minimum) c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . c-lineup-inexpr-block) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call + ) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist ) (arglist-cont c-lineup-gcc-asm-reg 0) (comment-intro c-lineup-knr-region-comment c-lineup-comment ) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (access-label . -) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont ) (brace-list-open . +) (inline-open . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . 0) (substatement-label . 0) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) (brace-list-intro . +) (brace-list-entry . 0) ) c-buffer-is-cc-mode 'c-mode c-tab-always-indent t c-syntactic-indentation t c-syntactic-indentation-in-macros t c-ignore-auto-fill '(string cpp code) c-auto-align-backslashes t c-backspace-function 'backward-delete-char-untabify c-delete-function 'delete-char c-electric-pound-behavior nil c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu")) c-enable-xemacs-performance-kludge-p nil c-old-style-variable-behavior nil defun-prompt-regexp nil tab-width 8 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function nil comment-multi-line t comment-start-skip "\\(//+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 70 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*$\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-=E2=80=93!|#%= ;>*=C2=B7=E2=80=A2=E2=80=A3=E2=81=83=E2=97=A6]+[ ]*\\)*\\)" ) From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 05 15:57:34 2020 Received: (at 39409) by debbugs.gnu.org; 5 Feb 2020 20:57:34 +0000 Received: from localhost ([127.0.0.1]:46815 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1izRjp-00082Y-RA for submit@debbugs.gnu.org; Wed, 05 Feb 2020 15:57:34 -0500 Received: from colin.muc.de ([193.149.48.1]:33161 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1izRjn-00082P-VY for 39409@debbugs.gnu.org; Wed, 05 Feb 2020 15:57:32 -0500 Received: (qmail 29012 invoked by uid 3782); 5 Feb 2020 20:57:30 -0000 Received: from acm.muc.de (p4FE15C1C.dip0.t-ipconnect.de [79.225.92.28]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 05 Feb 2020 21:57:27 +0100 Received: (qmail 7701 invoked by uid 1000); 5 Feb 2020 20:57:27 -0000 Date: Wed, 5 Feb 2020 20:57:27 +0000 To: Benjamin Moody Subject: Re: bug#39409: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" Message-ID: <20200205205727.GA7507@ACM> References: <87r1zbnukh.fsf@pc57.ecg.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r1zbnukh.fsf@pc57.ecg.mit.edu> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39409 Cc: 39409@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Benjamin. Thank you for taking the trouble to report this bug, and thanks even more for appending a full CC-Mode configuration dump from C-c C-b. On Mon, Feb 03, 2020 at 18:02:22 -0500, Benjamin Moody wrote: > Emacs gives slightly odd fontification for the following C source: > int *foo(int length) > { > return malloc(length * sizeof(int)); > } > In either C or C++ mode, the identifier 'length' in the third line is > formatted as a type name (font-lock-type-face). (In ObjC mode, this > doesn't happen.) The problem was actually fixed in 2017, but hasn't yet made it through to a released version of Emacs. > I'm not sure if this problem is limited to "identifier followed by '*' > followed by 'sizeof'", but that pattern occurs often enough to be > distinctive. :) The problem was an awkward ambiguity, where foo * bar(baz) could be either a multiplication of foo by the result of calling bar, or the declaration of a function bar taking a parameter of type baz and returning a pointer to something of type foo. One really needs semantic analysis to resolve this properly, but until that happens, the workaround adopted is to use the (a)symmetry of whitespace around the * operator - If we have one of foo * bar(baz) foo*bar(baz) we treat the * as a mulplication. If we have one of foo *bar(baz) foo* bar(baz) the whole thing is a function declaration. This seems to work, more or less, in most cases. I would recommend you to upgrade your CC Mode. There are several ways to do this, in order of increasing work to you: 1/- Wait until the release of Emacs 27.1. This will be several months away, but probably less than a year. 2/- Ask me to send you a tarball of the current CC Mode in Emacs. 3/- Download the last released standalone CC Mode 5.34 from http://cc-mode.sourceforge.net/ (Note: the standalone version and that in Emacs have drifted apart, somewhat). 4/- Get the head of the Mercurial repository at the above address. 5/- Check out the entire Emacs repository from https://savannah.gnu.org, and use the not-quite-in-pretest Emacs version 27. 6/- Extract the CC Mode sources from the Emacs repository, and use those in Emacs 26. In all these methods apart from the first, you will need to byte compile the CC Mode sources (which isn't difficult). > Emacs : GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) > of 2019-09-22, modified by Debian > Package: CC Mode 5.33.1 (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 1-bit) [ .... ] -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 05 23:39:36 2020 Received: (at 39409) by debbugs.gnu.org; 6 Feb 2020 04:39:37 +0000 Received: from localhost ([127.0.0.1]:46989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1izYwy-00026m-Et for submit@debbugs.gnu.org; Wed, 05 Feb 2020 23:39:36 -0500 Received: from mail-il1-f173.google.com ([209.85.166.173]:34975) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1izUXn-0003pg-G2 for 39409@debbugs.gnu.org; Wed, 05 Feb 2020 18:57:20 -0500 Received: by mail-il1-f173.google.com with SMTP id g12so3509658ild.2 for <39409@debbugs.gnu.org>; Wed, 05 Feb 2020 15:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tVoc3Ey3MMCxPcXL90rG4br7JKEQpK2fGX8KPnr2gFA=; b=cY0zcpMCXt9mBor1K7uqwgBHi0wawGEBR61MZ+bfV0DFlDSx6Wrm4KvjrhvmQPljvF bX8k2B//jrJNmWRj2yk44om0I3v3qhdR/U/wsTYmNsHAm9NjvT3Ar3giCNEh7wUL5HOh abdA3NXxWNqPnO6nGDch70m31MIfYAjQQauUMTYUEWOFgHUtwERsJ4wdZ0IPx+mIiX0E U938fgA26vgaXjTAI1jgcL0COxzTRt981xh9M4BtGH56d8YlNRCwpM0rUyG0U25BRB0W PdoAztOgjIhbmc9H38RMYQblpHu8km5oS+t/2MK6xPwi+Ui/lL9UhtDO/oopAL4K+rTn ECtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tVoc3Ey3MMCxPcXL90rG4br7JKEQpK2fGX8KPnr2gFA=; b=mwnp/sGZUIrqkJW/EKW4K48zu032ypIs7RDUO8dbDsIHQdXHcaZ4Lqc1EBwTxu6xgw 79PwdccnR45ebfQhqFy3pIHj9TV7m9Roj/Sjwzh6syWvHXwXFp3VZdX4IrIFwdxFROtd /IOZf4OmlU3dp7wjymASRNQ5KqywIR3wb8GSKnF/FIvZI68pIZ5FQBFRmw2npKa0IT9n Ta6HOdQW58074mzHPzLshBE9bNEkKaYtc32MelcA6XzHxtC83rb6z670bDjZcbB0+lO/ nT9x2QWsdvQBb8EfpUJLc9KypEOq/rlJim+QWqjuw61rKfQURiAMZ0DFVoot0wu2Egck u60Q== X-Gm-Message-State: APjAAAUL2q5wbxUUoMTn8I0Sg9X0C96zGz/WdWoOH536t5McMWHCbTMt BFNlP454e8N4d5bOYpXSe7ceLNXIUVprlpPioBTHJufg X-Google-Smtp-Source: APXvYqx9nxc0k39re51JwUqtAcsl9OsgL1Wogs50xj0iUqcgEGgcLVccSkDoix8ooWfGS7c3zi7L1VVwZ4ll3kgNo3M= X-Received: by 2002:a92:88c4:: with SMTP id m65mr801752ilh.165.1580947033670; Wed, 05 Feb 2020 15:57:13 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:1dc2:0:0:0:0:0 with HTTP; Wed, 5 Feb 2020 15:57:13 -0800 (PST) In-Reply-To: <20200205205727.GA7507@ACM> References: <87r1zbnukh.fsf@pc57.ecg.mit.edu> <20200205205727.GA7507@ACM> From: Benjamin Moody Date: Wed, 5 Feb 2020 23:57:13 +0000 Message-ID: Subject: Re: bug#39409: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39409 X-Mailman-Approved-At: Wed, 05 Feb 2020 23:39:35 -0500 Cc: 39409@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Thank you for all your work on CC Mode. And yeah, I know C syntax can get pretty hairy. :) The curious thing is, though, this issue doesn't seem to occur with "foo * bar(baz)". What I'm seeing seems to happen specifically when the "function" is actually a keyword (like sizeof), and the expression is enclosed in parentheses: void foo() { xxx(xxx * xxx(xxx)); /* correct */ xxx(ttt * sizeof(xxx)); /* wrong */ xxx(xxx, xxx * xxx(xxx)); /* correct */ xxx(xxx, ttt * sizeof(xxx)); /* wrong */ ttt * fff(xxx); /* ambiguous, but logical */ xxx * sizeof(xxx); /* correct */ (xxx * xxx(xxx)); /* correct */ (ttt * sizeof(xxx)); /* wrong */ xxx = xxx * xxx(xxx); /* correct */ xxx = xxx * sizeof(xxx); /* correct */ xxx = (ttt * fff(xxx)); /* wrong (I think) */ xxx = (xxx * sizeof(xxx)); /* correct */ } (In these examples, 'xxx' uses the default face, 'ttt' uses font-lock-type-face, 'fff' uses font-lock-function-name-face, and of course 'sizeof' uses font-lock-keyword-face.) I tried the standalone version (cc-mode-5.34.tar.gz) and it appears to give the same results as above. Benjamin From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 06 15:21:47 2020 Received: (at 39409) by debbugs.gnu.org; 6 Feb 2020 20:21:47 +0000 Received: from localhost ([127.0.0.1]:48582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iznel-0003T0-A7 for submit@debbugs.gnu.org; Thu, 06 Feb 2020 15:21:47 -0500 Received: from colin.muc.de ([193.149.48.1]:37808 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1iznej-0003Ss-Fn for 39409@debbugs.gnu.org; Thu, 06 Feb 2020 15:21:46 -0500 Received: (qmail 2100 invoked by uid 3782); 6 Feb 2020 20:21:43 -0000 Received: from acm.muc.de (p4FE15CAF.dip0.t-ipconnect.de [79.225.92.175]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 06 Feb 2020 21:21:41 +0100 Received: (qmail 4559 invoked by uid 1000); 6 Feb 2020 20:21:41 -0000 Date: Thu, 6 Feb 2020 20:21:41 +0000 To: Benjamin Moody Subject: Re: bug#39409: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" Message-ID: <20200206202141.GA4293@ACM> References: <87r1zbnukh.fsf@pc57.ecg.mit.edu> <20200205205727.GA7507@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39409 Cc: 39409@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello again, Benjamin. Apologies for answering your original post rather hastily. CC Mode 5.34 does indeed leave wrong fontifications as you have noted below. I'd forgotten a particular patch I'd made since 5.34 which has a bearing on these fontifications. This was changeset: 6660:19eb4ddc766b tag: 2019-09-16-dix-m user: Alan Mackenzie date: Sat Sep 21 12:11:27 2019 +0000 files: cc-engine.el tests/statement-29.cc tests/statement-29.face description: CC Mode: Fix wrong fontification of FOO in ASSERT (FOO && !BAR) from the CC Mode Mercurial repository at SourceForge. Could I ask you, please, to apply this patch to your copy of CC Mode 5.34: diff -r a5dbcca7730b -r 19eb4ddc766b cc-engine.el --- a/cc-engine.el Sat Sep 21 12:09:54 2019 +0000 +++ b/cc-engine.el Sat Sep 21 12:11:27 2019 +0000 @@ -10109,7 +10109,8 @@ (throw 'at-decl-or-cast t))))) ;; CASE 18 - (when (and (not (memq context '(nil top))) + (when (and at-decl-end + (not (memq context '(nil top))) (or (and got-prefix (not got-number)) (and (eq context 'decl) (not c-recognize-paren-inits) On Wed, Feb 05, 2020 at 23:57:13 +0000, Benjamin Moody wrote: > Hi, > Thank you for all your work on CC Mode. And yeah, I know C syntax can > get pretty hairy. :) > The curious thing is, though, this issue doesn't seem to occur with > "foo * bar(baz)". What I'm seeing seems to happen specifically when > the "function" is actually a keyword (like sizeof), and the expression > is enclosed in parentheses: With the above patch in place and cc-engine.el recompiled, the fontification of your test file from yesterday seems to be correct. In particular: > void foo() > { > xxx(xxx * xxx(xxx)); /* correct */ > xxx(ttt * sizeof(xxx)); /* wrong */ > xxx(xxx, xxx * xxx(xxx)); /* correct */ > xxx(xxx, ttt * sizeof(xxx)); /* wrong */ These two "wrong" lines are now fontified correctly. > ttt * fff(xxx); /* ambiguous, but logical */ Indeed. Being at the "top level", this can only be a declaration. If you put "foo = " in front of that line, turning it into a statement, the fontifications on ttt and fff disappear. > xxx * sizeof(xxx); /* correct */ > (xxx * xxx(xxx)); /* correct */ > (ttt * sizeof(xxx)); /* wrong */ This one is now correct. > xxx = xxx * xxx(xxx); /* correct */ > xxx = xxx * sizeof(xxx); /* correct */ > xxx = (ttt * fff(xxx)); /* wrong (I think) */ > xxx = (xxx * sizeof(xxx)); /* correct */ Here ttt gets type face because a previous ttt has been recognised as a type and entered into CC Mode's "found types" mechanism. If you change this ttt into tttt, the wrong fontification disappears, since tttt is not registered as a "found type". > } > (In these examples, 'xxx' uses the default face, 'ttt' uses > font-lock-type-face, 'fff' uses font-lock-function-name-face, and of > course 'sizeof' uses font-lock-keyword-face.) > I tried the standalone version (cc-mode-5.34.tar.gz) and it appears to > give the same results as above. Yes. Sorry once again for not being more careful in my first reply. > Benjamin -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 07 12:47:42 2020 Received: (at 39409) by debbugs.gnu.org; 7 Feb 2020 17:47:42 +0000 Received: from localhost ([127.0.0.1]:50217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j07jB-00022l-QU for submit@debbugs.gnu.org; Fri, 07 Feb 2020 12:47:41 -0500 Received: from mail-io1-f51.google.com ([209.85.166.51]:45111) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j07jA-00022X-HD for 39409@debbugs.gnu.org; Fri, 07 Feb 2020 12:47:40 -0500 Received: by mail-io1-f51.google.com with SMTP id i11so379279ioi.12 for <39409@debbugs.gnu.org>; Fri, 07 Feb 2020 09:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tLQqYHp7jSLnKB1cOuYnuDoan6l4Of6yRnplQjZUnUw=; b=lv5EcWORE7APlV+PyBKMhxRxXacKBtEEGPVemmYqFfcbBtdw3sneOqcEMUi0QsQG8T UxQCpLTGx9WibhLGB9awWuYh2AcwWVepWms1dhraoEkIyhiy84yvEaL2qW34yIXTfCJY BhcDaKrQHauXHVofN33grN1qVeb29z02wba8GFiFn/BOOh+WMa2DDo+ql0MCRJT98nYP WAs94c4/aTRBvWF40J7RdkL4ZZzOUrLSl4NFJUlk0xE60bpPSRhtagpTzsoCfT75v1ur OLXrJSz6v8rIyqw5UbyUeLfBClKTZ1a4AiK940jxOMnMT/cTf5CcH7+y9esGxQiMJSzM eubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tLQqYHp7jSLnKB1cOuYnuDoan6l4Of6yRnplQjZUnUw=; b=XVhr6gYW7hni/rcp+B/6yUECjV/YpF+jNN9IDZFs19WIGnSzGkNZnV4fCLO3D0sZZa apINb8XK+jJ0e1dI9bZcA41JhB6MmtaFoubWC3/U+y2Z1Jd/W3SqUxdmzGAUJJS+ITRc ELjdipD3BTS5PNNQinGct9a0eqNDeHFL+AJWJhpym2QKq6FzXEpPXdekvgJUpOL5r9Dp ARJGOn7Wb2OKenekeCl4JRM1Wfi5YlX+0pcwu/+O6w0upQ08o+HlmBPLzCLj41a5U4DQ I6e61XLghdfC/m7zq1PJ5gWct/7NGFSJPadpX/dlz7VL+jAGG4HEL/klKLRD/7UOQYMK Rc6g== X-Gm-Message-State: APjAAAX06eh7NcOcYib4o7/Bk8hwiXZQ2gxwaRUTgs8DYQCCOHBFbHN3 HtVIwW8FkvpYD8TP6kP0V1sabVeYnFUzUtDGHqkVj27m X-Google-Smtp-Source: APXvYqxdyjElz4P/Ts+7Ee7VGnKY/xlCjv11NajQqoU46XH+Mm7igkJ7xLEJwl11qKrQgRl0D7qO7dSh2F1srEycFsc= X-Received: by 2002:a5d:9255:: with SMTP id e21mr456833iol.260.1581097654628; Fri, 07 Feb 2020 09:47:34 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:1dc2:0:0:0:0:0 with HTTP; Fri, 7 Feb 2020 09:47:33 -0800 (PST) In-Reply-To: <20200206202141.GA4293@ACM> References: <87r1zbnukh.fsf@pc57.ecg.mit.edu> <20200205205727.GA7507@ACM> <20200206202141.GA4293@ACM> From: Benjamin Moody Date: Fri, 7 Feb 2020 17:47:33 +0000 Message-ID: Subject: Re: bug#39409: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39409 Cc: 39409@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, > diff -r a5dbcca7730b -r 19eb4ddc766b cc-engine.el > --- a/cc-engine.el Sat Sep 21 12:09:54 2019 +0000 > +++ b/cc-engine.el Sat Sep 21 12:11:27 2019 +0000 > @@ -10109,7 +10109,8 @@ > (throw 'at-decl-or-cast t))))) > > ;; CASE 18 > - (when (and (not (memq context '(nil top))) > + (when (and at-decl-end > + (not (memq context '(nil top))) > (or (and got-prefix (not got-number)) > (and (eq context 'decl) > (not c-recognize-paren-inits) Yes, this patch fixes the issue. Thanks once again! Benjamin From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 07 15:01:11 2020 Received: (at 39409) by debbugs.gnu.org; 7 Feb 2020 20:01:11 +0000 Received: from localhost ([127.0.0.1]:50274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j09oM-0005Bc-Q8 for submit@debbugs.gnu.org; Fri, 07 Feb 2020 15:01:11 -0500 Received: from colin.muc.de ([193.149.48.1]:55631 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1j09oK-0005BM-0L for 39409@debbugs.gnu.org; Fri, 07 Feb 2020 15:01:09 -0500 Received: (qmail 44102 invoked by uid 3782); 7 Feb 2020 20:01:07 -0000 Received: from acm.muc.de (p4FE15DC2.dip0.t-ipconnect.de [79.225.93.194]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 07 Feb 2020 21:01:03 +0100 Received: (qmail 8669 invoked by uid 1000); 7 Feb 2020 20:01:03 -0000 Date: Fri, 7 Feb 2020 20:01:03 +0000 To: Benjamin Moody Subject: Re: bug#39409: CC Mode 5.33.1 (C/*l); Wrong fontification of "foo * sizeof" Message-ID: <20200207200103.GA8591@ACM> References: <87r1zbnukh.fsf@pc57.ecg.mit.edu> <20200205205727.GA7507@ACM> <20200206202141.GA4293@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39409 Cc: 39409@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 39409 27.0.60 quit Hello again, Benjamin. On Fri, Feb 07, 2020 at 17:47:33 +0000, Benjamin Moody wrote: > Hi, > > diff -r a5dbcca7730b -r 19eb4ddc766b cc-engine.el > > --- a/cc-engine.el Sat Sep 21 12:09:54 2019 +0000 > > +++ b/cc-engine.el Sat Sep 21 12:11:27 2019 +0000 > > @@ -10109,7 +10109,8 @@ > > (throw 'at-decl-or-cast t))))) > > ;; CASE 18 > > - (when (and (not (memq context '(nil top))) > > + (when (and at-decl-end > > + (not (memq context '(nil top))) > > (or (and got-prefix (not got-number)) > > (and (eq context 'decl) > > (not c-recognize-paren-inits) > Yes, this patch fixes the issue. Thanks once again! Thank you for the test. The patch in question is already in the emacs-27 branch, so I think we can regard the bug as fixed. I'm closing it with this post. > Benjamin -- Alan Mackenzie (Nuremberg, Germany). From unknown Thu Aug 14 21:55:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 07 Mar 2020 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator