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 <oleg.tolmatcev@gmail.com>
#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 */
--- /dev/null
+/* Verify that _m_prefetchw does not produce -Wcast-qual warnings when\r
+ included as a system header. The cast (const void *) drops volatile\r
+ from volatile const void *, which would trigger -Wcast-qual if not\r
+ in a system header. */\r
+/* { dg-do compile } */\r
+/* { dg-options "-mprfchw -O2 -Wcast-qual" } */\r
+\r
+#include <x86intrin.h>\r
+\r
+void\r
+prefetchw_cast_qual_test (volatile void *p)\r
+{\r
+ _m_prefetchw (p);\r
+}\r
+\r
+/* { dg-bogus "cast discards .volatile. qualifier" "" { target *-*-* } 0 } */\r