[PATCH] D83681: [clang] Provide a more specific diagnostic for a misplaced lambda capture-default.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 15 05:05:03 PDT 2020


aaron.ballman added inline comments.


================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:937
+      return Invalid([&] {
+        Diag(Tok.getLocation(), diag::err_capture_default_first);
+      });
----------------
Would it make sense to provide a fix-it to move the capture default to the start of the list automatically, or is that a pain?


================
Comment at: clang/test/Parser/lambda-misplaced-capture-default.cpp:11
+
+  [i, &] {}; // expected-error {{capture default must be first}}
+  [i, = ] {}; // expected-error {{capture default must be first}}
----------------
Can you also add a test showing that `[=, &i]` continues to behave properly (to test the `&]` checking logic)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83681/new/

https://reviews.llvm.org/D83681





More information about the cfe-commits mailing list