From: Jason Merrill Date: Thu, 21 Jul 2016 06:05:33 +0000 (-0400) Subject: PR c++/71121 - -Waddress, constexpr, and PMFs. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e96fe88c518ddc2d8917355d1781de3f8714c348;p=gcc.git PR c++/71121 - -Waddress, constexpr, and PMFs. * cp-gimplify.c (cp_fully_fold): First call maybe_constant_value. From-SVN: r238559 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 87dcaa82616..8ff7f758c99 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-07-21 Jason Merrill + + PR c++/71121 + * cp-gimplify.c (cp_fully_fold): First call maybe_constant_value. + 2016-07-21 Andrew Sutton Jason Merrill diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 41ab35f8ede..ee28ba5738f 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1954,6 +1954,11 @@ cxx_omp_disregard_value_expr (tree decl, bool shared) tree cp_fully_fold (tree x) { + if (processing_template_decl) + return x; + /* FIXME cp_fold ought to be a superset of maybe_constant_value so we don't + have to call both. */ + x = maybe_constant_value (x); return cp_fold (x); } diff --git a/gcc/testsuite/g++.dg/warn/Waddress-4.C b/gcc/testsuite/g++.dg/warn/Waddress-4.C new file mode 100644 index 00000000000..a9fdfc48b4d --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Waddress-4.C @@ -0,0 +1,15 @@ +// PR c++/71121 +// { dg-do compile { target c++14 } } +// { dg-options -Waddress } + +struct CC { void mbr(); }; + +constexpr auto getFunc() { + return &CC::mbr; +} + +constexpr bool xxx(void (CC::*_a)()) +{ + constexpr auto f = getFunc(); + return (f == _a); +} diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-7.C b/gcc/testsuite/g++.dg/warn/overflow-warn-7.C deleted file mode 100644 index b536563b637..00000000000 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-7.C +++ /dev/null @@ -1,17 +0,0 @@ -// PR c/62096 - unexpected warning overflow in implicit constant conversion -// { dg-do compile { target c++11 } } - -enum E { - E_val = 1, -}; - -inline constexpr E operator~(E e) -{ - return E(~static_cast(e)); -} - -int main() -{ - int val = ~E_val; // { dg-bogus "overflow in implicit constant conversion" } - (void) val; -}