runtime(c): Do not highlight noreturn in C++ code

Commit: 
https://github.com/vim/vim/commit/5529b750a7ce6dcafaecb119d674b99275dbe3c7
Author: Wu Yongwei <[email protected]>
Date:   Thu Jan 15 20:37:14 2026 +0000

    runtime(c): Do not highlight noreturn in C++ code
    
    closes: https://github.com/vim/vim/issues/19170
    
    Signed-off-by: Wu Yongwei <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim
index d2f2b85b4..64bcd3e36 100644
--- a/runtime/syntax/c.vim
+++ b/runtime/syntax/c.vim
@@ -1,7 +1,7 @@
 " Vim syntax file
 " Language:            C
 " Maintainer:          The Vim Project <https://github.com/vim/vim>
-" Last Change:         2025 Nov 18
+" Last Change:         2026 Jan 13
 " Former Maintainer:   Bram Moolenaar <[email protected]>
 
 " Quit when a (custom) syntax file was already loaded
@@ -326,7 +326,10 @@ if !exists("c_no_c11")
   syn keyword  cOperator       _Alignof alignof
   syn keyword  cStorageClass   _Atomic
   syn keyword  cOperator       _Generic
-  syn keyword  cStorageClass   _Noreturn noreturn
+  syn keyword  cStorageClass   _Noreturn
+  if !s:in_cpp_family
+    syn keyword        cStorageClass   noreturn
+  endif
   syn keyword  cOperator       _Static_assert static_assert
   syn keyword  cStorageClass   _Thread_local thread_local
   syn keyword   cType          char16_t char32_t
diff --git a/runtime/syntax/testdir/dumps/c_noreturn_00.dump 
b/runtime/syntax/testdir/dumps/c_noreturn_00.dump
new file mode 100644
index 000000000..7bb73809b
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/c_noreturn_00.dump
@@ -0,0 +1,20 @@
+>#+0#e000e06#ffffff0|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|i|o|.|h|>| 
+0#0000000&@56
+|#+0#e000e06&|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|l|i|b|.|h|>| +0#0000000&@55
+|#+0#e000e06&|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|n|o|r|e|t|u|r|n|.|h|>| 
+0#0000000&@50
+@75
+|/+0#0000e05&@1| |c|a|u|s|e|s| |u|n|d|e|f|i|n|e|d| |b|e|h|a|v|i|o|r| |i|f| |i| 
|<|=| |0| +0#0000000&@36
+|/+0#0000e05&@1| |e|x|i|t|s| |i|f| |i| |>| |0| +0#0000000&@57
+|n+0#00e0003&|o|r|e|t|u|r|n| +0#0000000&|v+0#00e0003&|o|i|d| 
+0#0000000&|e|x|i|t|_|n|o|w|(|i+0#00e0003&|n|t| +0#0000000&|i|)| 
|/+0#0000e05&@1| |o|r| |_|N|o|r|e|t|u|r|n| |v|o|i|d| |e|x|i|t|_|n|o|w|(|i|n|t| 
|i|)| +0#0000000&@8
+|{| @73
+@4|i+0#af5f00255&|f| +0#0000000&|(|i| |>| |0+0#e000002&|)+0#0000000&| @60
+@8|e|x|i|t|(|i|)|;| @58
+|}| @73
+@75
+|i+0#00e0003&|n|t| +0#0000000&|m|a|i|n|(|v+0#00e0003&|o|i|d|)+0#0000000&| @60
+|{| @73
+@4|p|u|t|s|(|"+0#e000002&|P|r|e|p|a|r|i|n|g| |t|o| 
|e|x|i|t|.@2|"|)+0#0000000&|;| @41
+@4|e|x|i|t|_|n|o|w|(|2+0#e000002&|)+0#0000000&|;| @58
+@4|p|u|t|s|(|"+0#e000002&|T|h|i|s| |c|o|d|e| |i|s| |n|e|v|e|r| 
|e|x|e|c|u|t|e|d|.|"|)+0#0000000&|;| @33
+|}| @73
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/cpp_noreturn_00.dump 
b/runtime/syntax/testdir/dumps/cpp_noreturn_00.dump
new file mode 100644
index 000000000..e2cfd2589
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/cpp_noreturn_00.dump
@@ -0,0 +1,20 @@
+>#+0#e000e06#ffffff0|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|i|o|.|h|>| 
+0#0000000&@56
+|#+0#e000e06&|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|l|i|b|.|h|>| +0#0000000&@55
+@75
+|[@1|n|o|r|e|t|u|r|n|]@1| |v+0#00e0003&|o|i|d| 
+0#0000000&|e|r@1|o|r|_|e|x|i|t|(|c+0#00e0003&|o|n|s|t| 
+0#0000000&|c+0#00e0003&|h|a|r|*+0#0000000&| |r|e|a|s|o|n|)| @26
+|{| @73
+@4|p|r|i|n|t|f|(|"+0#e000002&|E|r@1|o|r|:| 
|%+0#e000e06&|s|\|n|"+0#e000002&|,+0#0000000&| |r|e|a|s|o|n|)|;| @40
+@4|e|x|i|t|(|1+0#e000002&|)+0#0000000&|;| @62
+|}| @73
+@75
+|i+0#00e0003&|n|t| +0#0000000&|m|a|i|n|(|v+0#00e0003&|o|i|d|)+0#0000000&| @60
+|{| @73
+@4|p|u|t|s|(|"+0#e000002&|P|r|e|p|a|r|i|n|g| |t|o| 
|e|x|i|t|.@2|"|)+0#0000000&|;| @41
+@4|e|r@1|o|r|_|e|x|i|t|(|"+0#e000002&|A|s@1|u|m|e| |s|o|m|e|t|h|i|n|g| |i|s| 
|w|r|o|n|g|"|)+0#0000000&|;| @30
+@4|p|u|t|s|(|"+0#e000002&|T|h|i|s| |c|o|d|e| |i|s| |n|e|v|e|r| 
|e|x|e|c|u|t|e|d|.|"|)+0#0000000&|;| @33
+|}| @73
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/input/c_noreturn.c 
b/runtime/syntax/testdir/input/c_noreturn.c
new file mode 100644
index 000000000..a2413c866
--- /dev/null
+++ b/runtime/syntax/testdir/input/c_noreturn.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdnoreturn.h>
+
+// causes undefined behavior if i <= 0
+// exits if i > 0
+noreturn void exit_now(int i) // or _Noreturn void exit_now(int i)
+{
+    if (i > 0)
+        exit(i);
+}
+
+int main(void)
+{
+    puts("Preparing to exit...");
+    exit_now(2);
+    puts("This code is never executed.");
+}
diff --git a/runtime/syntax/testdir/input/cpp_noreturn.cpp 
b/runtime/syntax/testdir/input/cpp_noreturn.cpp
new file mode 100644
index 000000000..c2b729f59
--- /dev/null
+++ b/runtime/syntax/testdir/input/cpp_noreturn.cpp
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+[[noreturn]] void error_exit(const char* reason)
+{
+    printf("Error: %s
", reason);
+    exit(1);
+}
+
+int main(void)
+{
+    puts("Preparing to exit...");
+    error_exit("Assume something is wrong");
+    puts("This code is never executed.");
+}

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vgUDI-00Ej5f-Dy%40256bit.org.

Raspunde prin e-mail lui