[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute
Nathan Chancellor via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 5 10:55:06 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG877210faa447: [Sema] Do not emit -Wunused-variable for variables declared with cleanup… (authored by nathanchance).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152180/new/
https://reviews.llvm.org/D152180
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/warn-unused-variables.c
Index: clang/test/Sema/warn-unused-variables.c
===================================================================
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
(void)(^() { int X = 4; }); // expected-warning{{unused}}
(void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
}
+
+void c1(int *);
+void f4(void) {
+ int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
return false;
}
- if (D->hasAttr<UnusedAttr>() || D->hasAttr<ObjCPreciseLifetimeAttr>())
+ if (D->hasAttr<UnusedAttr>() || D->hasAttr<ObjCPreciseLifetimeAttr>() ||
+ D->hasAttr<CleanupAttr>())
return false;
if (isa<LabelDecl>(D))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152180.528511.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230605/0ce9b6bb/attachment-0001.bin>
More information about the cfe-commits
mailing list