]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: set TREE_NOTHROW after genericize
authorJason Merrill <jason@redhat.com>
Mon, 31 Oct 2022 17:38:41 +0000 (13:38 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 1 Nov 2022 01:23:17 +0000 (21:23 -0400)
genericize might introduce function calls (and does on the contracts
branch), so it's safer to set this flag later.

gcc/cp/ChangeLog:

* decl.cc (finish_function): Set TREE_NOTHROW later in the function.

gcc/cp/decl.cc

index 87cb7a6c3a41992b45a5eeeef6e6132c92f3ba63..6e98ea35a394b7a96c65f6dedefa08dda1d8187d 100644 (file)
@@ -17867,14 +17867,6 @@ finish_function (bool inline_p)
 
   finish_fname_decls ();
 
-  /* If this function can't throw any exceptions, remember that.  */
-  if (!processing_template_decl
-      && !cp_function_chain->can_throw
-      && !flag_non_call_exceptions
-      && !decl_replaceable_p (fndecl,
-                             opt_for_fn (fndecl, flag_semantic_interposition)))
-    TREE_NOTHROW (fndecl) = 1;
-
   /* This must come after expand_function_end because cleanups might
      have declarations (from inline functions) that need to go into
      this function's blocks.  */
@@ -18099,6 +18091,14 @@ finish_function (bool inline_p)
       && !DECL_OMP_DECLARE_REDUCTION_P (fndecl))
     cp_genericize (fndecl);
 
+  /* If this function can't throw any exceptions, remember that.  */
+  if (!processing_template_decl
+      && !cp_function_chain->can_throw
+      && !flag_non_call_exceptions
+      && !decl_replaceable_p (fndecl,
+                             opt_for_fn (fndecl, flag_semantic_interposition)))
+    TREE_NOTHROW (fndecl) = 1;
+
   /* Emit the resumer and destroyer functions now, providing that we have
      not encountered some fatal error.  */
   if (coro_emit_helpers)