diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-01-08 19:20:43 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-01-08 19:20:43 +0000 |
commit | 97fcc4977b21da43ab106607ad472149b7d4785a (patch) | |
tree | 29bbec5477953cc0c591a9ce9167007ad3868881 /lib/Sema | |
parent | eeef924c4fcb79a3bcc8782afce343e641bbcb83 (diff) |
Check for delegating constructors and (currently) return an error about them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index e2067de964..b6c6d4d038 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1392,6 +1392,22 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr **Args, } MemInitResult +Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, + Expr **Args, unsigned NumArgs, + SourceLocation LParenLoc, + SourceLocation RParenLoc, + CXXRecordDecl *ClassDecl, + SourceLocation EllipsisLoc) { + SourceLocation Loc = TInfo->getTypeLoc().getLocalSourceRange().getBegin(); + if (!LangOpts.CPlusPlus0x) + return Diag(Loc, diag::err_delegation_0x_only) + << TInfo->getTypeLoc().getLocalSourceRange(); + + return Diag(Loc, diag::err_delegation_unimplemented) + << TInfo->getTypeLoc().getLocalSourceRange(); +} + +MemInitResult Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr **Args, unsigned NumArgs, SourceLocation LParenLoc, SourceLocation RParenLoc, @@ -1438,6 +1454,12 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, const CXXBaseSpecifier *DirectBaseSpec = 0; const CXXBaseSpecifier *VirtualBaseSpec = 0; if (!Dependent) { + if (Context.hasSameUnqualifiedType(QualType(ClassDecl->getTypeForDecl(),0), + BaseType)) + return BuildDelegatingInitializer(BaseTInfo, Args, NumArgs, + LParenLoc, RParenLoc, ClassDecl, + EllipsisLoc); + FindBaseInitializer(*this, ClassDecl, BaseType, DirectBaseSpec, VirtualBaseSpec); |