OSDN Git Service

PR c++/49793
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Jul 2011 00:14:46 +0000 (00:14 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Jul 2011 00:14:46 +0000 (00:14 +0000)
* typeck2.c (check_narrowing): Downgrade permerror to pedwarn.
Make conditional on -Wnarrowing.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176665 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist17.C
gcc/testsuite/g++.dg/cpp0x/initlist36.C
gcc/testsuite/g++.dg/cpp0x/initlist5.C
gcc/testsuite/g++.dg/cpp0x/initlist52.C
gcc/testsuite/g++.dg/cpp0x/initlist7.C

index 990302f..be7317d 100644 (file)
@@ -1,5 +1,8 @@
 2011-07-22  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49793
+       * c.opt (Wnarrowing): New.
+
        PR c++/30112
        * c-common.h: Declare c_linkage_bindings.
        * c-pragma.c (handle_pragma_redefine_extname): Use it.
index 00bdd93..617ea2d 100644 (file)
@@ -489,6 +489,10 @@ Wmultichar
 C ObjC C++ ObjC++ Warning
 Warn about use of multi-character character constants
 
+Wnarrowing
+C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(1)
+-Wno-narrowing   In C++0x mode, ignore ill-formed narrowing conversions within { }
+
 Wnested-externs
 C ObjC Var(warn_nested_externs) Warning
 Warn about \"extern\" declarations not at file scope
index cdbb3fe..284224f 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49793
+       * typeck2.c (check_narrowing): Downgrade permerror to pedwarn.
+       Make conditional on -Wnarrowing.
+
 2011-07-22  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Warn about the use of final/override in non-c++0x mode, and
index bdd2452..727a88b 100644 (file)
@@ -719,7 +719,7 @@ check_narrowing (tree type, tree init)
   bool ok = true;
   REAL_VALUE_TYPE d;
 
-  if (!ARITHMETIC_TYPE_P (type))
+  if (!warn_narrowing || !ARITHMETIC_TYPE_P (type))
     return;
 
   if (BRACE_ENCLOSED_INITIALIZER_P (init)
@@ -777,8 +777,8 @@ check_narrowing (tree type, tree init)
     }
 
   if (!ok)
-    permerror (input_location, "narrowing conversion of %qE from %qT "
-              "to %qT inside { }", init, ftype, type);
+    pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE "
+            "from %qT to %qT inside { }", init, ftype, type);
 }
 
 /* Process the initializer INIT for a variable of type TYPE, emitting
index a364c72..1d0d089 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49793
+       * g++.dg/cpp0x/initlist55.C: New.
+
 2011-07-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/49791
index 86371e8..6ea08d1 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
 
 void f(int i);
 
index 94624c9..a703b45 100644 (file)
@@ -1,5 +1,5 @@
 // PR c++/44358
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
 
 #include <initializer_list>
 
index 32caac3..dbd17ec 100644 (file)
@@ -1,5 +1,5 @@
 // Test for narrowing diagnostics
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
 
 #include <initializer_list>
 
index 22bc287..17c0cfe 100644 (file)
@@ -1,5 +1,5 @@
 // PR c++/45378
-// { dg-options -std=c++0x }
+// { dg-options "-std=c++0x -pedantic-errors" }
 
 int main()
 {
index 7913ed7..55a0371 100644 (file)
@@ -1,5 +1,5 @@
 // PR c++/37932
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
 
 typedef enum { AA=1, BB=2 } my_enum;