rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

I don't think it's possible to check this in the way you're doing so here. In 
general, there's no way to know whether a constant expression will be part of a 
`typedef` declaration or function declaration until you've finished parsing it 
(when you're parsing the decl-specifiers in a declaration you don't know 
whether you're declaring a function or a variable, and the `typedef` keyword 
might appear later).

So I think you need a different approach here. How about tracking the set of 
contained lambdas on the `Declarator` and `DeclSpec` objects, and diagnose from 
`ActOnFunctionDeclarator` / `ActOnTypedefDeclarator` if the current expression 
evaluation context contains any lambdas? (Maybe when entering an expression 
evaluation context, pass an optional `SmallVectorImpl<Expr*>*` to `Sema` to 
collect the lambdas contained within the expression.)

There are some particularly "fun" cases to watch out for here:

  decltype([]{})
    a, // ok
    f(); // ill-formed

... that require us to track the lambdas in the `DeclSpec` separately from the 
lambdas in the `Declarator`.


Repository:
  rL LLVM

https://reviews.llvm.org/D28510



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to