https://github.com/gallopruss-sie updated https://github.com/llvm/llvm-project/pull/234114
>From 7c2d6cb791f6de48a25c14ca0f70ebd7b5aab362 Mon Sep 17 00:00:00 2001 From: Russell Gallop <[email protected]> Date: Wed, 21 Oct 2026 09:28:52 +0100 Subject: [PATCH 1/2] [clang] Improve diagnostic if intrin.h used in incompatible environments Attempting to include intrin.h in environments (such as PS5) where it isn't supported results in a confusing file not found error from the include_next ...\intrin.h(12,15): fatal error: 'intrin.h' file not found 12 | #include_next <intrin.h> | ^~~~~~~~~~ This can occur when porting codebases from Windows. This change provides an earlier, clearer error in these environments. --- clang/lib/Headers/intrin.h | 4 +++- clang/test/Headers/intrin-non-windows.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 clang/test/Headers/intrin-non-windows.cpp diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h index 7dcb5a526afb2a..7396e476dd9915 100644 --- a/clang/lib/Headers/intrin.h +++ b/clang/lib/Headers/intrin.h @@ -8,7 +8,9 @@ */ /* Only include this if we're compiling for the windows platform. */ -#ifndef _MSC_VER +#if !defined(_WIN32) +#error "<intrin.h> is a Windows-only header and is not available on this platform" +#elif !defined(_MSC_VER) #include_next <intrin.h> #else diff --git a/clang/test/Headers/intrin-non-windows.cpp b/clang/test/Headers/intrin-non-windows.cpp new file mode 100644 index 00000000000000..36bb2bcc704db4 --- /dev/null +++ b/clang/test/Headers/intrin-non-windows.cpp @@ -0,0 +1,14 @@ +// Verify that <intrin.h> produces a clear diagnostic on non-Windows targets +// rather than silently failing via #include_next to a missing system header. + +// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffreestanding -fsyntax-only \ +// RUN: -Wsystem-headers -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -fsyntax-only \ +// RUN: -Wsystem-headers -verify %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -ffreestanding -fsyntax-only \ +// RUN: -Wsystem-headers -verify %s +// RUN: %clang_cc1 -triple x86_64-sie-ps5 -ffreestanding -fsyntax-only \ +// RUN: -Wsystem-headers -verify %s + +// [email protected]:* {{<intrin.h> is a Windows-only header and is not available on this platform}} +#include <intrin.h> >From a25caecc3123190a675237299a2d1612dbef2f54 Mon Sep 17 00:00:00 2001 From: Russell Gallop <[email protected]> Date: Wed, 21 Oct 2026 09:56:37 +0100 Subject: [PATCH 2/2] clang-format --- clang/lib/Headers/intrin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h index 7396e476dd9915..4026d9c34da6c9 100644 --- a/clang/lib/Headers/intrin.h +++ b/clang/lib/Headers/intrin.h @@ -9,7 +9,8 @@ /* Only include this if we're compiling for the windows platform. */ #if !defined(_WIN32) -#error "<intrin.h> is a Windows-only header and is not available on this platform" +#error \ + "<intrin.h> is a Windows-only header and is not available on this platform" #elif !defined(_MSC_VER) #include_next <intrin.h> #else _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
