]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix false positive with -Wunused [PR114450]
authorLucas Chollet <lucas.chollet@free.fr>
Mon, 26 Jan 2026 10:16:53 +0000 (18:16 +0800)
committerJason Merrill <jason@redhat.com>
Wed, 28 Jan 2026 02:31:00 +0000 (10:31 +0800)
commit04ec3d4712519e32f85c034ff4237fcd5f9fbe39
tree5ece5c90c9fd97818226a907ed15ed82802a633f
parentb0db0df2b2f8e152aca2c8d19643e259dab23cbb
c++: Fix false positive with -Wunused [PR114450]

The patch fixes a bug in the detection of the usage of static variables
inside generic lambdas.  The comment in finish_id_expression_1 already
mentions this case, but the code didn't actually handle it.

PR c++/114450

gcc/cp/ChangeLog:

* lambda.cc (generic_lambda_fn_p): Handle null argument.
* semantics.cc (finish_id_expression_1): Check for generic lambda.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wunused-var-42.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
gcc/cp/lambda.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/warn/Wunused-var-42.C [new file with mode: 0644]