Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only -verify %s |
| 2 | |
Manman Ren | 6731d73 | 2016-02-22 18:24:30 +0000 | [diff] [blame] | 3 | #if !__has_feature(attribute_availability_with_strict) |
| 4 | #error "Missing __has_feature" |
| 5 | #endif |
| 6 | |
Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 7 | void f0(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6))); |
| 8 | void f1(int) __attribute__((availability(macosx,introduced=10.5))); |
Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [diff] [blame] | 9 | void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // expected-note {{'f2' has been explicitly marked deprecated here}} |
Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 10 | void f3(int) __attribute__((availability(macosx,introduced=10.6))); |
| 11 | void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}} |
Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [diff] [blame] | 12 | void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}} |
Alex Lorenz | 0b1ce8b | 2017-08-15 14:42:01 +0000 | [diff] [blame] | 13 | void f6(int) __attribute__((availability(macOS,strict,introduced=10.6))); //expected-note{{'f6' has been explicitly marked unavailable here}} |
Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 14 | |
| 15 | void test() { |
| 16 | f0(0); |
| 17 | f1(0); |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 18 | f2(0); // expected-warning{{'f2' is deprecated: first deprecated in macOS 10.5}} |
Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 19 | f3(0); |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 20 | f4(0); // expected-error{{f4' is unavailable: obsoleted in macOS 10.5}} |
| 21 | f5(0); // expected-error{{'f5' is unavailable: not available on macOS}} |
| 22 | f6(0); // expected-error{{'f6' is unavailable: introduced in macOS 10.6}} |
Douglas Gregor | 20b2ebd | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 23 | } |
Fariborz Jahanian | 329b351 | 2011-12-09 01:15:54 +0000 | [diff] [blame] | 24 | |
Duncan P. N. Exon Smith | 5d6790c | 2016-03-08 06:12:54 +0000 | [diff] [blame] | 25 | struct __attribute__((availability(macosx,strict,introduced=10.6))) |
| 26 | not_yet_introduced_struct; // \ |
| 27 | expected-note{{'not_yet_introduced_struct' has been explicitly marked unavailable here}} |
| 28 | |
| 29 | void uses_not_introduced_struct(struct not_yet_introduced_struct *); // \ |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 30 | expected-error{{'not_yet_introduced_struct' is unavailable: introduced in macOS 10.6}} |
Duncan P. N. Exon Smith | 5d6790c | 2016-03-08 06:12:54 +0000 | [diff] [blame] | 31 | |
| 32 | __attribute__((availability(macosx,strict,introduced=10.6))) |
| 33 | void uses_not_introduced_struct_same_availability(struct not_yet_introduced_struct *); |
| 34 | |
Fariborz Jahanian | 329b351 | 2011-12-09 01:15:54 +0000 | [diff] [blame] | 35 | // rdar://10535640 |
| 36 | |
| 37 | enum { |
| 38 | foo __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) |
| 39 | }; |
| 40 | |
| 41 | enum { |
| 42 | bar __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) = foo |
| 43 | }; |
| 44 | |
| 45 | enum __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) { |
| 46 | bar1 = foo |
| 47 | }; |
Manman Ren | 45b1ab1 | 2016-05-06 19:57:16 +0000 | [diff] [blame] | 48 | |
| 49 | // Make sure the note is on the declaration with the actual availability attributes. |
Alex Lorenz | 0b1ce8b | 2017-08-15 14:42:01 +0000 | [diff] [blame] | 50 | struct __attribute__((availability(macOS,strict,introduced=10.9))) type_info // \ |
Manman Ren | 45b1ab1 | 2016-05-06 19:57:16 +0000 | [diff] [blame] | 51 | expected-note{{'type_info' has been explicitly marked unavailable here}} |
| 52 | { |
| 53 | }; |
| 54 | struct type_info; |
| 55 | int test2() { |
Manman Ren | ccf25bb | 2016-06-28 20:55:30 +0000 | [diff] [blame] | 56 | struct type_info *t; // expected-error{{'type_info' is unavailable: introduced in macOS 10.9}} |
Manman Ren | 45b1ab1 | 2016-05-06 19:57:16 +0000 | [diff] [blame] | 57 | return 0; |
| 58 | } |