diff mbox

[C++] PR 65858

Message ID 5542858A.7050703@oracle.com
State New
Headers show

Commit Message

Paolo Carlini April 30, 2015, 7:42 p.m. UTC
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.

///////////////////////

Comments

Prathamesh Kulkarni April 30, 2015, 9:08 p.m. UTC | #1
On 1 May 2015 at 01:12, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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
That could be fixed as follows:
if (!warn_narrowing || inhibit_warnings)
  ok = true;
else
  // pedwarn
>> -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!
Indeed, checking return value of pedwarn is better compared to testing
on warning flags.
Thanks for pointing out -;)

Regards,
Prathamesh
>
> Paolo.
>
> ///////////////////////
Jason Merrill May 1, 2015, 5:25 p.m. UTC | #2
OK (= true).

Jason
diff mbox

Patch

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 };