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
This commit is contained in:
parent
f0913ab8d6
commit
0f57299d37
7 changed files with 28 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
5
gcc/testsuite/gcc.dg/Wconversion-3.c
Normal file
5
gcc/testsuite/gcc.dg/Wconversion-3.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wconversion" } */
|
||||
|
||||
unsigned f(unsigned a) { return a + -1; } /* { dg-warning "negative" } */
|
||||
|
5
gcc/testsuite/gcc.dg/Wconversion-4.c
Normal file
5
gcc/testsuite/gcc.dg/Wconversion-4.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
unsigned f(unsigned a) { return a + -1; }
|
||||
|
Loading…
Add table
Reference in a new issue