Author: Zeyi Xu Date: 2026-08-06T00:46:27Z New Revision: 7db2e3307ce6a8bcc0f20caa16e1fd031013281f
URL: https://github.com/llvm/llvm-project/commit/7db2e3307ce6a8bcc0f20caa16e1fd031013281f DIFF: https://github.com/llvm/llvm-project/commit/7db2e3307ce6a8bcc0f20caa16e1fd031013281f.diff LOG: [Clang] Define `__SIG_ATOMIC_TYPE__` macro (#213934) Define `__SIG_ATOMIC_TYPE__` for compatibility with GCC. This fixes `riscv32-netbsd` and `riscv64-netbsd` system headers that define `sig_atomic_t` using this macro. Reference: https://gcc.gnu.org/onlinedocs/gcc-16.1.0/cpp/Common-Predefined-Macros.html Follow up of #199678, Closes #213895 (cherry picked from commit c08ed4c1ab086aad6f22cfc499e74d92953045ae) Added: Modified: clang/docs/ReleaseNotes.md clang/lib/Frontend/InitPreprocessor.cpp clang/test/Preprocessor/init-aarch64.c clang/test/Preprocessor/init-riscv.c clang/test/Preprocessor/init.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index 937db9730a001..a75d666f67691 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -834,6 +834,7 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the - Fixed a crash in the constant evaluator when an ill-formed array new-expression whose bound could not be determined (e.g. `new int[]()`) was used in a constant expression. (#GH200139) - Fixed a case where function effect analysis (`nonblocking` etc.) did not visit a destructor invoked from a `delete` expression. (#GH184460) - Clang now defines the GCC-compatible predefined macros `__WCHAR_MIN__`, `__WINT_MIN__`, and `__SIG_ATOMIC_MIN__`. (#GH199678) +- Clang now defines the GCC-compatible predefined macro `__SIG_ATOMIC_TYPE__`. (#GH213895) - Fix a crash in addUnsizedArray due assert not verifying we have a Base before doing checks on it. (#GH44212) - Fixed an assertion that could occur when rebuilding parenthesized list initialization expressions during template instantiation or AST transformation. diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 8b6ff844d0daa..65b065dc818f5 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1191,6 +1191,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI, DefineFmt(LangOpts, "__SIZE", TI.getSizeType(), TI, Builder); DefineType("__WCHAR_TYPE__", TI.getWCharType(), Builder); DefineType("__WINT_TYPE__", TI.getWIntType(), Builder); + DefineType("__SIG_ATOMIC_TYPE__", TI.getSigAtomicType(), Builder); DefineTypeSizeAndWidth("__SIG_ATOMIC", TI.getSigAtomicType(), TI, Builder); DefineTypeMin("__SIG_ATOMIC", TI.getSigAtomicType(), TI, Builder); if (LangOpts.C23) diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c index 6796cb3bdd912..44b92ea2331b0 100644 --- a/clang/test/Preprocessor/init-aarch64.c +++ b/clang/test/Preprocessor/init-aarch64.c @@ -264,6 +264,7 @@ // AARCH64-NEXT: #define __SHRT_WIDTH__ 16 // AARCH64-NEXT: #define __SIG_ATOMIC_MAX__ 2147483647 // AARCH64-NEXT: #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +// AARCH64-NEXT: #define __SIG_ATOMIC_TYPE__ int // AARCH64-NEXT: #define __SIG_ATOMIC_WIDTH__ 32 // AARCH64-NEXT: #define __SIZEOF_DOUBLE__ 8 // AARCH64-NEXT: #define __SIZEOF_FLOAT__ 4 diff --git a/clang/test/Preprocessor/init-riscv.c b/clang/test/Preprocessor/init-riscv.c index 00282e670a0f7..ad554e6948a87 100644 --- a/clang/test/Preprocessor/init-riscv.c +++ b/clang/test/Preprocessor/init-riscv.c @@ -14,5 +14,6 @@ // RV64: #define __GCC_DESTRUCTIVE_SIZE 64 // NETBSD: #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +// NETBSD: #define __SIG_ATOMIC_TYPE__ int // NETBSD: #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) // NETBSD: #define __WINT_MIN__ 0U diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 1d49af5c8d62f..29a8d234ece49 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1950,9 +1950,11 @@ // WEBASSEMBLY-NEXT:#define __SHRT_WIDTH__ 16 // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647L // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +// WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_TYPE__ long int // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 9223372036854775807L // WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_TYPE__ long int // WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __SIZEOF_DOUBLE__ 8 // WEBASSEMBLY-NEXT:#define __SIZEOF_FLOAT__ 4 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
