GNU bug report logs - #63323
c-ts-mode does not know about `restrict'

Previous Next

Package: emacs;

Reported by: Po Lu <luangruo <at> yahoo.com>

Date: Sat, 6 May 2023 08:20:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Po Lu <luangruo <at> yahoo.com>
Subject: bug#63323: closed (Re: bug#63323: c-ts-mode does not know about
 `restrict')
Date: Sun, 07 May 2023 05:14:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#63323: c-ts-mode does not know about `restrict'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 63323 <at> debbugs.gnu.org.

-- 
63323: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63323
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63323-done <at> debbugs.gnu.org
Subject: Re: bug#63323: c-ts-mode does not know about `restrict'
Date: Sun, 07 May 2023 08:14:25 +0300
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sat, 6 May 2023 15:54:32 -0700
> Cc: luangruo <at> yahoo.com,
>  63323 <at> debbugs.gnu.org
> 
> 
> 
> > Actually, it looks like we recognize the type qualifiers in C as
> > keywords, via a separate list.  So I've just added to that list the
> > two missing qualifiers: 'restrict' and '_Atomic', and that fixes this
> > bug for me.
> > 
> > Yuan, is that the right fix?  I've installed it on the emacs-29
> > branch.
> 
> I check tree-sitter-c’s grammar and it defines type_qualifier [1], so if you move (type_qualifier) @font-lock-type-face out of the check for cpp, if would work. Recognizing them as keywords also works. So both are technically correct. C-mode uses keyword face, so I think your fix is a-ok.
> 
> [1] you probably know this, but for completeness:
> 
>     type_qualifier: $ => choice(
>       'const',
>       'volatile',
>       'restrict',
>       '_Atomic'
>     ),

Right, they just copied from the C Standard.

Whether we want to stay with qualifiers in keywords or not depends on
whether we thing type qualifiers could or should be fontified
differently from keywords.  (What do other IDEs do with C type
qualifiers?)  Something to think for the future, I guess.

For now, I'm closing this bug.

[Message part 3 (message/rfc822, inline)]
From: Po Lu <luangruo <at> yahoo.com>
To: bug-gnu-emacs <at> gnu.org
Subject: c-ts-mode does not know about `restrict'
Date: Sat, 06 May 2023 16:19:32 +0800
Standard C accepts a keyword `restrict', which is used to declare
pointers whose referenced object must only be accessed by lvalues based
upon one such pointer within the block where they are declared.

Like so:

  argb *restrict src, *restrict dest;

c-ts-mode does not understand this keyword.  It is not fontified within
such declarations.



This bug report was last modified 2 years and 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.