The compiler should not warn on code such as:
class [[maybe_unused]] MaybeUnusedClass {};
class C {
  MaybeUnusedClass c;
};Patch based on comments on the bug by Shafik and Aaron.
Fixes #61334
 Differential  D159083  
Clang: Don't warn about unused private fields of types declared maybe_unused Authored by hans on Aug 29 2023, 4:32 AM. 
Details The compiler should not warn on code such as: class [[maybe_unused]] MaybeUnusedClass {};
class C {
  MaybeUnusedClass c;
};Patch based on comments on the bug by Shafik and Aaron. Fixes #61334 
Diff Detail 
 Event TimelineComment Actions Thank you for working on this! Mostly looks good, but I did have another test request. Also, please be sure to add a release note for the fix. 
 Comment Actions Add release note. 
 
 
 Comment Actions LGTM! 
 Comment Actions Thanks! I filed https://github.com/llvm/llvm-project/issues/65111 to track the template instantiation concerns  | ||||||||||||||||||||||||||||||
Let's try one more thing:
template <typename Ty, typename Uy> class C2 { Ty c; // no-warning Uy d; // warning }; class [[maybe_unused]] Good {}; class Bad {}; C2<Good, Bad> c;