summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-04 13:41:56 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-04 13:41:56 +0000
commit8e12c3811554bed6521152e55e4b500a83f82680 (patch)
treed8d1cb3796207eedc70bcda69a36658bde3ee778 /clang/lib
parent57c6594e97f3927756976bc5cdeffbb17226aa08 (diff)
downloadbcm5719-llvm-8e12c3811554bed6521152e55e4b500a83f82680.tar.gz
bcm5719-llvm-8e12c3811554bed6521152e55e4b500a83f82680.zip
Diagnose use of 'this' in a C++ default argument. Thanks to Eli for correcting my bogus assertion about it already being handled
llvm-svn: 58691
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 4a2f0b43f63..bd3da49030e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -46,6 +46,7 @@ namespace {
bool VisitExpr(Expr *Node);
bool VisitDeclRefExpr(DeclRefExpr *DRE);
+ bool VisitPredefinedExpr(PredefinedExpr *PE);
};
/// VisitExpr - Visit all of the children of this expression.
@@ -84,14 +85,20 @@ namespace {
VDecl->getName(), DefaultArg->getSourceRange());
}
- // C++ [dcl.fct.default]p8:
- // The keyword this shall not be used in a default argument of a
- // member function.
- // Note: this requirement is already diagnosed by
- // Sema::ActOnCXXThis, because the use of "this" inside a default
- // argument doesn't occur inside the body of a non-static member
- // function.
+ return false;
+ }
+ /// VisitPredefinedExpr - Visit a predefined expression, which could
+ /// refer to "this".
+ bool CheckDefaultArgumentVisitor::VisitPredefinedExpr(PredefinedExpr *PE) {
+ if (PE->getIdentType() == PredefinedExpr::CXXThis) {
+ // C++ [dcl.fct.default]p8:
+ // The keyword this shall not be used in a default argument of a
+ // member function.
+ return S->Diag(PE->getSourceRange().getBegin(),
+ diag::err_param_default_argument_references_this,
+ PE->getSourceRange());
+ }
return false;
}
}
OpenPOWER on IntegriCloud