all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Juri Linkov <juri@linkov.net>
Cc: 36492@debbugs.gnu.org
Subject: bug#36492: c-mode fails with errors during fontification
Date: 6 Jul 2019 14:27:48 -0000	[thread overview]
Message-ID: <20190706142748.85417.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.154.1562272763.2688.bug-gnu-emacs@gnu.org>

In article <mailman.154.1562272763.2688.bug-gnu-emacs@gnu.org> you wrote:
> [-- text/plain, encoding 7bit, charset: US-ASCII, 6 lines --]

>> Opening this message in Gnus fails with the following backtrace
>> because c-mode fails to fontify the attachment.

> Actually, with the attachment in this message the bug in c-mode
> font-lock is much easier to reproduce.

That is one ugly piece of erroneous C.  ;-)

What triggers the bug is the ) without a preceding (.  A variable
recording the position of the opening ( is still set to nil, and we
tried to use it in the given buffer with the unbalanced ).

> [-- text/x-csrc, encoding 7bit, charset: US-ASCII, 3 lines, name: test.c --]

The following patch fixes it, I hope.  Would you please do the usual,
and confirm that it does indeed fix the bug (or tell me what's still
wrong).

Thanks!


diff -r eb4ee9bb0682 cc-engine.el
--- a/cc-engine.el	Thu Jul 04 13:01:08 2019 +0000
+++ b/cc-engine.el	Sat Jul 06 14:16:43 2019 +0000
@@ -9480,6 +9480,7 @@
 			   (not got-prefix)
 			   (or (eq context 'top) make-top)
 			   (eq (char-after) ?\))
+			   after-paren-pos
 			   (or (memq at-type '(nil maybe))
 			       (not got-identifier)
 			       (save-excursion
@@ -9516,7 +9517,7 @@
 	    ;; (con|de)structors in C++ and `c-typeless-decl-kwds'
 	    ;; style declarations.  That isn't applicable in an
 	    ;; arglist context, though.
-	    (when (and (> paren-depth 0)
+	    (when (and (> paren-depth 0) ; ensures `after-paren-pos' is non-nil
 		       (not got-prefix-before-parens)
 		       (not (eq at-type t))
 		       (or backup-at-type


-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2019-07-06 14:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 20:56 bug#36492: c-mode fails with errors during fontification Juri Linkov
2019-07-04 20:08 ` Juri Linkov
     [not found] ` <mailman.154.1562272763.2688.bug-gnu-emacs@gnu.org>
2019-07-04 21:19   ` Alan Mackenzie
2019-07-06 14:27   ` Alan Mackenzie [this message]
2019-07-07 21:52     ` Juri Linkov
2019-07-08 12:53       ` Alan Mackenzie
2019-07-08 13:16         ` Noam Postavsky
2019-07-08 21:46           ` Juri Linkov
2019-07-08 21:58             ` Noam Postavsky
2019-07-08 13:47         ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190706142748.85417.qmail@mail.muc.de \
    --to=acm@muc.de \
    --cc=36492@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.