diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-03-30 16:52:20 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-03-30 16:59:07 +0200 |
commit | e421d32147c867e326fbf036781f57c873f7056e (patch) | |
tree | 5ac53cbad75b4ce66e05bd281182dbb95f102b0d /src/shared/cplusplus/CheckDeclaration.cpp | |
parent | aff7d3fdf8c78488d85bffba4c72f64d92f23f74 (diff) | |
download | qt-creator-e421d32147c867e326fbf036781f57c873f7056e.tar.gz |
Postpone the parsing of function definitions.
Diffstat (limited to 'src/shared/cplusplus/CheckDeclaration.cpp')
-rw-r--r-- | src/shared/cplusplus/CheckDeclaration.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index 508e2e798b..01a10222c9 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -85,6 +85,13 @@ void CheckDeclaration::check(DeclarationAST *declaration, (void) switchScope(previousScope); } +void CheckDeclaration::check(CtorInitializerAST *ast, Scope *scope) +{ + Scope *previousScope = switchScope(scope); + accept(ast); + (void) switchScope(previousScope); +} + DeclarationAST *CheckDeclaration::switchDeclaration(DeclarationAST *declaration) { DeclarationAST *previousDeclaration = _declaration; @@ -352,29 +359,8 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) ast->symbol = fun; _scope->enterSymbol(fun); - if (! semantic()->skipFunctionBodies()) { - if (ast->ctor_initializer) { - bool looksLikeCtor = false; - if (ty.isValid() || ! fun->identity()) - looksLikeCtor = false; - else if (fun->identity()->isNameId() || fun->identity()->isTemplateNameId()) - looksLikeCtor = true; - - if (! looksLikeCtor) { - translationUnit()->error(ast->ctor_initializer->firstToken(), - "only constructors take base initializers"); - } - accept(ast->ctor_initializer); - } - - const int previousVisibility = semantic()->switchVisibility(Symbol::Public); - const int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod); - - semantic()->check(ast->function_body, fun->members()); - - semantic()->switchMethodKey(previousMethodKey); - semantic()->switchVisibility(previousVisibility); - } + if (! semantic()->skipFunctionBodies()) + semantic()->checkFunctionDefinition(ast); return false; } |