Replacing some manual diagnostic checks with an existing helper method.  Adding missing test cases for the diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186944 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 00379b6..09d61e7 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2073,11 +2073,8 @@
 
 static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D, 
                                             const AttributeList &Attr) {
-  unsigned NumArgs = Attr.getNumArgs();
-  if (NumArgs > 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;
+  if (!checkAttributeNumArgs(S, Attr, 0))
     return;
-  }
   
   D->addAttr(::new (S.Context)
              ArcWeakrefUnavailableAttr(Attr.getRange(), S.Context,
@@ -2092,11 +2089,8 @@
     return;
   }
   
-  unsigned NumArgs = Attr.getNumArgs();
-  if (NumArgs > 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;
+  if (!checkAttributeNumArgs(S, Attr, 0))
     return;
-  }
   
   D->addAttr(::new (S.Context)
              ObjCRootClassAttr(Attr.getRange(), S.Context,
@@ -2110,11 +2104,8 @@
     return;
   }
   
-  unsigned NumArgs = Attr.getNumArgs();
-  if (NumArgs > 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;
+  if (!checkAttributeNumArgs(S, Attr, 0))
     return;
-  }
   
   D->addAttr(::new (S.Context)
              ObjCRequiresPropertyDefsAttr(Attr.getRange(), S.Context,
diff --git a/test/SemaObjC/arc-unavailable-for-weakref.m b/test/SemaObjC/arc-unavailable-for-weakref.m
index b9b5cc5..516611f 100644
--- a/test/SemaObjC/arc-unavailable-for-weakref.m
+++ b/test/SemaObjC/arc-unavailable-for-weakref.m
@@ -86,3 +86,7 @@
 @implementation I2 // expected-note {{when implemented by class I2}}
 @synthesize font = _font;
 @end
+
+__attribute__((objc_arc_weak_reference_unavailable(1)))	// expected-error {{attribute 'objc_arc_weak_reference_unavailable' takes no arguments}}
+@interface I3
+@end
diff --git a/test/SemaObjC/attr-root-class.m b/test/SemaObjC/attr-root-class.m
index 4f4c8b6..a21aefd 100644
--- a/test/SemaObjC/attr-root-class.m
+++ b/test/SemaObjC/attr-root-class.m
@@ -14,3 +14,7 @@
 __attribute__((objc_root_class)) static void nonClassDeclaration()  // expected-error {{'objc_root_class' attribute only applies to Objective-C interfaces}}
 {
 }
+
+__attribute__((objc_root_class(1))) // expected-error {{attribute 'objc_root_class' takes no arguments}}
+@interface I1
+@end
diff --git a/test/SemaObjC/default-synthesize-3.m b/test/SemaObjC/default-synthesize-3.m
index ce80154..e41a7d3 100644
--- a/test/SemaObjC/default-synthesize-3.m
+++ b/test/SemaObjC/default-synthesize-3.m
@@ -154,3 +154,6 @@
 @synthesize failureCount = _failureCount;
 @end
 
+__attribute ((objc_requires_property_definitions(1))) // expected-error {{attribute 'objc_requires_property_definitions' takes no arguments}}
+@interface I1
+@end