Match Clang's declaration of _m_prefetchw to avoid requiring
const_cast<void *> at call sites.
gcc/ChangeLog:
* config/i386/prfchwintrin.h (_m_prefetchw):: Take
volatile const void * instead of void *.
gcc/testsuite/ChangeLog:
* gcc.target/i386/prfchw-Wcast-qual-1.c: New test.
Signed-off-by: oltolm <[email protected]>
---
I don't have git commit rights.
Oleg
gcc/config/i386/prfchwintrin.h | 4 ++--
.../gcc.target/i386/prfchw-Wcast-qual-1.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/prfchw-Wcast-qual-1.c
diff --git a/gcc/config/i386/prfchwintrin.h b/gcc/config/i386/prfchwintrin.h
index af3bded18e0..2ac190964de 100644
--- a/gcc/config/i386/prfchwintrin.h
+++ b/gcc/config/i386/prfchwintrin.h
@@ -29,9 +29,9 @@
#define _PRFCHWINTRIN_H_INCLUDED
extern __inline void __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
-_m_prefetchw (void *__P)
+_m_prefetchw (volatile const void *__P)
{
- __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+ __builtin_prefetch ((const void *) __P, 1, 3 /* _MM_HINT_T0 */);
}
#endif /* _PRFCHWINTRIN_H_INCLUDED */
diff --git a/gcc/testsuite/gcc.target/i386/prfchw-Wcast-qual-1.c
b/gcc/testsuite/gcc.target/i386/prfchw-Wcast-qual-1.c
new file mode 100644
index 00000000000..c6e86aa6d3d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/prfchw-Wcast-qual-1.c
@@ -0,0 +1,16 @@
+/* Verify that _m_prefetchw does not produce -Wcast-qual warnings when
+ included as a system header. The cast (const void *) drops volatile
+ from volatile const void *, which would trigger -Wcast-qual if not
+ in a system header. */
+/* { dg-do compile } */
+/* { dg-options "-mprfchw -O2 -Wcast-qual" } */
+
+#include <x86intrin.h>
+
+void
+prefetchw_cast_qual_test (volatile void *p)
+{
+ _m_prefetchw (p);
+}
+
+/* { dg-bogus "cast discards .volatile. qualifier" "" { target *-*-* } 0 } */
--
2.54.0.windows.1