]> granicus.if.org Git - clang/commit
C++14 init-capture: error out instead of crashing.
authorManman Ren <manman.ren@gmail.com>
Fri, 1 Jul 2016 22:27:16 +0000 (22:27 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 1 Jul 2016 22:27:16 +0000 (22:27 +0000)
commit9f8590177859cf3325c79e98e77d443ee1504cbf
tree9f15748fdc7d9f134366eff5066125bdea03e5d2
parent4e34e330b7b33e10832c9093b843f81dcea9ab22
C++14 init-capture: error out instead of crashing.

When we have template arguments, we have a function and a pattern, the variable
in init-capture belongs to the pattern decl when checking if the lhs of
"max = current" is modifiable:
  auto find = [max = init](auto current) {
    max = current;
  };

In function isReferenceToNonConstCapture, we handle the case where the decl
context for the variable is not part of the current context.

Instead of crashing, we emit an error message:
cannot assign to a variable captured by copy in a non-mutable lambda

rdar://26997922

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274392 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaExpr.cpp
test/SemaCXX/cxx1y-init-captures.cpp