From 46591a43afad65a53a294d0d9391e3a3093966f5 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 13 Mar 2012 01:10:51 +0000 Subject: [PATCH] Make the error about assigning to lambda-captured variables clearer, and mention the existence of mutable lambdas. llvm-svn: 152598 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +- clang/test/SemaCXX/lambda-expressions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index bdad36a982c7..d859f37ad00c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4388,7 +4388,7 @@ def err_typecheck_duplicate_vector_components_not_mlvalue : Error< def err_block_decl_ref_not_modifiable_lvalue : Error< "variable is not assignable (missing __block type specifier)">; def err_lambda_decl_ref_not_modifiable_lvalue : Error< - "variable is not assignable (captured by copy)">; + "cannot assign to a variable captured by copy in a non-mutable lambda">; def err_typecheck_call_not_function : Error< "called object type %0 is not a function or function pointer">; def err_call_incomplete_return : Error< diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index 80ba0a1d035b..e91dee92edb1 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -144,7 +144,7 @@ namespace ModifyingCapture { void test() { int n = 0; [=] { - n = 1; // expected-error {{variable is not assignable (captured by copy)}} + n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}} }; } }