]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(c): classify type qualifiers, function specifiers and C23 attributes
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Mon, 1 Jun 2026 21:04:08 +0000 (21:04 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 1 Jun 2026 21:04:08 +0000 (21:04 +0000)
Move const, volatile, restrict and _Atomic to a new cTypeQualifier group
and inline and _Noreturn to cFunctionSpec. Add the C23 standard attributes
deprecated, fallthrough, maybe_unused, nodiscard, unsequenced and
reproducible as cStandardAttribute, and reclassify the existing noreturn
into the same group.

The new groups link to cStorageClass, so the default highlighting and any
existing cStorageClass override are unchanged, while allowing finer-grained
customization.

fixes:  #19574
closes: #20368

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/c.vim

index 64bcd3e36878d85777e347a6dd5bce441b165059..68381095204ecc618d1f4005917432ea805156fe 100644 (file)
@@ -1,7 +1,7 @@
 " Vim syntax file
 " Language:            C
 " Maintainer:          The Vim Project <https://github.com/vim/vim>
-" Last Change:         2026 Jan 13
+" Last Change:         2026 Jun 01
 " Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 " Quit when a (custom) syntax file was already loaded
@@ -278,9 +278,9 @@ if exists("c_gnu")
   syn keyword  cOperator       __alignof__
   syn keyword  cOperator       typeof __typeof__
   syn keyword  cOperator       __real__ __imag__
-  syn keyword  cStorageClass   __attribute__ __const__ __extension__
-  syn keyword  cStorageClass   inline __inline __inline__
-  syn keyword  cStorageClass   __restrict__ __volatile__ __noreturn__
+  syn keyword  cStorageClass   __attribute__ __extension__
+  syn keyword  cTypeQualifier  __const__ __restrict__ __volatile__
+  syn keyword  cFunctionSpec   inline __inline __inline__ __noreturn__
 endif
 syn keyword    cType           int long short char void
 syn keyword    cType           signed unsigned float double
@@ -314,9 +314,11 @@ endif
 
 syn keyword    cTypedef        typedef
 syn keyword    cStructure      struct union enum
-syn keyword    cStorageClass   static register auto volatile extern const
+syn keyword    cStorageClass   static register auto extern
+syn keyword    cTypeQualifier  const volatile
 if !exists("c_no_c99") && !s:in_cpp_family
-  syn keyword  cStorageClass   inline restrict
+  syn keyword  cFunctionSpec   inline
+  syn keyword  cTypeQualifier  restrict
 endif
 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))
   syn keyword  cStorageClass   constexpr
@@ -324,11 +326,11 @@ endif
 if !exists("c_no_c11")
   syn keyword  cStorageClass   _Alignas alignas
   syn keyword  cOperator       _Alignof alignof
-  syn keyword  cStorageClass   _Atomic
+  syn keyword  cTypeQualifier  _Atomic
   syn keyword  cOperator       _Generic
-  syn keyword  cStorageClass   _Noreturn
+  syn keyword  cFunctionSpec   _Noreturn
   if !s:in_cpp_family
-    syn keyword        cStorageClass   noreturn
+    syn keyword        cStandardAttribute      noreturn
   endif
   syn keyword  cOperator       _Static_assert static_assert
   syn keyword  cStorageClass   _Thread_local thread_local
@@ -352,6 +354,11 @@ if !exists("c_no_c11")
   syn keyword  cType           atomic_intmax_t atomic_uintmax_t
 endif
 
+if !exists("c_no_c23") && !s:in_cpp_family
+  syn keyword  cStandardAttribute      deprecated fallthrough maybe_unused nodiscard
+  syn keyword  cStandardAttribute      unsequenced reproducible
+endif
+
 if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20"))
   syn keyword   cType          char8_t
 endif
@@ -606,6 +613,9 @@ hi def link cOperator               Operator
 hi def link cStructure         Structure
 hi def link cTypedef           Structure
 hi def link cStorageClass      StorageClass
+hi def link cTypeQualifier     cStorageClass
+hi def link cFunctionSpec      cStorageClass
+hi def link cStandardAttribute cStorageClass
 hi def link cInclude           Include
 hi def link cPreProc           PreProc
 hi def link cDefine            Macro