summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp/Wsignprom.c
blob: 87d422b794fdcc89c4e8749a87b88177c910469e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* { dg-do preprocess } */
/* { dg-options "-Wall" } */

/* Test that -Wall emits the warnings about integer promotion changing
   the sign of an operand.  */

#if -1 > 0U  /* { dg-warning "5:changes sign when promoted" } */
#endif

#if 0U + -1  /* { dg-warning "10:changes sign when promoted" } */
#endif

#if 0U * -1  /* { dg-warning "10:changes sign when promoted" } */
#endif

#if 1U / -2  /* { dg-warning "10:changes sign when promoted" } */
#endif

#if -1 % 1U  /* { dg-warning "5:changes sign when promoted" } */
#endif

#if 1 ? 0U : -1  /* { dg-warning "14:changes sign when promoted" } */
#endif

#if 1 ? -1 : 0U  /* { dg-warning "9:changes sign when promoted" } */
#endif