diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 132c55cfc6d..0dc44cd87ca 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -10837,37 +10837,37 @@ treat_lvalue_as_rvalue_p (tree expr, bool return_p)
      parenthesized) id-expression that names an implicitly movable entity
      declared in the body or parameter-declaration-clause of the innermost
      enclosing function or lambda-expression, */
-  if (DECL_CONTEXT (retval) != current_function_decl)
-    return NULL_TREE;
   if (return_p)
     {
+      if (DECL_CONTEXT (retval) != current_function_decl)
+	return NULL_TREE;
       expr = move (expr);
       if (expr == error_mark_node)
 	return NULL_TREE;
       return set_implicit_rvalue_p (expr);
     }
 
-  /* if the operand of a throw-expression is a (possibly parenthesized)
-     id-expression that names an implicitly movable entity whose scope does not
-     extend beyond the compound-statement of the innermost try-block or
-     function-try-block (if any) whose compound-statement or ctor-initializer
-     encloses the throw-expression, */
+  /* if the id-expression (possibly parenthesized) is the operand of
+     a throw-expression, and names an implicitly movable entity that belongs
+     to a scope that does not contain the compound-statement of the innermost
+     lambda-expression, try-block, or function-try-block (if any) whose
+     compound-statement or ctor-initializer contains the throw-expression.  */
 
   /* C++20 added move on throw of parms.  */
   if (TREE_CODE (retval) == PARM_DECL && cxx_dialect < cxx20)
     return NULL_TREE;
 
   for (cp_binding_level *b = current_binding_level;
-       ; b = b->level_chain)
-    {
-      for (tree decl = b->names; decl; decl = TREE_CHAIN (decl))
-	if (decl == retval)
-	  return set_implicit_rvalue_p (move (expr));
-      if (b->kind == sk_function_parms
-	  || b->kind == sk_try
-	  || b->kind == sk_namespace)
+       b->kind != sk_namespace; b = b->level_chain)
+    if (b->kind == sk_try)
+      {
+	for (tree decl = b->names; decl; decl = TREE_CHAIN (decl))
+	  if (decl == retval)
+	    return set_implicit_rvalue_p (move (expr));
 	return NULL_TREE;
-    }
+      }
+
+  return set_implicit_rvalue_p (move (expr));
 }
 
 /* Warn about dubious usage of std::move (in a return statement, if RETURN_P
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae69.C b/gcc/testsuite/g++.dg/cpp0x/sfinae69.C
index 361e0b79ba2..60eba61165d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/sfinae69.C
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae69.C
@@ -15,7 +15,7 @@ constexpr bool is_throwable(...) { return false; }
 
 constexpr bool b = is_throwable<moveonly>(moveonly{});
 #if __cplusplus >= 202002L
-static_assert (b, "move from the function parameter"); // { dg-bogus "" "PR113853" { xfail c++20 } }
+static_assert (b, "move from the function parameter");
 #else
 static_assert (!b, "no move from the function parameter");
 #endif
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae70.C b/gcc/testsuite/g++.dg/cpp0x/sfinae70.C
new file mode 100644
index 00000000000..48ea70a61a4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae70.C
@@ -0,0 +1,16 @@
+// PR c++/113789
+// { dg-do compile { target c++11 } }
+
+struct AutoPtr {
+    AutoPtr() = default;
+    AutoPtr(AutoPtr&) {}
+};
+
+template<class T> auto f(T p, int) -> decltype(throw p, 1) = delete;
+template<class T> void f(T p, long);
+
+void
+g ()
+{
+  f (AutoPtr (), 42); // { dg-error "use of deleted function" "" { target c++20_down } }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae71.C b/gcc/testsuite/g++.dg/cpp0x/sfinae71.C
new file mode 100644
index 00000000000..2fefe5f70e0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae71.C
@@ -0,0 +1,17 @@
+// PR c++/113789
+// { dg-do compile { target c++11 } }
+// Like sfinae70.C but T&&.
+
+struct AutoPtr {
+    AutoPtr() = default;
+    AutoPtr(AutoPtr&) {}
+};
+
+template<class T> auto f(T&& p, int) -> decltype(throw p, 1) = delete;
+template<class T> void f(T p, long);
+
+void
+g ()
+{
+  f (AutoPtr (), 42); // { dg-error "use of deleted function" "" { target c++20_down } }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae72.C b/gcc/testsuite/g++.dg/cpp0x/sfinae72.C
new file mode 100644
index 00000000000..397cdbd8c23
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae72.C
@@ -0,0 +1,17 @@
+// PR c++/113789
+// { dg-do compile { target c++11 } }
+// Like sfinae70.C but ().
+
+struct AutoPtr {
+    AutoPtr() = default;
+    AutoPtr(AutoPtr&) {}
+};
+
+template<class T> auto f(T p, int) -> decltype(throw (p), 1) = delete;
+template<class T> void f(T p, long);
+
+void
+g ()
+{
+  f (AutoPtr (), 42); // { dg-error "use of deleted function" "" { target c++20_down } }
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/implicit-move4.C b/gcc/testsuite/g++.dg/cpp2a/implicit-move4.C
new file mode 100644
index 00000000000..af4f62e5c7f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/implicit-move4.C
@@ -0,0 +1,59 @@
+// PR c++/113853
+// { dg-do compile { target c++20 } }
+
+struct X {
+  X();
+  X(const X&);
+  X(X&&) = delete;
+};
+
+void
+f1 ()
+{
+  try {
+    ;
+  } catch (X x) {
+    throw x; // { dg-error "use of deleted function" }
+  }
+}
+
+void
+f2 (X x)
+try {
+  ;
+} catch (...) {
+  throw x;  // { dg-error "use of deleted function" }
+}
+
+void
+f3 ()
+try {
+  X x;
+  throw x;  // { dg-error "use of deleted function" }
+} catch (...) {
+}
+
+void
+f4 (X x)
+try {
+  throw x;
+} catch (...) {
+}
+
+void
+f5 (X x)
+{
+  void g (decltype(throw x, true));	// { dg-error "use of deleted function|expected" }
+}
+
+// The "expected" shouldn't be here, c++/113924.
+void
+f6 (X x, int = decltype(throw x, true){}) // { dg-error "use of deleted function|expected" }
+{
+}
+
+void
+f7 (X x)
+{
+  [&] { throw x; };
+}
