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
>> distinguishing unevaluated contexts or not in the di
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, then great (we seem to be a
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 -- that is a bug.
>>
>> It is an evaluated expression, but is it odr-used?
>>
>> C++
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
cfe-commits@lists.llvm.org
http://lists.l
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 [basic.def.odr] p3:
>
> A variable x whose name appears as a p
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 odr-used by ex unless applying
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 ma
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)
>
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:
https://connect.microsof
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);
}
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
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
>
>
> /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTr
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:
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 [-Werro
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&id=84305#toc
Repository:
rL LLVM
https://review
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}}
+ aut
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}}
+ a
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}}
+ aut
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}}
+ a
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 explicit_initialized_va
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}}
+
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:
include/clang/Basic/Dia
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" i
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 commen
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); }; //
expected-wa
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); }; //
expected-warnin
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
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); }; //
expected-warnin
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 other
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 t
malcolm.parsons added inline comments.
Comment at: include/clang/Sema/ScopeInfo.h:457
+/// lambda.
+bool Used = false;
+
Should this be moved into one of the `PointerIntPair`s?
https://reviews.llvm.org/D28467
_
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
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 the
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
include/clan
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 you
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 -Wunused-lambda-ca
36 matches
Mail list logo