[cfe-commits] r123076 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp
Sean Hunt
scshunt at csclub.uwaterloo.ca
Sat Jan 8 11:20:43 PST 2011
Author: coppro
Date: Sat Jan 8 13:20:43 2011
New Revision: 123076
URL: http://llvm.org/viewvc/llvm-project?rev=123076&view=rev
Log:
Check for delegating constructors and (currently) return an error about them.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=123076&r1=123075&r2=123076&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 8 13:20:43 2011
@@ -893,6 +893,12 @@
"enumeration previously declared with %select{non|}0fixed underlying type">;
def err_enum_redeclare_scoped_mismatch : Error<
"enumeration previously declared as %select{un|}0scoped">;
+
+// C++0x delegating constructors
+def err_delegation_0x_only : Error<
+ "Delegating constructors are permitted only in C++0x.">;
+def err_delegation_unimplemented : Error<
+ "Delegating constructors are not fully implemented.">;
// Objective-C++
def err_objc_decls_may_only_appear_in_global_scope : Error<
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=123076&r1=123075&r2=123076&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Jan 8 13:20:43 2011
@@ -2566,6 +2566,13 @@
CXXRecordDecl *ClassDecl,
SourceLocation EllipsisLoc);
+ MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo,
+ Expr **Args, unsigned NumArgs,
+ SourceLocation RParenLoc,
+ SourceLocation LParenLoc,
+ CXXRecordDecl *ClassDecl,
+ SourceLocation EllipsisLoc);
+
bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
CXXBaseOrMemberInitializer **Initializers,
unsigned NumInitializers, bool AnyErrors);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=123076&r1=123075&r2=123076&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jan 8 13:20:43 2011
@@ -1392,6 +1392,22 @@
}
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 @@
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);
More information about the cfe-commits
mailing list