diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-11 20:50:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-11 20:50:30 +0000 |
commit | 4261e4c3633fcb18fc4defe9cbd796b0e57decf1 (patch) | |
tree | 0e9e80e95cc0a3d494559431ec9192b5992e8a12 /clang/lib/Sema/SemaDecl.cpp | |
parent | 5202cc00364eaa34db7d45f2c9ae25bbf6f388a1 (diff) | |
download | bcm5719-llvm-4261e4c3633fcb18fc4defe9cbd796b0e57decf1.tar.gz bcm5719-llvm-4261e4c3633fcb18fc4defe9cbd796b0e57decf1.zip |
Make sure that we set the access specifier for an instantiated FieldDecl, and that the aggregate and POD flags for an instantiated class template are updated based on instantiation of a FieldDecl
llvm-svn: 66701
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f77d1d8845f..2e033bf907a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3253,14 +3253,16 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagD, SourceLocation DeclStart, Declarator &D, ExprTy *BitfieldWidth) { return HandleField(S, static_cast<RecordDecl*>(TagD), DeclStart, D, - static_cast<Expr*>(BitfieldWidth)); + static_cast<Expr*>(BitfieldWidth), + AS_public); } /// HandleField - Analyze a field of a C struct or a C++ data member. /// FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, SourceLocation DeclStart, - Declarator &D, Expr *BitWidth) { + Declarator &D, Expr *BitWidth, + AccessSpecifier AS) { IdentifierInfo *II = D.getIdentifier(); SourceLocation Loc = DeclStart; if (II) Loc = D.getIdentifierLoc(); @@ -3277,7 +3279,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, FieldDecl *NewFD = CheckFieldDecl(II, T, Record, Loc, D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable, - BitWidth, PrevDecl, &D); + BitWidth, AS, PrevDecl, &D); if (NewFD->isInvalidDecl() && PrevDecl) { // Don't introduce NewFD into scope; there's already something // with the same name in the same scope. @@ -3302,7 +3304,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitWidth, - NamedDecl *PrevDecl, + AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D) { IdentifierInfo *II = Name.getAsIdentifierInfo(); bool InvalidDecl = false; @@ -3364,6 +3366,19 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, if (InvalidDecl) NewFD->setInvalidDecl(); + NewFD->setAccess(AS); + + // C++ [dcl.init.aggr]p1: + // An aggregate is an array or a class (clause 9) with [...] no + // private or protected non-static data members (clause 11). + // A POD must be an aggregate. + if (getLangOptions().CPlusPlus && + (AS == AS_private || AS == AS_protected)) { + CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record); + CXXRecord->setAggregate(false); + CXXRecord->setPOD(false); + } + return NewFD; } |