diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-01 10:37:29 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-01 10:37:29 +0000 |
commit | 07952324dda0e758c17f8bc3015793c65c51c48c (patch) | |
tree | df23760bd379514f0adb730fe44cb2642df6d58c /lib/Sema/SemaExprCXX.cpp | |
parent | aae2d7418b7004fde1ba08fe60db219d0c95ff30 (diff) |
Add Sema support for C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index e49a43c472..be7cf069ec 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -49,3 +49,21 @@ Action::ExprResult Sema::ActOnCXXThrow(SourceLocation OpLoc, ExprTy *E) { return new CXXThrowExpr((Expr*)E, Context.VoidTy, OpLoc); } + +Action::ExprResult Sema::ActOnCXXThis(SourceLocation ThisLoc) { + /// C++ 9.3.2: In the body of a non-static member function, the keyword this + /// is a non-lvalue expression whose value is the address of the object for + /// which the function is called. + + if (!isa<FunctionDecl>(CurContext)) { + Diag(ThisLoc, diag::err_invalid_this_use); + return ExprResult(true); + } + + if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) + if (MD->isInstance()) + return new PreDefinedExpr(ThisLoc, MD->getThisType(Context), + PreDefinedExpr::CXXThis); + + return Diag(ThisLoc, diag::err_invalid_this_use); +} |