From 15c2ccbac51d3e17c4524946bbf1ee44c6e7f811 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 22 Jul 2011 20:30:13 -0400 Subject: [PATCH] * doc/invoke.texi (C++ Dialect Options): Document -Wno-narrowing. From-SVN: r176670 --- gcc/ChangeLog | 4 ++++ gcc/doc/invoke.texi | 12 ++++++++++++ gcc/testsuite/g++.dg/cpp0x/initlist55.C | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist55.C 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 }; -- 2.30.2