diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2019-04-11 17:55:30 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2019-04-11 17:55:30 +0000 |
commit | c5a0583400b71f81faf9dedfaab094720c2ef823 (patch) | |
tree | 5cecf0481ac9204698f89067c5c2d680e2341c39 /clang/test/Parser/objc-implementation-attrs.m | |
parent | 7822b4618853a41aaa5ee3a7f14e0e32b1d29a64 (diff) | |
download | bcm5719-llvm-c5a0583400b71f81faf9dedfaab094720c2ef823.tar.gz bcm5719-llvm-c5a0583400b71f81faf9dedfaab094720c2ef823.zip |
Add support for attributes on @implementations in Objective-C
We want to make objc_nonlazy_class apply to implementations, but ran into this.
There doesn't seem to be any reason that this isn't supported.
Differential revision: https://reviews.llvm.org/D60542
llvm-svn: 358200
Diffstat (limited to 'clang/test/Parser/objc-implementation-attrs.m')
-rw-r--r-- | clang/test/Parser/objc-implementation-attrs.m | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/clang/test/Parser/objc-implementation-attrs.m b/clang/test/Parser/objc-implementation-attrs.m new file mode 100644 index 00000000000..76d9714140d --- /dev/null +++ b/clang/test/Parser/objc-implementation-attrs.m @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -Wno-objc-root-class -verify %s + +@interface I1 @end + +// expected-warning@+1 {{'always_inline' attribute only applies to functions}} +__attribute__((always_inline)) +@implementation I1 @end + +// expected-warning@+1 {{'always_inline' attribute only applies to functions}} +__attribute__((always_inline)) +@implementation I1 (MyCat) @end + +// expected-warning@+1 {{'always_inline' attribute only applies to functions}} +__attribute__((always_inline)) +// expected-warning@+1 {{cannot find interface declaration for 'I2'}} +@implementation I2 @end + +// expected-error@+1 {{only applies to Objective-C interfaces}} +__attribute__((objc_root_class)) +// expected-warning@+1 {{cannot find interface declaration for 'I3'}} +@implementation I3 @end + +#define AVAIL_ATTR __attribute__((availability(macos, introduced=1000))) + +typedef int AVAIL_ATTR unavail_int; // expected-note {{marked as being introduced}} + +@interface I4 @end // expected-note {{annotate}} +@implementation I4 { + unavail_int x; // expected-warning {{'unavail_int' is only available on macOS 1000 or newer}} +} +@end + +@interface I5 @end + +#pragma clang attribute push (AVAIL_ATTR, apply_to=objc_implementation) +@implementation I5 { + unavail_int x; +} +@end +#pragma clang attribute pop + +I5 *i5; + +// expected-error@+1 2 {{'annotate' attribute takes one argument}} +#pragma clang attribute push (__attribute__((annotate)), apply_to=objc_implementation) +@interface I6 @end +@interface I6 (MyCat) @end +@interface I6 () @end + +@implementation I6 @end // expected-note {{when applied to this declaration}} +@implementation I6 (MyCat) @end // expected-note {{when applied to this declaration}} + +#pragma clang attribute pop |