===================================================================
@@ -958,10 +958,12 @@ check_narrowing (tree type, tree init, tsubst_flag
}
else if (complain & tf_error)
{
+ int savederrorcount = errorcount;
global_dc->pedantic_errors = 1;
- if (!pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
- "narrowing conversion of %qE from %qT to %qT "
- "inside { }", init, ftype, type))
+ pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
+ "narrowing conversion of %qE from %qT to %qT "
+ "inside { }", init, ftype, type);
+ if (errorcount == savederrorcount)
ok = true;
global_dc->pedantic_errors = flag_pedantic_errors;
}
===================================================================
@@ -0,0 +1,14 @@
+// PR c++/66007
+// { dg-do run { target c++11 } }
+// { dg-options "-Wno-error=narrowing" }
+
+extern "C" void abort();
+
+int main()
+{
+ unsigned foo[] = { 1, -1, 3 };
+ if (foo[0] != 1 || foo[1] != __INT_MAX__ * 2U + 1 || foo[2] != 3)
+ abort();
+}
+
+// { dg-prune-output "narrowing conversion" }