Skip to content

Commit 6063031

Browse files
authored
[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
1 parent 0a62836 commit 6063031

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ C Language Changes
249249
- The ``[[clang::assume()]]`` attribute is now correctly recognized in C. The
250250
``__attribute__((assume()))`` form has always been supported, so the fix is
251251
specific to the attribute syntax used.
252+
- The ``clang-cl`` driver now recognizes ``/std:clatest`` and sets the language
253+
mode to C23. (#GH147233)
252254

253255
C2y Feature Support
254256
^^^^^^^^^^^^^^^^^^^

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7212,6 +7212,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
72127212
LanguageStandard = llvm::StringSwitch<StringRef>(StdArg->getValue())
72137213
.Case("c11", "-std=c11")
72147214
.Case("c17", "-std=c17")
7215+
// TODO: add c23 when MSVC supports it.
7216+
.Case("clatest", "-std=c23")
72157217
.Default("");
72167218
if (LanguageStandard.empty())
72177219
D.Diag(clang::diag::warn_drv_unused_argument)

clang/test/Driver/cl-options.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@
362362
// RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix CHECK-C11 %s
363363
// CHECK-C11: -std=c11
364364

365+
// RUN: %clang_cl -c -### /std:c17 -- %s 2>&1 | FileCheck -check-prefix CHECK-C17 %s
366+
// CHECK-C17: -std=c17
367+
368+
// RUN: %clang_cl -c -### /std:clatest -- %s 2>&1 | FileCheck -check-prefix CHECK-CLATEST %s
369+
// CHECK-CLATEST: -std=c23
370+
365371
// For some warning ids, we can map from MSVC warning to Clang warning.
366372
// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
367373
// Wno: "-cc1"

0 commit comments

Comments
 (0)