diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -212,6 +212,8 @@ of FAM-like arrays. - Clang now correctly diagnoses a warning when defercencing a void pointer in C mode. This fixes `Issue 53631 `_ +- Clang now prints more readable identifier for anonymous class/struct of + ``-Wconsumed``. Non-comprehensive list of changes in this release ------------------------------------------------- diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1223,7 +1223,8 @@ if (const CXXRecordDecl *RD = ThisType->getAsCXXRecordDecl()) { if (!RD->hasAttr()) { - S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) << RD; + S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) + << S.Context.getTagDeclType(RD); return false; } diff --git a/clang/test/SemaCXX/warn-consumed-parsing.cpp b/clang/test/SemaCXX/warn-consumed-parsing.cpp --- a/clang/test/SemaCXX/warn-consumed-parsing.cpp +++ b/clang/test/SemaCXX/warn-consumed-parsing.cpp @@ -62,5 +62,10 @@ Status { }; - - +class Anonymous { + struct /* anonymous */ { + void callableWhen() CALLABLE_WHEN("unconsumed"); // expected-warning-re {{consumed analysis attribute is attached to member of class 'Anonymous::(unnamed struct at {{.*}})' which isn't marked as consumable}} + void consumes() SET_TYPESTATE(consumed); // expected-warning-re {{consumed analysis attribute is attached to member of class 'Anonymous::(unnamed struct at {{.*}})' which isn't marked as consumable}} + bool testUnconsumed() TEST_TYPESTATE(consumed); // expected-warning-re {{consumed analysis attribute is attached to member of class 'Anonymous::(unnamed struct at {{.*}})' which isn't marked as consumable}} + } anonymous; +};