+2018-03-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84854
+       * semantics.c (finish_if_stmt_cond): Check if the type of the condition
+       is boolean.
+
 2018-03-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/81311 - wrong C++17 overload resolution.
 
   if (IF_STMT_CONSTEXPR_P (if_stmt)
       && !type_dependent_expression_p (cond)
       && require_constant_expression (cond)
-      && !value_dependent_expression_p (cond))
+      && !value_dependent_expression_p (cond)
+      /* Wait until instantiation time, since only then COND has been
+        converted to bool.  */
+      && TREE_TYPE (cond) == boolean_type_node)
     {
       cond = instantiate_non_dependent_expr (cond);
       cond = cxx_constant_value (cond, NULL_TREE);
 
+2018-03-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84854
+       * g++.dg/cpp1z/constexpr-if15.C: New test.
+       * g++.dg/cpp1z/constexpr-if16.C: New test.
+
 2018-03-21  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/builtin-tgmath-3.c: New test.
 
--- /dev/null
+// PR c++/84854
+// { dg-options -std=c++17 }
+
+constexpr int foo () { return 1; }
+constexpr int foo (int) { return 2; }
+
+template <typename>
+void a()
+{
+  if constexpr(foo) { };
+}
 
--- /dev/null
+// { dg-options -std=c++17 }
+
+struct A
+{
+  constexpr operator bool () { return true; }
+  int i;
+};
+
+A a;
+
+template <class T> void f()
+{
+  constexpr bool b = a;
+  if constexpr (a) { }
+}
+
+int main()
+{
+  f<int>();
+}