diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -722,6 +722,11 @@ if (Opts.CPlusPlus && Opts.WChar) { Builder.defineMacro("_WCHAR_T"); } + + // The AIX library implementation of C11 atomics is not yet complete. + if (Opts.C11 || Opts.C17 || Opts.C2x) { + Builder.defineMacro("__STDC_NO_ATOMICS__"); + } } public: diff --git a/clang/test/Preprocessor/aix-nocatomics.c b/clang/test/Preprocessor/aix-nocatomics.c new file mode 100644 --- /dev/null +++ b/clang/test/Preprocessor/aix-nocatomics.c @@ -0,0 +1,19 @@ +// The AIX library implementation of C11 atomics is incomplete, so test that the +// appropriate macro is set. + +// 32-bit cases. +// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c11 < /dev/null | FileCheck -match-full-lines %s +// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c17 < /dev/null | FileCheck -match-full-lines %s +// RUN: %clang_cc1 -E -dM -triple=powerpc-ibm-aix7.1.0.0 -std=c2x < /dev/null | FileCheck -match-full-lines %s + +// 64-bit cases. +// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c11 < /dev/null | FileCheck -match-full-lines %s +// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c17 < /dev/null | FileCheck -match-full-lines %s +// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c2x < /dev/null | FileCheck -match-full-lines %s + +// CHECK:#define __STDC_NO_ATOMICS__ 1 + +// Check that it's not set for C before 11. +// RUN: %clang_cc1 -E -dM -triple=powerpc64-ibm-aix7.1.0.0 -std=c99 < /dev/null | FileCheck -match-full-lines -check-prefix C99 %s + +// C99-NOT:#define __STDC_NO_ATOMICS__ 1