[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute
authorNathan Chancellor <nathan@kernel.org>
Mon, 5 Jun 2023 17:49:41 +0000 (10:49 -0700)
committerNathan Chancellor <nathan@kernel.org>
Mon, 5 Jun 2023 17:54:47 +0000 (10:54 -0700)
commit877210faa447f4cc7db87812f8ed80e398fedd61
treeb682728aa375dd558c2a1fa80c7c6e10baf644f1
parent9959cdb66a02b50e29f4635b65c59a422f7b11c7
[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

A variable declared with __attribute__((cleanup)) cannot be unused, as
its address is passed to the clean up function. Do not emit
-Wunused-variable for variables declared with the cleanup attribute,
which matches GCC's behavior: https://godbolt.org/z/dz5YfTsan

Reviewed By: erichkeane, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D152180
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/warn-unused-variables.c