[PATCH] D28902: [Sema] Reword unused lambda capture warning

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 09:30:28 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292498: [Sema] Reword unused lambda capture warning (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D28902?vs=84966&id=84984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28902

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -320,7 +320,7 @@
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup<UnusedPrivateField>, DefaultIgnore;
 def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
-  "%select{used|required to be captured for use in an unevaluated context}1">,
+  "%select{used|required to be captured for this use}1">,
   InGroup<UnusedLambdaCapture>, DefaultIgnore;
 
 def warn_parameter_size: Warning<
Index: cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
+++ cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -22,6 +22,7 @@
 
 void test() {
   int i = 0;
+  const int k = 0;
 
   auto captures_nothing = [] {};
 
@@ -34,8 +35,9 @@
   auto explicit_by_value_used = [i] { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
-  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
-  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}}
+  auto explicit_by_value_unused_const = [k] { return k + 1; };         // expected-warning{{lambda capture 'k' is not required to be captured for this use}}
 
   auto explicit_by_reference_used = [&i] { i++; };
   auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}}
@@ -70,6 +72,7 @@
 template <typename T>
 void test_templated() {
   int i = 0;
+  const int k = 0;
 
   auto captures_nothing = [] {};
 
@@ -82,8 +85,9 @@
   auto explicit_by_value_used = [i] { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
-  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}}
   auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not used}}
+  auto explicit_by_value_unused_const = [k] { return k + 1; };         // expected-warning{{lambda capture 'k' is not required to be captured for this use}}
 
   auto explicit_by_reference_used = [&i] { i++; };
   auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28902.84984.patch
Type: text/x-patch
Size: 3372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170119/f092e1c2/attachment.bin>


More information about the cfe-commits mailing list