===================================================================
@@ -2121,19 +2121,17 @@ unsafe_conversion_p (tree type, tree expr, bool pr
static void
conversion_warning (tree type, tree expr)
{
- int i;
- const int expr_num_operands = TREE_OPERAND_LENGTH (expr);
tree expr_type = TREE_TYPE (expr);
location_t loc = EXPR_LOC_OR_HERE (expr);
if (!warn_conversion && !warn_sign_conversion)
return;
- /* If any operand is artificial, then this expression was generated
- by the compiler and we do not warn. */
- for (i = 0; i < expr_num_operands; i++)
+ /* If the only operand is artificial, then the expression was generated
+ by the compiler and we do not warn. ???? */
+ if (TREE_OPERAND_LENGTH (expr) == 1)
{
- tree op = TREE_OPERAND (expr, i);
+ tree op = TREE_OPERAND (expr, 0);
if (op && DECL_P (op) && DECL_ARTIFICIAL (op))
return;
}
===================================================================
@@ -0,0 +1,17 @@
+// PR c++/45385
+// { dg-options "-Wconversion" }
+
+void foo(unsigned char);
+
+class Test
+{
+ void eval()
+ {
+ foo(bar()); // { dg-warning "may alter its value" }
+ }
+
+ unsigned int bar() const
+ {
+ return __INT_MAX__ * 2U + 1;
+ }
+};