comparison gcc/testsuite/c-c++-common/Wsign-compare-1.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* PR c/81417 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wsign-compare" } */
4
5 int
6 fn1 (signed int a, unsigned int b)
7 {
8 return a < b; /* { dg-warning "comparison of integer expressions of different signedness: 'int' and 'unsigned int'" } */
9 }
10
11 int
12 fn2 (signed int a, unsigned int b)
13 {
14 return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'int'" } */
15 }
16
17 int
18 fn3 (signed long int a, unsigned long int b)
19 {
20 return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'long unsigned int' and 'long int'" } */
21 }
22
23 int
24 fn4 (signed short int a, unsigned int b)
25 {
26 return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'short int'" } */
27 }
28
29 int
30 fn5 (unsigned int a, signed int b)
31 {
32 return a < b; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'int'" } */
33 }