From: Ted Kremenek Date: Mon, 7 Oct 2013 23:51:11 +0000 (+0000) Subject: Suppress useless -Wshadow warning when using _mm* macros from emmintrin.h X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=185f156e41b38c2452dba7bb0ee44067f8d92538;p=clang Suppress useless -Wshadow warning when using _mm* macros from emmintrin.h Fixes . I'm not completely satisfied with this patch. Sprinkling "diagnostic ignored" _Pragmas throughout this file is gross, but I couldn't suppress it for the entire file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192143 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/emmintrin.h b/lib/Headers/emmintrin.h index 505773e388..9ab0a73aad 100644 --- a/lib/Headers/emmintrin.h +++ b/lib/Headers/emmintrin.h @@ -826,7 +826,9 @@ _mm_xor_si128(__m128i __a, __m128i __b) } #define _mm_slli_si128(a, count) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128i __a = (a); \ + _Pragma("clang diagnostic pop"); \ (__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); }) static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) @@ -891,7 +893,9 @@ _mm_sra_epi32(__m128i __a, __m128i __count) #define _mm_srli_si128(a, count) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128i __a = (a); \ + _Pragma("clang diagnostic pop"); \ (__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); }) static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) @@ -1280,20 +1284,26 @@ _mm_movemask_epi8(__m128i __a) } #define _mm_shuffle_epi32(a, imm) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128i __a = (a); \ + _Pragma("clang diagnostic pop"); \ (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si) _mm_set1_epi32(0), \ (imm) & 0x3, ((imm) & 0xc) >> 2, \ ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); }) #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128i __a = (a); \ + _Pragma("clang diagnostic pop"); \ (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ (imm) & 0x3, ((imm) & 0xc) >> 2, \ ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ 4, 5, 6, 7); }) #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128i __a = (a); \ + _Pragma("clang diagnostic pop"); \ (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ 0, 1, 2, 3, \ 4 + (((imm) & 0x03) >> 0), \ @@ -1386,8 +1396,10 @@ _mm_movemask_pd(__m128d __a) } #define _mm_shuffle_pd(a, b, i) __extension__ ({ \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\""); \ __m128d __a = (a); \ __m128d __b = (b); \ + _Pragma("clang diagnostic pop"); \ __builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); }) static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) diff --git a/test/Sema/warn-shadow.c b/test/Sema/warn-shadow.c index 32aca8d612..a9979ff9d7 100644 --- a/test/Sema/warn-shadow.c +++ b/test/Sema/warn-shadow.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s +#include + int i; // expected-note 3 {{previous declaration is here}} void foo() { @@ -59,3 +61,11 @@ void rdar8883302() { void test8() { int bob; // expected-warning {{declaration shadows a variable in the global scope}} } + +// Test that using two macros from emmintrin do not cause a +// useless -Wshadow warning. +void rdar10679282() { + __m128i qf = _mm_setzero_si128(); + qf = _mm_slli_si128(_mm_add_epi64(qf, _mm_srli_si128(qf, 8)), 8); // no-warning + (void) qf; +}