Fix scoping of method declarations and issue 
warning when same parameter name used multiple times.
// rdar://8877730


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125229 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/objc-forcollection-neg-2.m b/test/Parser/objc-forcollection-neg-2.m
index e02c51c..6aa74c9 100644
--- a/test/Parser/objc-forcollection-neg-2.m
+++ b/test/Parser/objc-forcollection-neg-2.m
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 typedef struct objc_class *Class;
+struct __objcFastEnumerationState; 
 typedef struct objc_object {
  Class isa;
 } *id;
     
-            
 @protocol P @end
 
 @interface MyList
diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m
index 0ba093e..d896c35 100644
--- a/test/Parser/objc-forcollection-neg.m
+++ b/test/Parser/objc-forcollection-neg.m
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+struct __objcFastEnumerationState; 
 typedef struct objc_class *Class;
 typedef struct objc_object {
  Class isa;
diff --git a/test/Parser/objc-foreach-syntax.m b/test/Parser/objc-foreach-syntax.m
index 943540e..cc82725 100644
--- a/test/Parser/objc-foreach-syntax.m
+++ b/test/Parser/objc-foreach-syntax.m
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-
-
+struct __objcFastEnumerationState; 
 @implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}}
 - (unsigned int)countByEnumeratingWithState:  (struct __objcFastEnumerationState *)state objects:  (id *)items count:(unsigned int)stackcount
 {
diff --git a/test/SemaObjC/method-prototype-scope.m b/test/SemaObjC/method-prototype-scope.m
new file mode 100644
index 0000000..2184172
--- /dev/null
+++ b/test/SemaObjC/method-prototype-scope.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+// rdar://8877730
+
+int object;
+
+@class NSString, NSArray;
+
+@interface Test 
+- Func:(int)XXXX, id object;
+
+- doSomethingElseWith:(id)object;
+
+- (NSString *)doSomethingWith:(NSString *)object and:(NSArray *)object; // expected-warning {{redefinition of method parameter 'object'}} \
+					  // expected-note {{previous declaration is here}}
+@end
+
+@implementation Test
+
+- (NSString *)doSomethingWith:(NSString *)object and:(NSArray *)object // expected-warning {{redefinition of method parameter 'object'}} \
+					  // expected-note {{previous declaration is here}}
+{
+    return object; // expected-warning {{incompatible pointer types returning 'NSArray *' from a function with result type 'NSString *'}}
+}
+
+- Func:(int)XXXX, id object { return object; }
+
+- doSomethingElseWith:(id)object { return object; }
+
+@end
+
+struct P;
+
+@interface Test1
+- doSomethingWith:(struct S *)object and:(struct P *)obj; // expected-warning {{declaration of 'struct S' will not be visible outside of this function}}
+@end
+
+int obj;