opnsense-src/test/Sema/shift.c

41 lines
1 KiB
C
Raw Normal View History

2010-01-01 05:34:51 -05:00
// RUN: %clang -Wall -fsyntax-only -Xclang -verify %s
2009-10-14 14:03:49 -04:00
#include <limits.h>
enum {
X = 1 << 0,
Y = 1 << 1,
Z = 1 << 2
};
2009-06-02 13:58:47 -04:00
void test() {
char c;
2009-10-14 14:03:49 -04:00
c = 0 << 0;
c = 0 << 1;
c = 1 << 0;
c = 1 << -0;
c = 1 >> -0;
c = 1 << -1; // expected-warning {{shift count is negative}}
c = 1 >> -1; // expected-warning {{shift count is negative}}
c = 1 << c;
c <<= 0;
c >>= 0;
c <<= 1;
c >>= 1;
c <<= -1; // expected-warning {{shift count is negative}}
c >>= -1; // expected-warning {{shift count is negative}}
c <<= 999999; // expected-warning {{shift count >= width of type}}
c >>= 999999; // expected-warning {{shift count >= width of type}}
c <<= CHAR_BIT; // expected-warning {{shift count >= width of type}}
c >>= CHAR_BIT; // expected-warning {{shift count >= width of type}}
c <<= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
c >>= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
(void)((long)c << CHAR_BIT);
2009-06-02 13:58:47 -04:00
}
2009-10-14 14:03:49 -04:00
#define a 0
#define ashift 8
enum { b = (a << ashift) };