OSDN Git Service

* c-typeck.c (parser_build_binary_op): Don't call the function
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 May 2006 16:51:19 +0000 (16:51 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 May 2006 16:51:19 +0000 (16:51 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113418 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wconversion-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wconversion-4.c [new file with mode: 0644]

index ac99122..30e6800 100644 (file)
@@ -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
index 5e54660..fc9def8 100644 (file)
@@ -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);
index 5636685..2d4248a 100644 (file)
@@ -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);
 
index 64fa9f1..2152920 100644 (file)
@@ -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.  */
index 15c7c63..4ff2941 100644 (file)
@@ -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 (file)
index 0000000..d45749d
--- /dev/null
@@ -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 (file)
index 0000000..ddd1987
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned f(unsigned a) { return a + -1; }
+