2014-08-04 Ed Schonberg <schonberg@adacore.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / Wconversion-5.c
blobbe749a9a65f5b9951c814c317f09dd618b1457f8
1 /* PR c++/34198 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wconversion" } */
5 signed char sc;
6 unsigned char uc;
7 short int ss;
8 unsigned short int us;
9 int si;
10 unsigned int ui;
12 void test1 (void)
14 int a = uc & 0xff;
15 int b = sc & 0x7f;
16 int c = 0xff & uc;
17 int d = 0x7f & sc;
18 int e = uc & sc;
19 unsigned char f = (int) uc;
20 signed char g = (int) sc;
21 unsigned char h = (unsigned int) (short int) uc;
22 signed char i = (int) (unsigned short int) sc; /* { dg-warning "may alter its value" "" { target { int32plus } } } */
23 unsigned char j = (unsigned int) (short int) us; /* { dg-warning "may alter its value" } */
24 signed char k = (int) (unsigned short int) ss; /* { dg-warning "may alter its value" } */
27 void test2 (void)
29 signed char a = (unsigned char) sc; /* { dg-warning "may change the sign" } */
30 unsigned char b = (signed char) uc; /* { dg-warning "may change the sign" } */
31 signed char c = (int) (unsigned char) sc; /* { dg-warning "may change the sign" } */
32 unsigned char d = (int) (signed char) uc; /* { dg-warning "may change the sign" } */
33 int e = (unsigned int) si; /* { dg-warning "may change the sign" } */
34 unsigned int f = (int) ui; /* { dg-warning "may change the sign" } */