Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][X86] Fix -Wundef warning in cpuid.h #89842

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Conversation

DanShaders
Copy link
Contributor

Caught by compiling a project (SerenityOS) that uses compiler-rt and not silencing warnings from system headers.

Caught by compiling a project (SerenityOS) that uses compiler-rt and
not silencing warnings from system headers.
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Apr 23, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2024

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: Dan Klishch (DanShaders)

Changes

Caught by compiling a project (SerenityOS) that uses compiler-rt and not silencing warnings from system headers.


Full diff: https://github.com/llvm/llvm-project/pull/89842.diff

1 Files Affected:

  • (modified) clang/lib/Headers/cpuid.h (+3-3)
diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 0bb9912b465ffe..bb7692efb78ffe 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -10,7 +10,7 @@
 #ifndef __CPUID_H
 #define __CPUID_H
 
-#if !(__x86_64__ || __i386__)
+#if !defined(__x86_64__) && !defined(__i386__)
 #error this header is for x86 only
 #endif
 
@@ -256,7 +256,7 @@
 #define bit_AVX10_256   0x00020000
 #define bit_AVX10_512   0x00040000
 
-#if __i386__
+#ifdef __i386__
 #define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
     __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
                   : "0"(__leaf))
@@ -285,7 +285,7 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf,
                                               unsigned int *__sig)
 {
     unsigned int __eax, __ebx, __ecx, __edx;
-#if __i386__
+#ifdef __i386__
     int __cpuid_supported;
 
     __asm("  pushfl\n"

@nico
Copy link
Contributor

nico commented Apr 26, 2024

If your project disables warning for system headers (why even do that?), I'm guessing there's going to be a bunch of other issues you'll run into. But this change here is fine, it makes cpuid.h consisten with all the other headers in clang/lib/Headers :)

@nico nico merged commit 134e645 into llvm:main Apr 26, 2024
8 checks passed
@DanShaders DanShaders deleted the defined-i386 branch April 26, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants