+2018-04-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85356 - ICE with pointer to member function.
+       * pt.c (maybe_instantiate_noexcept): Do instantiate in templates if
+       flag_noexcept_type.  Build the new spec within the function context.
+       * except.c (build_noexcept_spec): Do get constant value in templates
+       if flag_noexcept_type.
+       * decl.c (check_redeclaration_exception_specification): Don't
+       instantiate noexcept on a dependent declaration.
+
 2018-04-12  Marek Polacek  <polacek@redhat.com>
 
        PR c++/85258
 
       && UNEVALUATED_NOEXCEPT_SPEC_P (old_exceptions))
     return;
 
-  maybe_instantiate_noexcept (new_decl);
-  maybe_instantiate_noexcept (old_decl);
+  if (!type_dependent_expression_p (old_decl))
+    {
+      maybe_instantiate_noexcept (new_decl);
+      maybe_instantiate_noexcept (old_decl);
+    }
   new_exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (new_decl));
   old_exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl));
 
 
 {
   /* This isn't part of the signature, so don't bother trying to evaluate
      it until instantiation.  */
-  if (!processing_template_decl && TREE_CODE (expr) != DEFERRED_NOEXCEPT)
+  if (TREE_CODE (expr) != DEFERRED_NOEXCEPT
+      && (!processing_template_decl
+         || (flag_noexcept_type && !value_dependent_expression_p (expr))))
     {
       expr = perform_implicit_conversion_flags (boolean_type_node, expr,
                                                complain,
                                                LOOKUP_NORMAL);
+      expr = instantiate_non_dependent_expr (expr);
       expr = cxx_constant_value (expr);
     }
   if (TREE_CODE (expr) == INTEGER_CST)
 
   tree fntype, spec, noex, clone;
 
   /* Don't instantiate a noexcept-specification from template context.  */
-  if (processing_template_decl)
+  if (processing_template_decl
+      && (!flag_noexcept_type || type_dependent_expression_p (fn)))
     return true;
 
   if (DECL_CLONED_FUNCTION_P (fn))
                                        tf_warning_or_error, fn,
                                        /*function_p=*/false,
                                        /*integral_constant_expression_p=*/true);
+         spec = build_noexcept_spec (noex, tf_warning_or_error);
          pop_deferring_access_checks ();
          pop_access_scope (fn);
          pop_tinst_level ();
-         spec = build_noexcept_spec (noex, tf_warning_or_error);
          if (spec == error_mark_node)
            spec = noexcept_false_spec;
        }
 
--- /dev/null
+// PR c++/85356
+
+struct A
+{
+  A& operator=(int);
+};
+
+void foo(A&(A::*)(int));
+
+template<int> void bar()
+{
+  foo(&A::operator=);
+}