GNU bug report logs -
#63323
c-ts-mode does not know about `restrict'
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63323 in the body.
You can then email your comments to 63323 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63323
; Package
emacs
.
(Sat, 06 May 2023 08:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Po Lu <luangruo <at> yahoo.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 06 May 2023 08:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63323
; Package
emacs
.
(Sat, 06 May 2023 10:31:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 63323 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 06 May 2023 16:19:32 +0800
> From: Po Lu via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> 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.
It looks like c-ts-mode thinks type qualifiers are possible only in
C++?
:feature 'type
`((primitive_type) @font-lock-type-face
(type_identifier) @font-lock-type-face
(sized_type_specifier) @font-lock-type-face
,@(when (eq mode 'cpp) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'((type_qualifier) @font-lock-type-face
(qualified_identifier
scope: (namespace_identifier) @font-lock-type-face)
(operator_cast) type: (type_identifier) @font-lock-type-face))
[,@c-ts-mode--type-keywords] @font-lock-type-face)
The tree-sitter library returns a type_qualifier node for 'restrict':
(parameter_declaration type: (type_identifier)
declarator:
(pointer_declarator *
(type_qualifier restrict)
declarator: (identifier)))
Yuan, can you look into fixing this, please?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63323
; Package
emacs
.
(Sat, 06 May 2023 12:19:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 63323 <at> debbugs.gnu.org (full text, mbox):
> Cc: 63323 <at> debbugs.gnu.org
> Date: Sat, 06 May 2023 13:31:03 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> It looks like c-ts-mode thinks type qualifiers are possible only in
> C++?
>
> :feature 'type
> `((primitive_type) @font-lock-type-face
> (type_identifier) @font-lock-type-face
> (sized_type_specifier) @font-lock-type-face
> ,@(when (eq mode 'cpp) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> '((type_qualifier) @font-lock-type-face
>
> (qualified_identifier
> scope: (namespace_identifier) @font-lock-type-face)
>
> (operator_cast) type: (type_identifier) @font-lock-type-face))
> [,@c-ts-mode--type-keywords] @font-lock-type-face)
>
> The tree-sitter library returns a type_qualifier node for 'restrict':
>
> (parameter_declaration type: (type_identifier)
> declarator:
> (pointer_declarator *
> (type_qualifier restrict)
> declarator: (identifier)))
>
> Yuan, can you look into fixing this, please?
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#63323
; Package
emacs
.
(Sat, 06 May 2023 22:55:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 63323 <at> debbugs.gnu.org (full text, mbox):
> On May 6, 2023, at 5:19 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> Cc: 63323 <at> debbugs.gnu.org
>> Date: Sat, 06 May 2023 13:31:03 +0300
>> From: Eli Zaretskii <eliz <at> gnu.org>
>>
>> It looks like c-ts-mode thinks type qualifiers are possible only in
>> C++?
>>
>> :feature 'type
>> `((primitive_type) @font-lock-type-face
>> (type_identifier) @font-lock-type-face
>> (sized_type_specifier) @font-lock-type-face
>> ,@(when (eq mode 'cpp) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> '((type_qualifier) @font-lock-type-face
>>
>> (qualified_identifier
>> scope: (namespace_identifier) @font-lock-type-face)
>>
>> (operator_cast) type: (type_identifier) @font-lock-type-face))
>> [,@c-ts-mode--type-keywords] @font-lock-type-face)
>>
>> The tree-sitter library returns a type_qualifier node for 'restrict':
>>
>> (parameter_declaration type: (type_identifier)
>> declarator:
>> (pointer_declarator *
>> (type_qualifier restrict)
>> declarator: (identifier)))
>>
>> Yuan, can you look into fixing this, please?
>
> 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'
),
Yuan
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sun, 07 May 2023 05:14:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Po Lu <luangruo <at> yahoo.com>
:
bug acknowledged by developer.
(Sun, 07 May 2023 05:14:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 63323-done <at> debbugs.gnu.org (full text, mbox):
> 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.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 04 Jun 2023 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 342 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.