Hi again,
On 04/30/2015 08:45 PM, Paolo Carlini wrote:
.. also, your patch doesn't seem to fix the case of -w instead of
-Wno-narrowing. I think we want to check the return value of the
pedwarn instead. I'm testing something.
I'm finishing testing the below: with hindsight, checking the return
value of the pedwarn makes a lot of sense to me!
Paolo.
///////////////////////
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 222628)
+++ cp/typeck2.c (working copy)
@@ -959,9 +959,10 @@ check_narrowing (tree type, tree init, tsubst_flag
else if (complain & tf_error)
{
global_dc->pedantic_errors = 1;
- pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
- "narrowing conversion of %qE from %qT to %qT inside { }",
- init, ftype, type);
+ if (!pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
+ "narrowing conversion of %qE from %qT to %qT "
+ "inside { }", init, ftype, type))
+ ok = true;
global_dc->pedantic_errors = flag_pedantic_errors;
}
}
Index: testsuite/g++.dg/cpp0x/Wnarrowing4.C
===================================================================
--- testsuite/g++.dg/cpp0x/Wnarrowing4.C (revision 0)
+++ testsuite/g++.dg/cpp0x/Wnarrowing4.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/65858
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target lto }
+// { dg-options "-flto -Wno-narrowing" }
+
+int x { 0.5 };