aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wsign-compare-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/c-c++-common/Wsign-compare-1.c')
-rw-r--r--gcc/testsuite/c-c++-common/Wsign-compare-1.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/Wsign-compare-1.c b/gcc/testsuite/c-c++-common/Wsign-compare-1.c
new file mode 100644
index 00000000000..b9b17a99280
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wsign-compare-1.c
@@ -0,0 +1,33 @@
+/* PR c/81417 */
+/* { dg-do compile } */
+/* { dg-options "-Wsign-compare" } */
+
+int
+fn1 (signed int a, unsigned int b)
+{
+ return a < b; /* { dg-warning "comparison of integer expressions of different signedness: 'int' and 'unsigned int'" } */
+}
+
+int
+fn2 (signed int a, unsigned int b)
+{
+ return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'int'" } */
+}
+
+int
+fn3 (signed long int a, unsigned long int b)
+{
+ return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'long unsigned int' and 'long int'" } */
+}
+
+int
+fn4 (signed short int a, unsigned int b)
+{
+ return b < a; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'short int'" } */
+}
+
+int
+fn5 (unsigned int a, signed int b)
+{
+ return a < b; /* { dg-warning "comparison of integer expressions of different signedness: 'unsigned int' and 'int'" } */
+}