daltenty created this revision. Herald added a subscriber: jfb. daltenty requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The libc implementation on AIX does not have stdatomic.h and the requisite interfaces for c11 atomics, so for now it's better to set __STDC_NO_ATOMICS__ Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D99483 Files: clang/lib/Basic/Targets/OSTargets.h clang/test/Preprocessor/aix-nocatomics.c Index: clang/test/Preprocessor/aix-nocatomics.c =================================================================== --- /dev/null +++ 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 Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ 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:
Index: clang/test/Preprocessor/aix-nocatomics.c =================================================================== --- /dev/null +++ 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 Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ 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:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits