]> granicus.if.org Git - clang/commit
Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda call opera...
authorFaisal Vali <faisalv@yahoo.com>
Tue, 2 May 2017 20:56:34 +0000 (20:56 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Tue, 2 May 2017 20:56:34 +0000 (20:56 +0000)
commit3c98739502812e2b180c49505660ad6927d34286
tree9ced1f364eb4f0e06f5fb05a03a20c8b554891fd
parent0abbc389e00de0a36cdb5142b99ed9e4a2597895
Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda call operator specialization

When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda.

https://bugs.llvm.org/show_bug.cgi?id=32831

This patch was initially committed here: https://reviews.llvm.org/rL301735
Then reverted here: https://reviews.llvm.org/rL301916

The issue with the original patch was a failure to check that the closure type has been created within the LambdaScopeInfo before querying its DeclContext - instead of just assuming it has (silly!).  A reduced example such as this highlights the problem:
  struct X {
     int data;
     auto foo() { return [] { return [] -> decltype(data) { return 0; }; }; }
  };

When 'data' within decltype(data) tries to determine the type of 'this', none of the LambdaScopeInfo's have their closure types created at that point.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301972 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/cxx1z-lambda-star-this.cpp