[PATCH] D59752: Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 24 16:02:49 PDT 2019


riccibruno added inline comments.


================
Comment at: lib/Parse/ParseStmt.cpp:2293
   // FIXME: Possible draft standard bug: attribute-specifier should be allowed?
   StmtResult Block(ParseCompoundStatement());
   if (Block.isInvalid())
----------------
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:

> Names declared in the init-statement, the for-range-declaration, and in the condition of if, while, for, and switch statements are local to the if, while, for, or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outermost blocks) of the controlled statement; see 9.4.

This caused the declaration in the compound statement to be detected as erroneous. Indeed the following worked just fine. 

```
void f() {
    try {}
    catch (...) {
        int i;
        {
            {
                int i;
            }
        }
    }
}
```

Does this make sense or I am completely off base here ?



Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59752/new/

https://reviews.llvm.org/D59752





More information about the cfe-commits mailing list