* doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing.
authorJason Merrill <jason@redhat.com>
Sat, 23 Jul 2011 00:30:13 +0000 (20:30 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 23 Jul 2011 00:30:13 +0000 (20:30 -0400)
From-SVN: r176670

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/testsuite/g++.dg/cpp0x/initlist55.C [new file with mode: 0644]

index 8cf9313d8ff04af3ee15f2ffb90fa2c0ab3f0dba..4481b4355fdc1be6f6afba740ba6a84832a887ab 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-22  Jason Merrill  <jason@redhat.com>
+
+       * doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing.
+
 2011-07-22  Richard Henderson  <rth@redhat.com>
 
        * bb-reorder.c (gate_handle_partition_blocks): Honor optimize.
index e56eeaa732b1bcdfd34d03bdc850b4c548bd2d34..7783786bb64a7475aa52b42cd6e8c0124d93602d 100644 (file)
@@ -2348,6 +2348,18 @@ an instance of a derived class through a pointer to a base class if the
 base class does not have a virtual destructor.  This warning is enabled
 by @option{-Wall}.
 
+@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
+@opindex Wnarrowing
+@opindex Wno-narrowing
+With -std=c++0x, suppress the diagnostic required by the standard for
+narrowing conversions within @samp{@{ @}}, e.g.
+
+@smallexample
+int i = @{ 2.2 @}; // error: narrowing from double to int
+@end smallexample
+
+This flag can be useful for compiling valid C++98 code in C++0x mode.
+
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept
 @opindex Wno-noexcept
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist55.C b/gcc/testsuite/g++.dg/cpp0x/initlist55.C
new file mode 100644 (file)
index 0000000..cb42e81
--- /dev/null
@@ -0,0 +1,5 @@
+// Test for -Wno-narrowing
+// { dg-options "-std=c++0x -pedantic-errors -Wno-narrowing" }
+
+int i;
+float d = { i };