diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-07-20 13:31:56 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-07-20 13:31:56 +0000 |
commit | 21d6e4ae7eba14121ef5db8f0a48829f0abf94dc (patch) | |
tree | 9bd94b5aaf271855796963e66d84694ac7170431 /gcc/testsuite/gcc.dg/cpp/Wsignprom.c | |
parent | 243520fa70386744d7f2b95763384bd22f8576a1 (diff) | |
download | ppe42-gcc-21d6e4ae7eba14121ef5db8f0a48829f0abf94dc.tar.gz ppe42-gcc-21d6e4ae7eba14121ef5db8f0a48829f0abf94dc.zip |
* cppexp.c (struct op): Add token pointer.
(check_promotion, CHECK_PROMOTION): New.
(optab): Update.
(_cpp_parse_expr): Update, use token pointer of struct op.
(reduce): Warn about change of sign owing to promotion.
* cppinit.c (cpp_handle_option): New warning if -Wall.
* cpplib.h (struct cpp_options): New member.
testsuite:
* gcc.dg/cpp/Wsignprom.c: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55611 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp/Wsignprom.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/Wsignprom.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/Wsignprom.c b/gcc/testsuite/gcc.dg/cpp/Wsignprom.c new file mode 100644 index 00000000000..44b5667b3f2 --- /dev/null +++ b/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 "changes sign when promoted" } */ +#endif + +#if 0U + -1 /* { dg-warning "changes sign when promoted" } */ +#endif + +#if 0U * -1 /* { dg-warning "changes sign when promoted" } */ +#endif + +#if 1U / -2 /* { dg-warning "changes sign when promoted" } */ +#endif + +#if -1 % 1U /* { dg-warning "changes sign when promoted" } */ +#endif + +#if 1 ? 0U : -1 /* { dg-warning "changes sign when promoted" } */ +#endif + +#if 1 ? -1 : 0U /* { dg-warning "changes sign when promoted" } */ +#endif |