forked from OSchip/llvm-project
Allow __attribute__((unused)) for fields and make it silence
-Wunused-private-field. llvm-svn: 158411
This commit is contained in:
parent
f0273603f5
commit
429c134d5d
|
@ -1610,7 +1610,7 @@ static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
|||
}
|
||||
|
||||
if (!isa<VarDecl>(D) && !isa<ObjCIvarDecl>(D) && !isFunctionOrMethod(D) &&
|
||||
!isa<TypeDecl>(D) && !isa<LabelDecl>(D)) {
|
||||
!isa<TypeDecl>(D) && !isa<LabelDecl>(D) && !isa<FieldDecl>(D)) {
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
|
||||
<< Attr.getName() << ExpectedVariableFunctionOrLabel;
|
||||
return;
|
||||
|
|
|
@ -1646,6 +1646,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
|
|||
// effects and are not part of a dependent type declaration.
|
||||
if (!FD->isImplicit() && FD->getDeclName() &&
|
||||
FD->getAccess() == AS_private &&
|
||||
!FD->hasAttr<UnusedAttr>() &&
|
||||
!FD->getParent()->getTypeForDecl()->isDependentType() &&
|
||||
!InitializationHasSideEffects(*FD))
|
||||
UnusedPrivateFields.insert(FD);
|
||||
|
|
|
@ -115,6 +115,8 @@ class A {
|
|||
Trivial user_constructor_;
|
||||
NonTrivialConstructor non_trivial_constructor_;
|
||||
NonTrivialDestructor non_trivial_destructor_;
|
||||
|
||||
int attr_ __attribute__((unused));
|
||||
};
|
||||
|
||||
class EverythingUsed {
|
||||
|
|
Loading…
Reference in New Issue