aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-07-22 20:14:46 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-07-22 20:14:46 -0400
commit76f86d00d99168e75b27d8e641844237c78ad102 (patch)
treeec438265c3481cd0c137ec1444b398d057b6cd01
parent295331a41988c2ecd818ba80f23c790e292fb296 (diff)
downloadgcc-76f86d00d99168e75b27d8e641844237c78ad102.zip
gcc-76f86d00d99168e75b27d8e641844237c78ad102.tar.gz
gcc-76f86d00d99168e75b27d8e641844237c78ad102.tar.bz2
re PR c++/49793 ([C++0x] Narrowing conversion from int/short/char to double)
PR c++/49793 * typeck2.c (check_narrowing): Downgrade permerror to pedwarn. Make conditional on -Wnarrowing. From-SVN: r176665
-rw-r--r--gcc/c-family/ChangeLog3
-rw-r--r--gcc/c-family/c.opt4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck2.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist17.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist36.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist5.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist52.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist7.C2
10 files changed, 26 insertions, 8 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 990302f..be7317d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -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.
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 00bdd93..617ea2d 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -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
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cdbb3fe..284224f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index bdd2452..727a88b 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a364c72..1d0d089 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist17.C b/gcc/testsuite/g++.dg/cpp0x/initlist17.C
index 86371e8..6ea08d1 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist17.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist17.C
@@ -1,4 +1,4 @@
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
void f(int i);
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist36.C b/gcc/testsuite/g++.dg/cpp0x/initlist36.C
index 94624c9..a703b45 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist36.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist36.C
@@ -1,5 +1,5 @@
// PR c++/44358
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
#include <initializer_list>
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist5.C b/gcc/testsuite/g++.dg/cpp0x/initlist5.C
index 32caac3..dbd17ec 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist5.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist5.C
@@ -1,5 +1,5 @@
// Test for narrowing diagnostics
-// { dg-options "-std=c++0x" }
+// { dg-options "-std=c++0x -pedantic-errors" }
#include <initializer_list>
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist52.C b/gcc/testsuite/g++.dg/cpp0x/initlist52.C
index 22bc287..17c0cfe 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist52.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist52.C
@@ -1,5 +1,5 @@
// PR c++/45378
-// { dg-options -std=c++0x }
+// { dg-options "-std=c++0x -pedantic-errors" }
int main()
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist7.C b/gcc/testsuite/g++.dg/cpp0x/initlist7.C
index 7913ed7..55a0371 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist7.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist7.C
@@ -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;