From: Paolo Carlini Date: Mon, 20 Apr 2015 21:46:59 +0000 (+0000) Subject: re PR c++/65801 (Allow -Wno-narrowing to silence stricter C++11 narrowing rules) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2821fc6b76973dd6cb956229027e8e065a020424;p=gcc.git re PR c++/65801 (Allow -Wno-narrowing to silence stricter C++11 narrowing rules) /cp 2015-04-20 Paolo Carlini PR c++/65801 * typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing suppresses the diagnostic. 2015-04-20 Paolo Carlini PR c++/65801 * doc/invoke.texi ([-Wnarrowing]): Update. /testsuite 2015-04-20 Paolo Carlini PR c++/65801 * g++.dg/cpp0x/Wnarrowing2.C: New. From-SVN: r222249 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2262e09762d..659ac0133ab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-04-20 Paolo Carlini + + PR c++/65801 + * doc/invoke.texi ([-Wnarrowing]): Update. + 2015-04-20 Jeff Law PR tree-optimization/65658 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7da7c61b0d..91c389052c6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-04-20 Paolo Carlini + + PR c++/65801 + * typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing + suppresses the diagnostic. + 2015-04-20 Ville Voutilainen Reject trailing return type for an operator auto(). diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 80a693981b3..884957bc9bb 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -957,9 +957,13 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain) } } else if (complain & tf_error) - error_at (EXPR_LOC_OR_LOC (init, input_location), - "narrowing conversion of %qE from %qT to %qT inside { }", - init, ftype, type); + { + global_dc->pedantic_errors = 1; + pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, + "narrowing conversion of %qE from %qT to %qT inside { }", + init, ftype, type); + global_dc->pedantic_errors = flag_pedantic_errors; + } } return cxx_dialect == cxx98 || ok; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f5f79b81028..c20dd4d58cb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2706,10 +2706,10 @@ int i = @{ 2.2 @}; // error: narrowing from double to int This flag is included in @option{-Wall} and @option{-Wc++11-compat}. -With @option{-std=c++11}, @option{-Wno-narrowing} suppresses for -non-constants 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. +With @option{-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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e768f570bf4..8ffe2eac523 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-20 Paolo Carlini + + PR c++/65801 + * g++.dg/cpp0x/Wnarrowing2.C: New. + 2015-04-20 Jeff Law PR tree-optimization/65658 diff --git a/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C new file mode 100644 index 00000000000..fc806f955fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C @@ -0,0 +1,5 @@ +// PR c++/65801 +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-narrowing" } + +static struct zai { unsigned int x; } x = {-1};