Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Aaron Ballman via cfe-commits
On Thu, Jan 19, 2017 at 8:45 AM, Malcolm Parsons wrote: > On 19 January 2017 at 13:16, Aaron Ballman wrote: >> I wasn't thinking about that kind of odr-unuse when reviewing your >> patch, so I am starting to think that perhaps it's not worth >>

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 13:16, Aaron Ballman wrote: > I wasn't thinking about that kind of odr-unuse when reviewing your > patch, so I am starting to think that perhaps it's not worth > distinguishing unevaluated contexts or not in the diagnostic. :-( If > we could do it,

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Aaron Ballman via cfe-commits
On Thu, Jan 19, 2017 at 7:49 AM, Aaron Ballman wrote: > On Thu, Jan 19, 2017 at 4:37 AM, Malcolm Parsons > wrote: >> On 19 January 2017 at 03:47, Aaron Ballman wrote: >>> It is not used in an unevaluated context --

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 12:49, Aaron Ballman wrote: > You are correct, it is not an odr use. MSVC is wrong to require the capture. Should the warning be rephrased? -- Malcolm Parsons ___ cfe-commits mailing list

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Aaron Ballman via cfe-commits
On Thu, Jan 19, 2017 at 4:37 AM, Malcolm Parsons wrote: > On 19 January 2017 at 03:47, Aaron Ballman wrote: >> It is not used in an unevaluated context -- that is a bug. > > It is an evaluated expression, but is it odr-used? > > C++14

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 03:47, Aaron Ballman wrote: > It is not used in an unevaluated context -- that is a bug. It is an evaluated expression, but is it odr-used? C++14 [basic.def.odr] p3: A variable x whose name appears as a potentially-evaluated expression ex is

Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Aaron Ballman via cfe-commits
On Jan 18, 2017 7:34 PM, "Akira Hatanaka via Phabricator" < revi...@reviews.llvm.org> wrote: ahatanak added a comment. In https://reviews.llvm.org/D28467#649861, @krasin wrote: > This change makes Clang hardly incompatible with MSVC++. Consider the following program: > > #include > > int

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment. In https://reviews.llvm.org/D28467#649861, @krasin wrote: > This change makes Clang hardly incompatible with MSVC++. Consider the > following program: > > #include > > int main(void) { > const int kDelta = 1001; > auto g = [kDelta](int i) >

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment. MSVC's behaviour is discussed here: https://social.msdn.microsoft.com/Forums/SqlServer/en-US/4abf18bd-4ae4-4c72-ba3e-3b13e7909d5f/error-c2057-or-c3493-trying-to-use-an-integral-constant-expression-inside-a-lambda?forum=vclanguage and here:

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-18 Thread Ivan Krasin via Phabricator via cfe-commits
krasin added a comment. This change makes Clang hardly incompatible with MSVC++. Consider the following program: #include int main(void) { const int kDelta = 1001; auto g = [kDelta](int i) { printf("%d\n", i % kDelta); }; g(2);

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment. There are quite a few of them! Repository: rL LLVM https://reviews.llvm.org/D28467 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D28467#645348, @malcolm.parsons wrote: > http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/1122/steps/bootstrap%20clang/logs/stdio > > >

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment. IMO, you can go ahead and commit a fix that removes the captures, and the fix can be reviewed post-commit. I don't think you should revert this patch as you'll have to remove the captures anyway before reinstating this patch, so might as well do it now. Repository:

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment. http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/1122/steps/bootstrap%20clang/logs/stdio /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1116:17: error: lambda capture 'BitWidth' is not used

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL291905: [Sema] Add warning for unused lambda captures (authored by malcolm.parsons). Changed prior to commit: https://reviews.llvm.org/D28467?vs=84122=84305#toc Repository: rL LLVM

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86 + 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}} +

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86 + 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}} +

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86 + 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}} +

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86 + 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}} +

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM; this is an awesome new diagnostic, thank you for working on it! Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:26 + auto

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:26 + auto explicit_initialized_value_used = [j = 1] { return j + 1; }; + auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}} +

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 84122. malcolm.parsons marked 9 inline comments as done. malcolm.parsons added a comment. Improve warning message for use in unevaluated context. Initialise used flags in constructors. https://reviews.llvm.org/D28467 Files:

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:319 InGroup, DefaultIgnore; +def warn_unused_lambda_capture: Warning<"lambda capture %0 is not odr-used">, + InGroup, DefaultIgnore; We do not use the term "odr-use"

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-11 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 83942. malcolm.parsons marked 9 inline comments as done. malcolm.parsons added a comment. Change warning message. Check for side effects. Add tests for side effects. Add tests for decltype. Use const reference. Add . to comment. Remove unrelated

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-11 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:17 + auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; //

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments. Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:17 + auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; //

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-11 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons marked an inline comment as done. malcolm.parsons added inline comments. Comment at: include/clang/Sema/ScopeInfo.h:457 +/// lambda. +bool Used = false; + aaron.ballman wrote: > arphaman wrote: > > malcolm.parsons wrote: > > > Should this

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Sema/ScopeInfo.h:457 +/// lambda. +bool Used = false; + arphaman wrote: > malcolm.parsons wrote: > > Should this be moved into one of the `PointerIntPair`s? > I'm not sure.. If we needed

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments. Comment at: include/clang/Sema/ScopeInfo.h:457 +/// lambda. +bool Used = false; + malcolm.parsons wrote: > Should this be moved into one of the `PointerIntPair`s? I'm not sure.. If we needed other capturing information in

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-10 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 83792. malcolm.parsons added a comment. Use -Wno-unused-lambda-capture in existing tests. https://reviews.llvm.org/D28467 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/ScopeInfo.h

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment. I think that the patch would be neater if you add "-Wno-unused-lambda-capture" to the options for all of the tests that are modified by this patch in the CXX/ directory. This would avoid redundant `(void)` uses and ensure that the `(void)` uses won't interfere with

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-09 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 83624. malcolm.parsons added a comment. Don't warn in a dependent context. Remove spurious expected-warning. https://reviews.llvm.org/D28467 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments. Comment at: test/SemaCXX/uninitialized.cpp:1437 } else { -[fname]{}; +[fname] { (void)fname; }; // expected-warning {{lambda capture 'fname' is not used}} } I think that expected-warning shouldn't be used here as

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-09 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision. malcolm.parsons added reviewers: aaron.ballman, rsmith. malcolm.parsons added a subscriber: cfe-commits. Warn when a lambda explicitly captures something that is not used in its body. The warning is part of -Wunused and can be enabled with