[vim/vim] Do not highlight `noreturn` in C++ code (PR #19170)

5 views
Skip to first unread message

Wu Yongwei

unread,
6:02 AM (16 hours ago) 6:02 AM
to vim/vim, Subscribed

noreturn is now highlighted as keyword in C++ code. It should not.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19170

Commit Summary

  • b5349d8 Do not highlight `noreturn` in C++ code

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170@github.com>

dkearns

unread,
6:50 AM (16 hours ago) 6:50 AM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#19170)

Are you noticing this because it's highlighting the attribute?

Most of those other C11 keywords aren't C++ either.

I think it would be a good idea to use a dedicated C++ syntax file that doesn't source the C file. A little duplication would be much easier to handle.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3743899690@github.com>

Wu Yongwei

unread,
9:26 AM (13 hours ago) 9:26 AM
to vim/vim, Subscribed
adah1972 left a comment (vim/vim#19170)

Are you noticing this because it's highlighting the attribute?

Yes.

Most of those other C11 keywords aren't C++ either.

Identifiers like _Noreturn and _Generic do not matter, as they are reserved. Only noreturn causes apparent problems—it is a valid identifier for user use.

Also notice that C23 is going towards the C++ direction: [[noreturn]] is recommended.

I think it would be a good idea to use a dedicated C++ syntax file that doesn't source the C file. A little duplication would be much easier to handle.

Since C and C++ standards are trying to align, and more common stuff will likely come to both languages, I think reusing the C syntax file in C++ is still OK.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3744633686@github.com>

dkearns

unread,
12:13 PM (10 hours ago) 12:13 PM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#19170)

I was going to add generic attribute highlighting but I probably won't get to it before the release.

Presumably the stdatomic.h types shouldn't be matched in C++?

Could you please add a couple of simple syntax tests to check that noreturn is highlighted for C and not highlighted for C++?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3745479127@github.com>

Christian Brabandt

unread,
3:20 PM (7 hours ago) 3:20 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19170)

I second the suggestion to add syntax tests. Have a look at this recent commit, where I added a syntext test for cpp numbers 335aecd


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3746402616@github.com>

Wu Yongwei

unread,
9:28 PM (1 hour ago) 9:28 PM
to vim/vim, Subscribed
adah1972 left a comment (vim/vim#19170)

I am still learning how to add syntax tests.

In the meantime, noreturn is a macro from #include <stdnoreturn.h>. So maybe it should never have been highlighted, even in C? In that case, simply removing it from c.vim is the simplest way.

Though we do have examples of highlighting stuff from includes, noreturn is not commonly used (AFAIK), and its use is deprecated anyway (in favour of [[noreturn]] in C23).


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3747403328@github.com>

Wu Yongwei

unread,
10:11 PM (17 minutes ago) 10:11 PM
to vim/vim, Subscribed
adah1972 left a comment (vim/vim#19170)

I know how to add tests now.

Let me know which direction to go:

  1. Just remove noreturn from c.vim (I'll change this PR).
  2. Keep it as is, and add c_noreturn and cpp_noreturn tests (I'll amend this PR).
  3. Other suggestions?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19170/c3747484241@github.com>

Reply all
Reply to author
Forward
0 new messages