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
+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
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);
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);
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;
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. */
+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
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wconversion" } */
+
+unsigned f(unsigned a) { return a + -1; } /* { dg-warning "negative" } */
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned f(unsigned a) { return a + -1; }
+