From: Paolo Carlini Date: Tue, 24 May 2016 16:41:39 +0000 (+0000) Subject: re PR c++/69872 (-Wnarrowing note without warning/errror) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=72f382fbb85a77a75e839077a7df59197799e2f4;p=gcc.git re PR c++/69872 (-Wnarrowing note without warning/errror) /cp 2016-05-24 Paolo Carlini PR c++/69872 * typeck2.c (check_narrowing): Check pedwarn return value. /testsuite 2016-05-24 Paolo Carlini PR c++/69872 * g++.dg/warn/Wno-narrowing1.C: New. From-SVN: r236651 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c77dee6dfb7..4e06a71e7ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-05-24 Paolo Carlini + + PR c++/69872 + * typeck2.c (check_narrowing): Check pedwarn return value. + 2016-05-24 Jakub Jelinek PR c++/71257 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 833be20f7fe..835a44f1cf6 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -950,10 +950,12 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain) { if (complain & tf_warning_or_error) { - if (!almost_ok || pedantic) - pedwarn (loc, OPT_Wnarrowing, "narrowing conversion of %qE " - "from %qT to %qT inside { }", init, ftype, type); - if (pedantic && almost_ok) + if ((!almost_ok || pedantic) + && pedwarn (loc, OPT_Wnarrowing, + "narrowing conversion of %qE " + "from %qT to %qT inside { }", + init, ftype, type) + && almost_ok) inform (loc, " the expression has a constant value but is not " "a C++ constant-expression"); ok = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2b2466903c..d27369c87f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-24 Paolo Carlini + + PR c++/69872 + * g++.dg/warn/Wno-narrowing1.C: New. + 2016-05-24 Marek Polacek PR c/71249 diff --git a/gcc/testsuite/g++.dg/warn/Wno-narrowing1.C b/gcc/testsuite/g++.dg/warn/Wno-narrowing1.C new file mode 100644 index 00000000000..285f05a1249 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wno-narrowing1.C @@ -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" } +};