Alternate fix to PR12248: put Sema in charge of special-casing
the diagnostic for assigning to a copied block capture. This has
the pleasant side-effect of letting us special-case the diagnostic
for assigning to a copied lambda capture as well, without introducing
a new non-modifiable enumerator for it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152593 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index 99fc0ca..80ba0a1 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -139,3 +139,12 @@
unsigned int result = 0;
auto l = [&]() { ++result; };
}
+
+namespace ModifyingCapture {
+ void test() {
+ int n = 0;
+ [=] {
+ n = 1; // expected-error {{variable is not assignable (captured by copy)}}
+ };
+ }
+}