Out << "<implicit parameter> " << IPD->getNameAsString() << "\n";
break;
}
- case Decl::CXXClassVar: {
- CXXClassVarDecl* CVD = cast<CXXClassVarDecl>(*I);
- Out << "<static member var> " << CVD->getNameAsString() << "\n";
- break;
- }
case Decl::ParmVar: {
ParmVarDecl* PVD = cast<ParmVarDecl>(*I);
Out << "<parameter> " << PVD->getNameAsString() << "\n";
case Typedef:
case EnumConstant:
case Var:
- case CXXClassVar:
case ImplicitParam:
case ParmVar:
case OriginalParmVar:
static CXXConversionDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
};
-/// CXXClassVarDecl - Represents a static data member of a struct/union/class.
-class CXXClassVarDecl : public VarDecl {
-
- CXXClassVarDecl(CXXRecordDecl *RD, SourceLocation L,
- IdentifierInfo *Id, QualType T)
- : VarDecl(CXXClassVar, RD, L, Id, T, None) {}
-public:
- static CXXClassVarDecl *Create(ASTContext &C, CXXRecordDecl *RD,
- SourceLocation L,IdentifierInfo *Id,
- QualType T);
-
- // Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) { return D->getKind() == CXXClassVar; }
- static bool classof(const CXXClassVarDecl *D) { return true; }
-
-protected:
- /// EmitImpl - Serialize this CXXClassVarDecl. Called by Decl::Emit.
- // FIXME: Implement this.
- //virtual void EmitImpl(llvm::Serializer& S) const;
-
- /// CreateImpl - Deserialize a CXXClassVarDecl. Called by Decl::Create.
- // FIXME: Implement this.
- static CXXClassVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
-
- friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
-};
-
-
/// CXXClassMemberWrapper - A wrapper class for C++ class member decls.
/// Common functions like set/getAccess are included here to avoid bloating
/// the interface of non-C++ specific decl classes, like NamedDecl.
DECL(ObjCAtDefsField, FieldDecl)
DECL(Var, ValueDecl)
DECL(ImplicitParam, VarDecl)
- DECL(CXXClassVar, VarDecl)
DECL(ParmVar, VarDecl)
DECL(OriginalParmVar, ParmVarDecl)
DECL(NonTypeTemplateParm, VarDecl)
return new (C) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
}
-CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
- SourceLocation L, IdentifierInfo *Id,
- QualType T) {
- return new (C) CXXClassVarDecl(RD, L, Id, T);
-}
-
OverloadedFunctionDecl *
OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
DeclarationName N) {
return LV_Valid;
// -- If E2 is a static data member [...] then E1.E2 is an lvalue.
- if (isa<CXXClassVarDecl>(Member))
+ if (isa<VarDecl>(Member) && Member->getDeclContext()->isRecord())
return LV_Valid;
// -- If E2 is a non-static data member [...]. If E1 is an
return 0;
}
- if (DC->isRecord()) {
- // This is a static data member for a C++ class.
- NewVD = CXXClassVarDecl::Create(Context, cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), II,
- R);
- } else {
- bool ThreadSpecified = D.getDeclSpec().isThreadSpecified();
- if (S->getFnParent() == 0) {
- // C99 6.9p2: The storage-class specifiers auto and register shall not
- // appear in the declaration specifiers in an external declaration.
- if (SC == VarDecl::Auto || SC == VarDecl::Register) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
- InvalidDecl = true;
- }
+ bool ThreadSpecified = D.getDeclSpec().isThreadSpecified();
+ if (!DC->isRecord() && S->getFnParent() == 0) {
+ // C99 6.9p2: The storage-class specifiers auto and register shall not
+ // appear in the declaration specifiers in an external declaration.
+ if (SC == VarDecl::Auto || SC == VarDecl::Register) {
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
+ InvalidDecl = true;
}
- NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
- II, R, SC,
- // FIXME: Move to DeclGroup...
- D.getDeclSpec().getSourceRange().getBegin());
- NewVD->setThreadSpecified(ThreadSpecified);
}
+ NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
+ II, R, SC,
+ // FIXME: Move to DeclGroup...
+ D.getDeclSpec().getSourceRange().getBegin());
+ NewVD->setThreadSpecified(ThreadSpecified);
NewVD->setNextDeclarator(LastDeclarator);
// Handle attributes prior to checking for duplicates in MergeVarDecl
if (BitWidth) {
if (Member->isInvalidDecl()) {
// don't emit another diagnostic.
- } else if (isa<CXXClassVarDecl>(Member)) {
+ } else if (isa<VarDecl>(Member)) {
// C++ 9.6p3: A bit-field shall not be a static member.
// "static member 'A' cannot be a bit-field"
Diag(Loc, diag::err_static_not_bitfield)
// C++ 9.2p4: A member-declarator can contain a constant-initializer only
// if it declares a static member of const integral or const enumeration
// type.
- if (CXXClassVarDecl *CVD = dyn_cast<CXXClassVarDecl>(Member)) {
+ if (VarDecl *CVD = dyn_cast<VarDecl>(Member)) {
// ...static member of...
CVD->setInit(Init);
// ...const integral or const enumeration type.
return Owned(new (Context) MemberExpr(BaseExpr, OpKind == tok::arrow, FD,
MemberLoc, MemberType));
- } else if (CXXClassVarDecl *Var = dyn_cast<CXXClassVarDecl>(MemberDecl))
+ } else if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl))
return Owned(new (Context) MemberExpr(BaseExpr, OpKind == tok::arrow,
Var, MemberLoc,
Var->getType().getNonReferenceType()));