This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute
ClosedPublic

Authored by nathanchance on Jun 5 2023, 10:43 AM.

Details

Summary

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

Diff Detail

Event Timeline

nathanchance created this revision.Jun 5 2023, 10:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 10:43 AM
nathanchance requested review of this revision.Jun 5 2023, 10:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 10:43 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
erichkeane accepted this revision.Jun 5 2023, 10:46 AM
This revision is now accepted and ready to land.Jun 5 2023, 10:46 AM
nickdesaulniers accepted this revision.Jun 5 2023, 10:46 AM

Thanks for the patch!

clang/test/Sema/warn-unused-variables.c
35

void return type

Change f4()'s return type to void (Nick)

nathanchance marked an inline comment as done.Jun 5 2023, 10:52 AM
This revision was landed with ongoing or failed builds.Jun 5 2023, 10:55 AM
This revision was automatically updated to reflect the committed changes.

I note I forgot to require a release note, so please add one of those (and make sure it gets incorporated in any cherry-pick that happens).

ojeda added a subscriber: ojeda.Jun 12 2023, 3:56 AM