diff options
author | Jason Merrill <jason@gcc.gnu.org> | 2011-11-02 16:16:43 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-11-02 16:16:43 -0400 |
commit | 25339f1097a119662a4989964f32143ad44edbd3 (patch) | |
tree | 883396e26db08ff838de9608ab092c69fcce8870 /gcc/doc | |
parent | 24748eb48e44ae268686a795149edc03af0e4310 (diff) | |
download | gcc-25339f1097a119662a4989964f32143ad44edbd3.zip gcc-25339f1097a119662a4989964f32143ad44edbd3.tar.gz gcc-25339f1097a119662a4989964f32143ad44edbd3.tar.bz2 |
re PR c++/50810 (c++0x-compat does not warn about narrowing conversions)
PR c++/50810
gcc/c-family
* c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
Wnarrowing for C++0x and C++98.
* c.opt ([Wnarrowing]): Update.
gcc/cp
* typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
(digest_init_r): Call check_narrowing irrespective of the C++ dialect.
* decl.c (check_initializer): Likewise.
* semantics.c (finish_compound_literal): Likewise.
gcc/
* configure.ac: Add -Wno-narrowing to warning options.
libcpp/
* configure.ac: Add -Wno-narrowing to warning options.
From-SVN: r180794
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b68f607..d6c1faf 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2363,17 +2363,22 @@ 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)} +@item -Wnarrowing @r{(C++ and Objective-C++ only)} @opindex Wnarrowing @opindex Wno-narrowing -With -std=c++11, suppress the diagnostic required by the standard for -narrowing conversions within @samp{@{ @}}, e.g. +Warn when a narrowing conversion prohibited by C++11 occurs 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++11 mode. +This flag is included in @option{-Wall} and @option{-Wc++11-compat}. + +With -std=c++11, @option{-Wno-narrowing} suppresses the diagnostic +required by the standard. Note that this does not affect the meaning +of well-formed code; narrowing conversions are still considered +ill-formed in SFINAE context. @item -Wnoexcept @r{(C++ and Objective-C++ only)} @opindex Wnoexcept @@ -4062,9 +4067,10 @@ ISO C and ISO C++, e.g.@: request for implicit conversion from @code{void *} to a pointer to non-@code{void} type. @item -Wc++11-compat @r{(C++ and Objective-C++ only)} -Warn about C++ constructs whose meaning differs between ISO C++ 1998 and -ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that will become keywords -in ISO C++ 2011. This warning is enabled by @option{-Wall}. +Warn about C++ constructs whose meaning differs between ISO C++ 1998 +and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords +in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is +enabled by @option{-Wall}. @item -Wcast-qual @opindex Wcast-qual |