]> granicus.if.org Git - clang/commitdiff
Add #pragma clang attribute support to the availability attribute
authorAlex Lorenz <arphaman@gmail.com>
Thu, 20 Apr 2017 09:35:02 +0000 (09:35 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 20 Apr 2017 09:35:02 +0000 (09:35 +0000)
rdar://31707804

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300826 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
lib/Sema/SemaDeclAttr.cpp
test/Misc/pragma-attribute-supported-attributes-list.test
test/Parser/pragma-attribute.cpp
test/Sema/attr-availability.c

index b6cb0f4607cf0cab6b1e573e30ef91c2e3e63489..44893fbd036c3860210f4de4a32b7d3a0b7927e0 100644 (file)
@@ -655,7 +655,7 @@ def Availability : InheritableAttr {
 } }];
   let HasCustomParsing = 1;
   let DuplicatesAllowedWhileMerging = 1;
-//  let Subjects = SubjectList<[Named]>;
+  let Subjects = SubjectList<[Named]>;
   let Documentation = [AvailabilityDocs];
 }
 
index b87c8bfdd8b620d8053a3b10bbc863fbab8712f7..027b3fe0e782802894cf830dc4a503fbbf0ef21f 100644 (file)
@@ -2398,10 +2398,8 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
       << Platform->Ident;
 
   NamedDecl *ND = dyn_cast<NamedDecl>(D);
-  if (!ND) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+  if (!ND) // We warned about this already, so just return.
     return;
-  }
 
   AvailabilityChange Introduced = Attr.getAvailabilityIntroduced();
   AvailabilityChange Deprecated = Attr.getAvailabilityDeprecated();
index 5b58ba51b989b72b3c240dc5071501a0f0663ceb..f6a7ce2869acc0895ada6eb69b3cd6477cbd5f5e 100644 (file)
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 58 attributes:
+// CHECK: #pragma clang attribute supports 59 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -13,6 +13,7 @@
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
 // CHECK-NEXT: Annotate ()
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
+// CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: CXX11NoReturn (SubjectMatchRule_function)
 // CHECK-NEXT: CallableWhen (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: CarriesDependency (SubjectMatchRule_variable_is_parameter, SubjectMatchRule_objc_method, SubjectMatchRule_function)
index b28ec8c2c86d119a46f15e84b7c9e02d3ecc032d..f0ebca2c5313bb6b6b82c445cdda66f9e40fbe40 100644 (file)
@@ -122,9 +122,9 @@ void function();
 #pragma clang attribute push (__attribute__((annotate)) foo) // expected-error {{expected ','}}
 #pragma clang attribute push (__attribute__((annotate)), apply_to=function foo) // expected-error {{extra tokens after attribute in a '#pragma clang attribute push'}}
 
-#pragma clang attribute push (__attribute__((availability(macos, foo=1))), apply_to=function) // expected-error {{'foo' is not an availability stage; use 'introduced', 'deprecated', or 'obsoleted'}}
-// expected-error@-1 {{attribute 'availability' is not supported by '#pragma clang attribute'}}
-#pragma clang attribute push (__attribute__((availability(macos, 1))), apply_to=function) // expected-error {{expected 'introduced', 'deprecated', or 'obsoleted'}}
+#pragma clang attribute push (__attribute__((objc_bridge_related)), apply_to=function)
+// expected-error@-1 {{attribute 'objc_bridge_related' is not supported by '#pragma clang attribute'}}
+#pragma clang attribute push (__attribute__((objc_bridge_related(1))), apply_to=function) // expected-error {{expected a related ObjectiveC class name, e.g., 'NSColor'}}
 
 #pragma clang attribute push (__attribute__((used)), apply_to=function) // expected-error {{attribute 'used' is not supported by '#pragma clang attribute'}}
 
index a4b40ff9e0c30b39f96767303dc6f54f52e5d50e..c4133e3b9bc6e6c84f309b0495497c2ddf9f411e 100644 (file)
@@ -74,7 +74,7 @@ extern int x;
 
 void f8() {
   int (^b)(int);
-  b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute ignored}}
+  b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute only applies to named declarations}}
 }
 
 extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}