https://reviews.llvm.org/D59076 added a new coroutine error that
prevented users from using 'co_await' or 'co_yield' within a exception
handler. However, it was reverted in https://reviews.llvm.org/rC356774
because it caused a regression in nested scopes in C++ catch statements,
as documented by https://bugs.llvm.org/show_bug.cgi?id=41171.
The issue was due to an incorrect use of a clang::ParseScope. To fix:
- Add a regression test for catch statement parsing that mimics the bug report from https://bugs.llvm.org/show_bug.cgi?id=41171.
- Re-apply the coroutines error patch from https://reviews.llvm.org/D59076, but this time with the correct ParseScope behavior.
Just to make sure I understood the problem correctly, the issue was that you passed ScopeFlags to ParseCompoundStatement(). This override the default flags which are Scope::DeclScope | Scope::CompoundStmtScope. In particular now ParseCompoundStatement() was done as if in the controlling scope of an if statement. Now as per [basic.scope.block]/p4:
This caused the declaration in the compound statement to be detected as erroneous. Indeed the following worked just fine.
Does this make sense or I am completely off base here ?