[clang] 6063031 - [clang-cl] Support /std:clatest (#147284)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 7 06:15:27 PDT 2025
Author: Aaron Ballman
Date: 2025-07-07T09:15:23-04:00
New Revision: 60630310e9a4033f9085b3874147824d8676b8a7
URL: https://github.com/llvm/llvm-project/commit/60630310e9a4033f9085b3874147824d8676b8a7
DIFF: https://github.com/llvm/llvm-project/commit/60630310e9a4033f9085b3874147824d8676b8a7.diff
LOG: [clang-cl] Support /std:clatest (#147284)
cl.exe has /std:clatest, analogous to /std:c++latest, which sets the
language mode to the latest standard. For C, that's C23. This adds
support for the option.
Fixes #147233
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-options.c
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a6be59f1d6bd7..fddfc36d302b5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -249,6 +249,8 @@ C Language Changes
- The ``[[clang::assume()]]`` attribute is now correctly recognized in C. The
``__attribute__((assume()))`` form has always been supported, so the fix is
specific to the attribute syntax used.
+- The ``clang-cl`` driver now recognizes ``/std:clatest`` and sets the language
+ mode to C23. (#GH147233)
C2y Feature Support
^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 71d4f0af47179..7b8120da558f2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7212,6 +7212,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
LanguageStandard = llvm::StringSwitch<StringRef>(StdArg->getValue())
.Case("c11", "-std=c11")
.Case("c17", "-std=c17")
+ // TODO: add c23 when MSVC supports it.
+ .Case("clatest", "-std=c23")
.Default("");
if (LanguageStandard.empty())
D.Diag(clang::diag::warn_drv_unused_argument)
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index eb079895a0a88..57e16e8795a28 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -362,6 +362,12 @@
// RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix CHECK-C11 %s
// CHECK-C11: -std=c11
+// RUN: %clang_cl -c -### /std:c17 -- %s 2>&1 | FileCheck -check-prefix CHECK-C17 %s
+// CHECK-C17: -std=c17
+
+// RUN: %clang_cl -c -### /std:clatest -- %s 2>&1 | FileCheck -check-prefix CHECK-CLATEST %s
+// CHECK-CLATEST: -std=c23
+
// For some warning ids, we can map from MSVC warning to Clang warning.
// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
// Wno: "-cc1"
More information about the cfe-commits
mailing list