Commit 2821fc6b by Paolo Carlini Committed by Paolo Carlini

re PR c++/65801 (Allow -Wno-narrowing to silence stricter C++11 narrowing rules)

/cp
2015-04-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/65801
	* typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing
	suppresses the diagnostic.

2015-04-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/65801
	* doc/invoke.texi ([-Wnarrowing]): Update.

/testsuite
2015-04-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/65801
	* g++.dg/cpp0x/Wnarrowing2.C: New.

From-SVN: r222249
parent 0cfabb37
2015-04-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65801
* doc/invoke.texi ([-Wnarrowing]): Update.
2015-04-20 Jeff Law <law@redhat.com> 2015-04-20 Jeff Law <law@redhat.com>
PR tree-optimization/65658 PR tree-optimization/65658
......
2015-04-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65801
* typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing
suppresses the diagnostic.
2015-04-20 Ville Voutilainen <ville.voutilainen@gmail.com> 2015-04-20 Ville Voutilainen <ville.voutilainen@gmail.com>
Reject trailing return type for an operator auto(). Reject trailing return type for an operator auto().
......
...@@ -957,9 +957,13 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain) ...@@ -957,9 +957,13 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain)
} }
} }
else if (complain & tf_error) else if (complain & tf_error)
error_at (EXPR_LOC_OR_LOC (init, input_location), {
global_dc->pedantic_errors = 1;
pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
"narrowing conversion of %qE from %qT to %qT inside { }", "narrowing conversion of %qE from %qT to %qT inside { }",
init, ftype, type); init, ftype, type);
global_dc->pedantic_errors = flag_pedantic_errors;
}
} }
return cxx_dialect == cxx98 || ok; return cxx_dialect == cxx98 || ok;
......
...@@ -2706,10 +2706,10 @@ int i = @{ 2.2 @}; // error: narrowing from double to int ...@@ -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}. This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
With @option{-std=c++11}, @option{-Wno-narrowing} suppresses for With @option{-std=c++11}, @option{-Wno-narrowing} suppresses the diagnostic
non-constants the diagnostic required by the standard. Note that this required by the standard. Note that this does not affect the meaning
does not affect the meaning of well-formed code; narrowing conversions of well-formed code; narrowing conversions are still considered
are still considered ill-formed in SFINAE context. ill-formed in SFINAE context.
@item -Wnoexcept @r{(C++ and Objective-C++ only)} @item -Wnoexcept @r{(C++ and Objective-C++ only)}
@opindex Wnoexcept @opindex Wnoexcept
......
2015-04-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65801
* g++.dg/cpp0x/Wnarrowing2.C: New.
2015-04-20 Jeff Law <law@redhat.com> 2015-04-20 Jeff Law <law@redhat.com>
PR tree-optimization/65658 PR tree-optimization/65658
......
// PR c++/65801
// { dg-do compile { target c++11 } }
// { dg-options "-Wno-narrowing" }
static struct zai { unsigned int x; } x = {-1};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment