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
This commit is contained in:
Paolo Carlini 2016-05-24 16:41:39 +00:00 committed by Paolo Carlini
parent ef2ec9d9a2
commit 72f382fbb8
4 changed files with 23 additions and 4 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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;

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,7 @@
// 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" }
};