I'm backporting this so that, if we run into a particularly obnoxious
set of narrowing conversions in the C++11 transition, we can just
-Wno-narrowing instead of rolling a new gcc release.
Tested with check-c++ on ubuntu x86_64. Since this is going into a
google branch, I'll just commit it in a few hours unless I hear
complaints.
c-family/ChangeLog.google-4_6:
2011-11-02 Jeffrey Yasskin <[email protected]>
Backport from rev 176665
2011-07-22 Jason Merrill <[email protected]>
* c.opt (Wnarrowing): New.
cp/ChangeLog.google-4_6:
2011-11-02 Jeffrey Yasskin <[email protected]>
Backport from rev 176665
2011-07-22 Jason Merrill <[email protected]>
* typeck2.c (check_narrowing): Downgrade permerror to pedwarn.
Make conditional on -Wnarrowing.
testsuite/ChangeLog.google-4_6:
2011-11-02 Jeffrey Yasskin <[email protected]>
Backport from rev 176665
2011-07-22 Jason Merrill <[email protected]>
* g++.dg/cpp0x/initlist55.C: New.
You can also review this at http://codereview.appspot.com/5330065/.
Property changes on: .
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk:r176665
Property changes on: libjava/classpath
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/libjava/classpath:r176665
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 180783)
+++ gcc/c-family/c.opt (working copy)
@@ -493,6 +493,10 @@
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
Property changes on: gcc/testsuite/gcc.target/powerpc/ppc-round.c
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/gcc/testsuite/gcc.target/powerpc/ppc-round.c:r176665
Index: gcc/testsuite/g++.dg/cpp0x/initlist5.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist5.C (revision 180783)
+++ gcc/testsuite/g++.dg/cpp0x/initlist5.C (working copy)
@@ -1,5 +1,5 @@
// Test for narrowing diagnostics
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
#include <initializer_list>
Index: gcc/testsuite/g++.dg/cpp0x/initlist7.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist7.C (revision 180783)
+++ gcc/testsuite/g++.dg/cpp0x/initlist7.C (working copy)
@@ -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;
Index: gcc/testsuite/g++.dg/cpp0x/initlist17.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist17.C (revision 180783)
+++ gcc/testsuite/g++.dg/cpp0x/initlist17.C (working copy)
@@ -1,4 +1,4 @@
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
void f(int i);
Index: gcc/testsuite/g++.dg/cpp0x/initlist36.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist36.C (revision 180783)
+++ gcc/testsuite/g++.dg/cpp0x/initlist36.C (working copy)
@@ -1,5 +1,5 @@
// PR c++/44358
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
#include <initializer_list>
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c (revision 180783)
+++ gcc/cp/typeck2.c (working copy)
@@ -733,7 +733,7 @@
bool ok = true;
REAL_VALUE_TYPE d;
- if (!ARITHMETIC_TYPE_P (type))
+ if (!warn_narrowing || !ARITHMETIC_TYPE_P (type))
return;
init = maybe_constant_value (init);
@@ -781,8 +781,8 @@
}
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
Property changes on: gcc/config/rs6000/rs6000.c
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/gcc/config/rs6000/rs6000.c:r176665
Property changes on: gcc/config/rs6000/rs6000.h
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/gcc/config/rs6000/rs6000.h:r176665