summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-25 02:58:17 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-25 02:58:17 +0000
commit75fdaa465f4ccbe129ad69cdc8de34587066db13 (patch)
treefd18ba15744d66e01285fba3ef36583adbe50b73 /clang/lib/Sema
parent3cfc2e214a20998e0e4f81ec70e75fe9c0fb9e77 (diff)
downloadbcm5719-llvm-75fdaa465f4ccbe129ad69cdc8de34587066db13.tar.gz
bcm5719-llvm-75fdaa465f4ccbe129ad69cdc8de34587066db13.zip
Improve handling of base initializers. We now parse initializers in out of line decls, such as:
class C { C() { } int a; }; C::C() : a(10) { } We also diagnose when initializers are used on declarations that aren't constructors: t.cpp:1:10: error: only constructors take base initializers void f() : a(10) { } ^ Doug and/or Sebastian: I'd appreciate a review, especially the nested-name-spec test results (from the looks of it we now match gcc in that test.) llvm-svn: 67672
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/Sema.h4
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp12
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 6b9012b487a..42b0205bacb 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -1588,6 +1588,10 @@ public:
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
+ virtual void ActOnMemInitializers(DeclTy *ConstructorDecl,
+ SourceLocation ColonLoc,
+ MemInitTy **MemInits, unsigned NumMemInits);
+
virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
DeclTy *TagDecl,
SourceLocation LBrac,
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a85d62bc415..d734ffe5cfa 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -706,6 +706,18 @@ Sema::ActOnMemInitializer(DeclTy *ConstructorD,
return new CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, NumArgs);
}
+void Sema::ActOnMemInitializers(DeclTy *ConstructorDecl,
+ SourceLocation ColonLoc,
+ MemInitTy **MemInits, unsigned NumMemInits) {
+ CXXConstructorDecl *Constructor =
+ dyn_cast<CXXConstructorDecl>((Decl *)ConstructorDecl);
+
+ if (!Constructor) {
+ Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
+ return;
+ }
+}
+
namespace {
/// PureVirtualMethodCollector - traverses a class and its superclasses
/// and determines if it has any pure virtual methods.
OpenPOWER on IntegriCloud