===================================================================
@@ -2121,23 +2121,12 @@ 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++)
- {
- tree op = TREE_OPERAND (expr, i);
- if (op && DECL_P (op) && DECL_ARTIFICIAL (op))
- return;
- }
-
switch (TREE_CODE (expr))
{
case EQ_EXPR:
===================================================================
@@ -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;
+ }
+};
===================================================================
@@ -2998,7 +2998,8 @@ build_vec_init (tree base, tree maxindex, tree ini
if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
maxindex = array_type_nelts (atype);
- if (maxindex == NULL_TREE || maxindex == error_mark_node)
+ if (maxindex == NULL_TREE || maxindex == error_mark_node
+ || tree_int_cst_equal (maxindex, integer_minus_one_node))
return error_mark_node;
if (explicit_value_init_p)