aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c b/gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c
new file mode 100644
index 000000000..87d422b79
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/cpp/Wsignprom.c
@@ -0,0 +1,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