diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-07 20:08:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-07 20:08:42 +0000 |
commit | 2f1bc5285ccd40f411af5f5993f013e27e74ab78 (patch) | |
tree | 13b6547acb399a89753f742a0595aea613cecc36 /lib/Sema/SemaDecl.cpp | |
parent | 9057a81efaf15c543aab1c5c8488e8a9ed2c0ff4 (diff) |
Parsing, ASTs, and semantic analysis for the declaration of conversion
functions in C++, e.g.,
struct X {
operator bool() const;
};
Note that these conversions don't actually do anything, since we don't
yet have the ability to use them for implicit or explicit conversions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index fd94c80d8b..12a4b08e91 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -38,6 +38,11 @@ Sema::TypeTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S) { return 0; } +std::string Sema::getTypeAsString(TypeTy *Type) { + QualType Ty = QualType::getFromOpaquePtr(Type); + return Ty.getAsString(); +} + DeclContext *Sema::getDCParent(DeclContext *DC) { // If CurContext is a ObjC method, getParent() will return NULL. if (isa<ObjCMethodDecl>(DC)) @@ -835,6 +840,22 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { if (isInvalidDecl) NewFD->setInvalidDecl(); + } else if (D.getKind() == Declarator::DK_Conversion) { + if (D.getContext() != Declarator::MemberContext) { + Diag(D.getIdentifierLoc(), + diag::err_conv_function_not_member); + return 0; + } else { + bool isInvalidDecl = CheckConversionDeclarator(D, R, SC); + + NewFD = CXXConversionDecl::Create(Context, + cast<CXXRecordDecl>(CurContext), + D.getIdentifierLoc(), II, R, + isInline, isExplicit); + + if (isInvalidDecl) + NewFD->setInvalidDecl(); + } } else if (D.getContext() == Declarator::MemberContext) { // This is a C++ method declaration. NewFD = CXXMethodDecl::Create(Context, cast<CXXRecordDecl>(CurContext), @@ -931,6 +952,8 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { return ActOnConstructorDeclarator(Constructor); else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(NewFD)) return ActOnDestructorDeclarator(Destructor); + else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(NewFD)) + return ActOnConversionDeclarator(Conversion); // Extra checking for C++ overloaded operators (C++ [over.oper]). if (NewFD->isOverloadedOperator() && |