+2018-10-10 Marek Polacek <polacek@redhat.com>
+
+ PR c++/87567 - constexpr rejects call to non-constexpr function.
+ * constexpr.c (potential_constant_expression_1) <case FOR_STMT>: Return
+ true if the condition is always false.
+ <case WHILE_STMT>: Likewise.
+
2018-10-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84423
case FOR_STMT:
if (!RECUR (FOR_INIT_STMT (t), any))
return false;
- if (!RECUR (FOR_COND (t), rval))
+ tmp = FOR_COND (t);
+ if (!RECUR (tmp, rval))
return false;
+ if (tmp)
+ {
+ if (!processing_template_decl)
+ tmp = cxx_eval_outermost_constant_expr (tmp, true);
+ if (integer_zerop (tmp))
+ return true;
+ }
if (!RECUR (FOR_EXPR (t), any))
return false;
if (!RECUR (FOR_BODY (t), any))
return true;
case WHILE_STMT:
- if (!RECUR (WHILE_COND (t), rval))
+ tmp = WHILE_COND (t);
+ if (!RECUR (tmp, rval))
return false;
+ if (!processing_template_decl)
+ tmp = cxx_eval_outermost_constant_expr (tmp, true);
+ if (integer_zerop (tmp))
+ return true;
if (!RECUR (WHILE_BODY (t), any))
return false;
if (breaks (jump_target) || continues (jump_target))
+2018-10-10 Marek Polacek <polacek@redhat.com>
+
+ PR c++/87567 - constexpr rejects call to non-constexpr function.
+ * g++.dg/cpp1y/constexpr-loop7.C: New test.
+
2018-10-10 Paul A. Clarke <pc@us.ibm.com>
PR target/87579
--- /dev/null
+// PR c++/87567
+// { dg-do compile { target c++14 } }
+
+constexpr bool always_false() { return false; }
+int f() { return 1; }
+
+constexpr int
+fn1 ()
+{
+ while (always_false ())
+ return f();
+ return 0;
+}
+
+constexpr int
+fn2 ()
+{
+ for (;always_false();)
+ return f();
+ return 0;
+}