diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-25 02:58:17 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-25 02:58:17 +0000 |
commit | a7b3521ef52d983bd0e7fa562bb9ef1393f14634 (patch) | |
tree | f8bc187e9642a63ae61fcdeee48577e5ae274efe /lib/Parse/Parser.cpp | |
parent | 0cf6891270c59b458a1dd36d80d475adbf49ae7e (diff) |
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.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index a26c310c20..135faf4e9c 100644 --- a/lib/Parse/Parser.cpp +++ b/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); |