Q:

Silencing a -Wshift-count-overflow warning in a generic bitmask macro

I wrote this macro to get a bitmask generically:
#define BX_uint_least(Bits,Val) _Generic((char(*)[Bits]){0}, \
                                    char (*)[8]: (uint_least8_t)(Val), \
                                    char (*)[16]: (uint_least16_t)(Val), \
                                    char (*)[32]: (uint_least32_t)(Val), \
                                    char (*)[64]: (uint_least64_t)(Val))
#define BX_bitmask(Bits) ((BX_uint_least(Bits,1)<<Bits)-1)

but when I use it, it's generating -Wshift-count-overflow warnings.
Can these warnings be silenced from within the macro?
I don't want to silence them altogether because e.g., the UB-causing
((int32_t)1)<<32 should still get a warning, but ((uint_least32_t)1)<<32 overflowing to 0 is completely harmless and intended.
Example program:
#include <stdint.h>
#define BX_uint_least(Bits,Val) _Generic((char(*)[Bits]){0}, \
                                    char (*)[8]: (uint_least8_t)(Val), \
                                    char (*)[16]: (uint_least16_t)(Val), \
                                    char (*)[32]: (uint_least32_t)(Val), \
                                    char (*)[64]: (uint_least64_t)(Val))
#define BX_bitmask(Bits) ((BX_uint_least(Bits,1)<<Bits)-1)

int main() 
{

    //(void)((int32_t)1<<32); //UB; should warn
    (void)BX_bitmask(32); //shouldn't warn
    (void)(((uint32_t)1)<<32); //I don't care if it warns or not
}

By the way, the warning comes up with both gcc and clang without having to add any flags (such as -Wall or -Wextra), but by my reading of 6.5.7p4:

The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value of
  the result is E1 x 2E2 , reduced modulo one more than the maximum
  value representable in the result type. If E1 has a signed type and
  nonnegative value, and E1 x 2E2 is representable in the result type,
  then that is the resulting value; otherwise, the behavior is
  undefined.

the result of e.g., ((uint32_t)1)<<32 is perfectly well-defined (to be +(uint32_t)0) so I think it's a little weird that a perfectly well defined operation should ellicit a warning in compiler invocation that doesn't requests extra warnings.

A:

Bit shifting by an amount equal to the bit size of the type is undefined.
Section 6.5.7p3 of the C standard states:

The integer promotions are performed on each of the operands.  The
  type of the result is that  of  the  promoted  left  operand.   If 
  the  value  of  the  right  operand  is  negative  or  is greater than
  or equal to the width of the promoted left operand, the behavior is
  undefined.

So you can't perform ((uint_least32_t)1)<<32 or ((uint32_t)1)<<32 safely.

