Skip to content

[clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above #117149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ C Language Changes
------------------

- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
- Macro ``__STDC_NO_THREADS__`` is no longer necessary for MSVC 2022 1939 and later.

C2y Feature Support
^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class LangOptionsBase {
MSVC2019_5 = 1925,
MSVC2019_8 = 1928,
MSVC2022_3 = 1933,
MSVC2022_9 = 1939,
};

enum SYCLMajorVersion {
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Basic/Targets/OSTargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
Builder.defineMacro("_KERNEL_MODE");

Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
Builder.defineMacro("__STDC_NO_THREADS__");

// Define __STDC_NO_THREADS__ based on MSVC version, threads.h availability,
// and language standard.
if (!(Opts.isCompatibleWithMSVC(LangOptions::MSVC2022_9) && Opts.C11))
Builder.defineMacro("__STDC_NO_THREADS__");
// Starting with VS 2022 17.1, MSVC predefines the below macro to inform
// users of the execution character set defined at compile time.
// The value given is the Windows Code Page Identifier:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c89 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C89_MSVC33 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c99 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C99_MSVC33 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC33 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c89 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C89_MSVC39 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c99 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C99_MSVC39 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC39 %s
// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.40 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC40 %s

// C89_MSVC33: #define __STDC_NO_THREADS__ 1
// C99_MSVC33: #define __STDC_NO_THREADS__ 1
// C11_MSVC33: #define __STDC_NO_THREADS__ 1
// C89_MSVC39: #define __STDC_NO_THREADS__ 1
// C99_MSVC39: #define __STDC_NO_THREADS__ 1
// C11_MSVC39-NOT: #define __STDC_NO_THREADS__
// C11_MSVC40-NOT: #define __STDC_NO_THREADS__
2 changes: 1 addition & 1 deletion clang/test/Preprocessor/init-aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@
// AARCH64-MSVC: #define __WINT_WIDTH__ 16
// AARCH64-MSVC: #define __aarch64__ 1

// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm64ec-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix ARM64EC-MSVC %s
// RUN: %clang_cc1 -E -dM -fms-compatibility-version=19.33 -ffreestanding -triple=arm64ec-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix ARM64EC-MSVC %s

// ARM64EC-MSVC: #define _INTEGRAL_MAX_BITS 64
// ARM64EC-MSVC: #define _M_AMD64 100
Expand Down
Loading