Commit 72f382fb by Paolo Carlini Committed by Paolo Carlini

re PR c++/69872 (-Wnarrowing note without warning/errror)

/cp
2016-05-24  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/69872
	* typeck2.c (check_narrowing): Check pedwarn return value.

/testsuite
2016-05-24  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/69872
	* g++.dg/warn/Wno-narrowing1.C: New.

From-SVN: r236651
parent ef2ec9d9
2016-05-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69872
* typeck2.c (check_narrowing): Check pedwarn return value.
2016-05-24 Jakub Jelinek <jakub@redhat.com> 2016-05-24 Jakub Jelinek <jakub@redhat.com>
PR c++/71257 PR c++/71257
......
...@@ -950,10 +950,12 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain) ...@@ -950,10 +950,12 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain)
{ {
if (complain & tf_warning_or_error) if (complain & tf_warning_or_error)
{ {
if (!almost_ok || pedantic) if ((!almost_ok || pedantic)
pedwarn (loc, OPT_Wnarrowing, "narrowing conversion of %qE " && pedwarn (loc, OPT_Wnarrowing,
"from %qT to %qT inside { }", init, ftype, type); "narrowing conversion of %qE "
if (pedantic && almost_ok) "from %qT to %qT inside { }",
init, ftype, type)
&& almost_ok)
inform (loc, " the expression has a constant value but is not " inform (loc, " the expression has a constant value but is not "
"a C++ constant-expression"); "a C++ constant-expression");
ok = true; ok = true;
......
2016-05-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69872
* g++.dg/warn/Wno-narrowing1.C: New.
2016-05-24 Marek Polacek <polacek@redhat.com> 2016-05-24 Marek Polacek <polacek@redhat.com>
PR c/71249 PR c/71249
......
// PR c++/69872
// { dg-options "-Wall -Wextra -pedantic -Wno-narrowing" }
struct s { int x, y; };
short offsets[1] = {
((char*) &(((struct s*)16)->y) - (char *)16), // { dg-bogus "note" }
};
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