PR c++/71121 - -Waddress, constexpr, and PMFs.
authorJason Merrill <jason@redhat.com>
Thu, 21 Jul 2016 06:05:33 +0000 (02:05 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 Jul 2016 06:05:33 +0000 (02:05 -0400)
* cp-gimplify.c (cp_fully_fold): First call maybe_constant_value.

From-SVN: r238559

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/g++.dg/warn/Waddress-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/overflow-warn-7.C [deleted file]

index 87dcaa82616ea62525915119871511ec59783a37..8ff7f758c992f5c94ccb1aa241245a06ba9c8f70 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/71121
+       * cp-gimplify.c (cp_fully_fold): First call maybe_constant_value.
+
 2016-07-21  Andrew Sutton  <andrew.n.sutton@gmail.com>
            Jason Merrill  <jason@redhat.com>
 
index 41ab35f8ede03c119fb4bd0aa0aad5571edd3dd9..ee28ba5738f98bfb2c42e27e5e6984544ba11633 100644 (file)
@@ -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 (file)
index 0000000..a9fdfc4
--- /dev/null
@@ -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 (file)
index b536563..0000000
+++ /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<int>(e));
-}
-
-int main()
-{
-  int val = ~E_val;   // { dg-bogus "overflow in implicit constant conversion" }
-  (void) val;
-}