aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-05-01 16:51:19 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-05-01 16:51:19 +0000
commit0f57299d37b292bdfdc4e2a0d0fe00935b8c1931 (patch)
tree5fe7571023d4ea5ca8d0e554a9a317466e1d435f /gcc
parentf0913ab8d6b3990d68fc498fd2f9d6407fd10536 (diff)
downloadgcc-0f57299d37b292bdfdc4e2a0d0fe00935b8c1931.zip
gcc-0f57299d37b292bdfdc4e2a0d0fe00935b8c1931.tar.gz
gcc-0f57299d37b292bdfdc4e2a0d0fe00935b8c1931.tar.bz2
c-typeck.c (parser_build_binary_op): Don't call the function unsigned_conversion_warning to spot operand/result type...
* c-typeck.c (parser_build_binary_op): Don't call the function unsigned_conversion_warning to spot operand/result type overflow. (build_binary_op): Instead, call convert_and_check instead of convert to report the problem when the operands are promoted. * c-common.c (unsigned_conversion_warning): Make static. * c-common.h (unsigned_conversion_warning): Delete prototype. * gcc.dg/Wconversion-3.c: New test case. * gcc.dg/Wconversion-4.c: Likewise. Co-Authored-By: Joseph Myers <joseph@codesourcery.com> From-SVN: r113418
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-common.c2
-rw-r--r--gcc/c-common.h1
-rw-r--r--gcc/c-typeck.c6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/Wconversion-3.c5
-rw-r--r--gcc/testsuite/gcc.dg/Wconversion-4.c5
7 files changed, 28 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ac99122..30e6800 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2006-05-01 Roger Sayle <roger@eyesopen.com>
+
+ * c-typeck.c (parser_build_binary_op): Don't call the function
+ unsigned_conversion_warning to spot operand/result type overflow.
+ (build_binary_op): Instead, call convert_and_check instead of
+ convert to report the problem when the operands are promoted.
+ * c-common.c (unsigned_conversion_warning): Make static.
+ * c-common.h (unsigned_conversion_warning): Delete prototype.
+
2006-05-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/26726
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 5e54660..fc9def8 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -953,7 +953,7 @@ overflow_warning (tree value)
Invoke this function on every expression that might be implicitly
converted to an unsigned type. */
-void
+static void
unsigned_conversion_warning (tree result, tree operand)
{
tree type = TREE_TYPE (result);
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 5636685..2d4248a 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -659,7 +659,6 @@ extern void strict_aliasing_warning(tree, tree, tree);
extern void empty_body_warning (tree, tree);
extern tree convert_and_check (tree, tree);
extern void overflow_warning (tree);
-extern void unsigned_conversion_warning (tree, tree);
extern bool c_determine_visibility (tree);
extern bool same_scalar_type_ignoring_signedness (tree, tree);
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 64fa9f1..2152920 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2628,8 +2628,6 @@ parser_build_binary_op (enum tree_code code, struct c_expr arg1,
warning (OPT_Wstring_literal_comparison,
"comparison with string literal");
- unsigned_conversion_warning (result.value, arg1.value);
- unsigned_conversion_warning (result.value, arg2.value);
overflow_warning (result.value);
return result;
@@ -8367,9 +8365,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
if (!converted)
{
if (TREE_TYPE (op0) != result_type)
- op0 = convert (result_type, op0);
+ op0 = convert_and_check (result_type, op0);
if (TREE_TYPE (op1) != result_type)
- op1 = convert (result_type, op1);
+ op1 = convert_and_check (result_type, op1);
/* This can happen if one operand has a vector type, and the other
has a different type. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 15c7c63..4ff2941 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-01 Roger Sayle <roger@eyesopen.com>
+ Joseph S. Myers <joseph@codesourcery.com>
+
+ * gcc.dg/Wconversion-3.c: New test case.
+ * gcc.dg/Wconversion-4.c: Likewise.
+
2006-05-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/26726
diff --git a/gcc/testsuite/gcc.dg/Wconversion-3.c b/gcc/testsuite/gcc.dg/Wconversion-3.c
new file mode 100644
index 0000000..d45749d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wconversion-3.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wconversion" } */
+
+unsigned f(unsigned a) { return a + -1; } /* { dg-warning "negative" } */
+
diff --git a/gcc/testsuite/gcc.dg/Wconversion-4.c b/gcc/testsuite/gcc.dg/Wconversion-4.c
new file mode 100644
index 0000000..ddd1987
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wconversion-4.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned f(unsigned a) { return a + -1; }
+