From: Jason Merrill Date: Sat, 23 Jul 2011 00:30:13 +0000 (-0400) Subject: * doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15c2ccbac51d3e17c4524946bbf1ee44c6e7f811;p=gcc.git * doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing. From-SVN: r176670 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8cf9313d8ff..4481b4355fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2011-07-22 Jason Merrill + + * doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing. + 2011-07-22 Richard Henderson * bb-reorder.c (gate_handle_partition_blocks): Honor optimize. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e56eeaa732b..7783786bb64 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 index 00000000000..cb42e81ed6a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist55.C @@ -0,0 +1,5 @@ +// Test for -Wno-narrowing +// { dg-options "-std=c++0x -pedantic-errors -Wno-narrowing" } + +int i; +float d = { i };