From 3c3af9c25b6e57dfc8c28a07679b90f902759a1a Mon Sep 17 00:00:00 2001
From: Erik Verbruggen <erik.verbruggen@nokia.com>
Date: Fri, 18 Jun 2010 09:08:00 +0200
Subject: [PATCH] Fixed return-type checking for ObjC methods.

---
 src/shared/cplusplus/CheckDeclaration.cpp |  8 ++++----
 src/shared/cplusplus/CheckDeclarator.cpp  |  4 +++-
 src/shared/cplusplus/CheckName.cpp        |  4 ++--
 src/shared/cplusplus/CheckSpecifier.cpp   | 13 -------------
 src/shared/cplusplus/CheckSpecifier.h     |  2 --
 src/shared/cplusplus/Semantic.cpp         |  4 ----
 src/shared/cplusplus/Semantic.h           |  3 ---
 7 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index a0ae84fa5a7..d38aa0eeeed 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -720,10 +720,6 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
 
     Symbol *symbol;
     if (ast->function_body) {
-        if (!semantic()->skipFunctionBodies()) {
-            semantic()->check(ast->function_body, methodTy->members());
-        }
-
         symbol = methodTy;
     } else {
         Declaration *decl = control()->newDeclaration(selector->firstToken(), methodTy->name());
@@ -742,6 +738,10 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
 
     _scope->enterSymbol(symbol);
 
+    if (ast->function_body && !semantic()->skipFunctionBodies()) {
+        semantic()->check(ast->function_body, methodTy->members());
+    }
+
     return false;
 }
 
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
index 84edbd02924..8fb80549e61 100644
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ b/src/shared/cplusplus/CheckDeclarator.cpp
@@ -260,7 +260,9 @@ bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
         return false;
     }
 
-    FullySpecifiedType returnType = semantic()->check(ast->type_name, _scope);
+    FullySpecifiedType returnType;
+    if (ast->type_name && ast->type_name->type_id)
+        returnType = semantic()->check(ast->type_name->type_id, _scope);
 
     unsigned location = ast->selector->firstToken();
 
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
index d98c9b9610d..4105268f93f 100644
--- a/src/shared/cplusplus/CheckName.cpp
+++ b/src/shared/cplusplus/CheckName.cpp
@@ -394,8 +394,8 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
 {
     FullySpecifiedType type;
 
-    if (ast->type_name)
-        type = semantic()->check(ast->type_name, _scope);
+    if (ast->type_name && ast->type_name->type_id)
+        type = semantic()->check(ast->type_name->type_id, _scope);
 
     if (ast->param_name) {
         accept(ast->param_name);
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
index e35d1d193c1..422bd7f3c4d 100644
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ b/src/shared/cplusplus/CheckSpecifier.cpp
@@ -82,19 +82,6 @@ FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier,
     return switchFullySpecifiedType(previousType);
 }
 
-FullySpecifiedType CheckSpecifier::check(ObjCTypeNameAST *typeName,
-                                         Scope *scope,
-                                         const FullySpecifiedType &ty)
-{
-    FullySpecifiedType previousType = switchFullySpecifiedType(ty);
-    Scope *previousScope = switchScope(scope);
-
-    accept(typeName);
-
-    (void) switchScope(previousScope);
-    return switchFullySpecifiedType(previousType);
-}
-
 SpecifierListAST *CheckSpecifier::switchSpecifier(SpecifierListAST *specifier)
 {
     SpecifierListAST *previousSpecifier = _specifier;
diff --git a/src/shared/cplusplus/CheckSpecifier.h b/src/shared/cplusplus/CheckSpecifier.h
index e66b3060309..d4a1f4ed22a 100644
--- a/src/shared/cplusplus/CheckSpecifier.h
+++ b/src/shared/cplusplus/CheckSpecifier.h
@@ -64,8 +64,6 @@ public:
 
     FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope,
                              const FullySpecifiedType &ty = FullySpecifiedType());
-    FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope,
-                             const FullySpecifiedType &ty = FullySpecifiedType());
 
 protected:
     SpecifierListAST *switchSpecifier(SpecifierListAST *specifier);
diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp
index 9dd1b9aca8c..be08ebdf7af 100644
--- a/src/shared/cplusplus/Semantic.cpp
+++ b/src/shared/cplusplus/Semantic.cpp
@@ -169,10 +169,6 @@ FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const Fully
 FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope)
 { return d->checkDeclarator->check(methodPrototype, scope); }
 
-FullySpecifiedType Semantic::check(ObjCTypeNameAST *typeName, Scope *scope,
-                                   const FullySpecifiedType &type)
-{ return d->checkSpecifier->check(typeName, scope, type); }
-
 void Semantic::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
 { return d->checkName->check(arg, scope); }
 
diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h
index 6aace93f757..cc6e3454835 100644
--- a/src/shared/cplusplus/Semantic.h
+++ b/src/shared/cplusplus/Semantic.h
@@ -107,9 +107,6 @@ public:
 
     const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
 
-    FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope,
-                             const FullySpecifiedType &type = FullySpecifiedType());
-
     void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
 
     void checkFunctionDefinition(FunctionDefinitionAST *ast);
-- 
GitLab