mirror of git://gcc.gnu.org/git/gcc.git
PR c++/86190 - bogus -Wsign-conversion warning
PR c++/86190 - bogus -Wsign-conversion warning * typeck.c (cp_build_binary_op): Fix formatting. Add a warning sentinel. * g++.dg/warn/Wsign-conversion-3.C: New test. * g++.dg/warn/Wsign-conversion-4.C: New test. From-SVN: r262855
This commit is contained in:
parent
eb5926451a
commit
c56e97274f
|
|
@ -1,3 +1,9 @@
|
|||
2018-07-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/86190 - bogus -Wsign-conversion warning
|
||||
* typeck.c (cp_build_binary_op): Fix formatting. Add a warning
|
||||
sentinel.
|
||||
|
||||
2018-07-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/59480, DR 136
|
||||
|
|
|
|||
|
|
@ -5312,9 +5312,10 @@ cp_build_binary_op (location_t location,
|
|||
|
||||
if (short_compare)
|
||||
{
|
||||
/* We call shorten_compare only for diagnostic-reason. */
|
||||
tree xop0 = fold_simple (op0), xop1 = fold_simple (op1),
|
||||
xresult_type = result_type;
|
||||
/* We call shorten_compare only for diagnostics. */
|
||||
tree xop0 = fold_simple (op0);
|
||||
tree xop1 = fold_simple (op1);
|
||||
tree xresult_type = result_type;
|
||||
enum tree_code xresultcode = resultcode;
|
||||
shorten_compare (location, &xop0, &xop1, &xresult_type,
|
||||
&xresultcode);
|
||||
|
|
@ -5350,6 +5351,7 @@ cp_build_binary_op (location_t location,
|
|||
otherwise, it will be given type RESULT_TYPE. */
|
||||
if (! converted)
|
||||
{
|
||||
warning_sentinel w (warn_sign_conversion, short_compare);
|
||||
if (TREE_TYPE (op0) != result_type)
|
||||
op0 = cp_convert_and_check (result_type, op0, complain);
|
||||
if (TREE_TYPE (op1) != result_type)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
2018-07-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/86190 - bogus -Wsign-conversion warning
|
||||
* g++.dg/warn/Wsign-conversion-3.C: New test.
|
||||
* g++.dg/warn/Wsign-conversion-4.C: New test.
|
||||
|
||||
2018-07-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/59480, DR 136
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// PR c++/86190
|
||||
// { dg-options "-Wsign-conversion -Wsign-compare" }
|
||||
|
||||
typedef unsigned long sz_t;
|
||||
sz_t s();
|
||||
bool f(int i) { return s() < (unsigned long) i; }
|
||||
bool f2(int i) { return s() < static_cast<unsigned long>(i); }
|
||||
bool f3(int i) { return s() < i; } // { dg-warning "comparison of integer expressions of different signedness" }
|
||||
bool f4(int i) { return s() < (long) i; } // { dg-warning "comparison of integer expressions of different signedness" }
|
||||
bool f5(short int i) { return s() < (int) i; } // { dg-warning "comparison of integer expressions of different signedness" }
|
||||
bool f6(signed char i) { return s() < (int) i; } // { dg-warning "comparison of integer expressions of different signedness" }
|
||||
bool f7(unsigned char i) { return s() < i; }
|
||||
bool f8(signed char i) { return s() < i; } // { dg-warning "comparison of integer expressions of different signedness" }
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// PR c++/86190
|
||||
// { dg-options "-Wsign-conversion -Wsign-compare" }
|
||||
|
||||
typedef unsigned long size_t;
|
||||
|
||||
struct vector {
|
||||
typedef size_t size_type;
|
||||
size_type size();
|
||||
};
|
||||
|
||||
bool func(vector vec, int var)
|
||||
{
|
||||
return vec.size() < static_cast<size_t>(var); // { dg-bogus "may change" }
|
||||
}
|
||||
Loading…
Reference in New Issue