[clang] [Clang] prevent setting default lexical access specifier for missing primary declarations (PR #112424)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 22:18:34 PDT 2024


================
@@ -39,7 +39,8 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
                                     AccessSpecifier LexicalAS) {
   if (!PrevMemberDecl) {
     // Use the lexical access specifier.
-    MemberDecl->setAccess(LexicalAS);
----------------
shafik wrote:

I feel like we should be catching this in `Sema::ActOnTag` here:

https://github.com/llvm/llvm-project/blob/b49701085414838deb0213b9f10b68d9d3af6b0a/clang/lib/Sema/SemaDecl.cpp#L17938-L17951

It looks like we are not b/c `TUK` is `TUK_Declataion` but we should not be forward declaring here either. 

The current diagnostic does not fit this case though and maybe it has to be tweaked some more.

CC @AaronBallman 

https://github.com/llvm/llvm-project/pull/112424


More information about the cfe-commits mailing list