[PATCH] D28510: Reinstate CWG1607 restrictions on lambdas appearing inside certain constant-expressions

Faisal Vali via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 26 09:14:18 PST 2017


faisalv updated this revision to Diff 85927.
faisalv added a comment.

I tried a different approach, not because I was convinced it was better, but because it seemed (at the time) a simpler tweak - I'm not sure it is robust enough - but would appreciate your thoughts on it.

The approach is predicated on the following:

- lambda expressions can only appear in types in a non-unevaluated context, within array brackets
- if we track within each parameter declarator, its parent function declarator, we can always get to the outer most declarator and if the outermost declarator has the form (ptr-op f)(...) it can not be a function declarator (but is a variable) - we can determine this without waiting for the recursion to complete (I set a special token on the declarator once we start parsing a parens declarator and the token is a ptr-operator)
- additionally we can check the context of the outermost declarator to ensure it is not within an alias-declaration or a template-argument

Based on the test cases, it seems to work well - but not sure if the test cases are exhaustive.
Also the patch needs some cleanup if we agree that this direction is worth pursuing (and not too fragile an approach).

Thanks!

Would appreciate feedback!


https://reviews.llvm.org/D28510

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28510.85927.patch
Type: text/x-patch
Size: 21603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170126/0a444353/attachment-0001.bin>


More information about the cfe-commits mailing list