On Jan 9, 2009, at 11:57 AM, Sebastian Redl wrote: > Author: cornedbee > Date: Fri Jan 9 13:57:06 2009 > New Revision: 62003 > > URL: http://llvm.org/viewvc/llvm-project?rev=62003&view=rev > Log: > Very basic support for pure virtual functions.
Thanks! > Added: > cfe/trunk/test/SemaCXX/virtuals.cpp > Modified: > cfe/trunk/include/clang/AST/Decl.h > cfe/trunk/include/clang/Basic/DiagnosticKinds.def > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > > Modified: cfe/trunk/include/clang/AST/Decl.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=62003&r1=62002&r2=62003&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/include/clang/AST/Decl.h (original) > +++ cfe/trunk/include/clang/AST/Decl.h Fri Jan 9 13:57:06 2009 > @@ -648,6 +648,8 @@ > // NOTE: VC++ treats enums as signed, avoid using the StorageClass > enum > unsigned SClass : 2; > bool IsInline : 1; > + bool IsVirtual : 1; > + bool IsPure : 1; > > // Move to DeclGroup when it is implemented. > SourceLocation TypeSpecStartLoc; > @@ -659,7 +661,8 @@ > : ValueDecl(DK, DC, L, N, T, PrevDecl), > DeclContext(DK), > ParamInfo(0), Body(0), PreviousDeclaration(0), > - SClass(S), IsInline(isInline), TypeSpecStartLoc(TSSL) {} > + SClass(S), IsInline(isInline), IsVirtual(false), IsPure(false), > + TypeSpecStartLoc(TSSL) {} > > virtual ~FunctionDecl(); > virtual void Destroy(ASTContext& C); > @@ -692,7 +695,13 @@ > bool isThisDeclarationADefinition() const { return Body != 0; } > > void setBody(Stmt *B) { Body = B; } > - > + > + bool isVirtual() { return IsVirtual; } > + void setVirtual() { IsVirtual = true; } > + > + bool isPure() { return IsPure; } > + void setPure() { IsPure = true; } > + Could you add some documentation for these? Just a sentence or two would suffice. > + // not static member. perhaps virtual function? > + if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Member)) { > + IntegerLiteral *IL; > + if ((IL = dyn_cast<IntegerLiteral>(Init)) && IL->getValue() > == 0 && > + Context.getCanonicalType(IL->getType()) == > Context.IntTy) { I'm not so sure about this. Can't the parser parse a pure-specifier differently from a normal initializer, so it can check for '= 0' rather than having semantical analysis try to dissect an already- analyzed expression? We'll need to handle this kind of syntax on the parser anyway to deal with C++0x's "= delete" and "= default". - Doug _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
