https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95616

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<ia...@gcc.gnu.org>:

https://gcc.gnu.org/g:00f703000fea2e8384f643413b53baa66ec4ddc2

commit r10-9513-g00f703000fea2e8384f643413b53baa66ec4ddc2
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Mon Feb 15 17:11:31 2021 +0000

    coroutines : Do not accept throwing final await expressions [PR95616].

    From the PR:

    The wording of [dcl.fct.def.coroutine]/15 states:
     * The expression co_await promise.final_suspend() shall not be
       potentially-throwing ([except.spec]).

    See http://eel.is/c++draft/dcl.fct.def.coroutine#15
    and http://eel.is/c++draft/except.spec#6

    ie. all of the following must be declared noexcept (if they form part of
the await-expression):
    - promise_type::final_suspend()
    - finalSuspendObj.operator co_await()
    - finalSuspendAwaiter.await_ready()
    - finalSuspendAwaiter.await_suspend()
    - finalSuspendAwaiter.await_resume()
    - finalSuspedObj destructor
    - finalSuspendAwaiter destructor

    This implements the checks for these cases and rejects such code with
    a diagnostic if exceptions are enabled.

            Backported from 9ee91079fd5879cba046e452ab5593372166b2ab and
            4e252e23d34932f13f39cc6544bf5c9379fa2a87

    gcc/cp/ChangeLog:

            PR c++/95616
            * coroutines.cc (coro_diagnose_throwing_fn): New helper.
            (coro_diagnose_throwing_final_aw_expr): New helper.
            (build_co_await): Diagnose throwing final await expression
            components. Look through NOP_EXPRs inbuild_special_member_call
            return value to find the CALL_EXPR. Simplify.
            (build_init_or_final_await): Diagnose a throwing promise
            final_suspend() call.

    gcc/testsuite/ChangeLog:

            PR c++/95616
            * g++.dg/coroutines/pr95616-0-no-exceptions.C: New test.
            * g++.dg/coroutines/pr95616-0.C: New test.
            * g++.dg/coroutines/pr95616-1-no-exceptions.C: New test.
            * g++.dg/coroutines/pr95616-1.C: New test.
            * g++.dg/coroutines/pr95616-2.C: New test.
            * g++.dg/coroutines/pr95616-3-no-exceptions.C: New test.
            * g++.dg/coroutines/pr95616-3.C: New test.
            * g++.dg/coroutines/pr95616-4.C: New test.
            * g++.dg/coroutines/pr95616-5.C: New test.
            * g++.dg/coroutines/pr95616-6.C: New test.

    Co-authored-by: Jakub Jelinek  <ja...@redhat.com>

Reply via email to