[clang] d8cd780 - [clang] OpenBSD does not support C11 atomics or threads.
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 3 18:14:09 PDT 2021
Author: Brad Smith
Date: 2021-09-03T21:13:55-04:00
New Revision: d8cd7806310c51af912a647a6ca46de62ff13214
URL: https://github.com/llvm/llvm-project/commit/d8cd7806310c51af912a647a6ca46de62ff13214
DIFF: https://github.com/llvm/llvm-project/commit/d8cd7806310c51af912a647a6ca46de62ff13214.diff
LOG: [clang] OpenBSD does not support C11 atomics or threads.
Added:
Modified:
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 8004bc0f62f01..3d33eabcab44e 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -462,6 +462,11 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("__FLOAT128__");
}
+ if (Opts.C11) {
+ Builder.defineMacro("__STDC_NO_ATOMICS__");
+ Builder.defineMacro("__STDC_NO_THREADS__");
+ }
+
public:
OpenBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 4e46405dce6a5..6a3cb9b8ff6a9 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1464,6 +1464,16 @@
// OPENBSD:#define __WCHAR_TYPE__ int
// OPENBSD:#define __WINT_TYPE__ int
//
+// RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s
+// RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s
+// RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s
+// OPENBSD-STDC:#define __STDC_NO_ATOMICS__ 1
+// OPENBSD-STDC:#define __STDC_NO_THREADS__ 1
+//
+// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC-N %s
+// OPENBSD-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
+// OPENBSD-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=xcore-none-none < /dev/null | FileCheck -match-full-lines -check-prefix XCORE %s
// XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
// XCORE:#define __LITTLE_ENDIAN__ 1
More information about the cfe-commits
mailing list