From 75fdaa465f4ccbe129ad69cdc8de34587066db13 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 25 Mar 2009 02:58:17 +0000 Subject: 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 --- clang/lib/Parse/Parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Parse/Parser.cpp') diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index a26c310c204..135faf4e9c9 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -505,7 +505,9 @@ Parser::ParseDeclarationOrFunctionDefinition( } else if (DeclaratorInfo.isFunctionDeclarator() && (Tok.is(tok::l_brace) || // int X() {} (!getLang().CPlusPlus && - isDeclarationSpecifier()))) { // int X(f) int f; {} + isDeclarationSpecifier()) || // int X(f) int f; {} + (getLang().CPlusPlus && + Tok.is(tok::colon)))) { // X() : Base() {} (used for ctors) if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); -- cgit v1.2.3