161 lines · plain
1// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s2// RUN: %clang_cc1 -xobjective-c++ -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s3 4// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s5// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability-new -DNO_WARNING -fblocks -fsyntax-only -verify %s6 7// unguarded-availability implies unguarded-availability-new:8// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -fblocks -fsyntax-only -verify %s9// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.11 -Wunguarded-availability -Wno-unguarded-availability-new -DNO_WARNING -DWARN_PREV -fblocks -fsyntax-only -verify %s10// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -DNO_WARNING -fblocks -fsyntax-only -verify %s11// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s12 13// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s14// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s15// RUN: %clang_cc1 -DMAC -triple x86_64-apple-ios11 -DNO_WARNING -fblocks -fsyntax-only -verify %s16// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.12 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s17 18// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -fblocks -fsyntax-only -verify %s19// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s20// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s21// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios10.3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s22 23// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -fblocks -fsyntax-only -verify %s24// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s25// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s26// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos10 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s27 28// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -fblocks -fsyntax-only -verify %s29// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s30// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s31// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s32 33#ifdef MAC34#define PLATFORM macos35#define NEXT 10.1436 37#define AVAILABLE_PREV __attribute__((availability(macos, introduced = 10.12)))38#define AVAILABLE_CURRENT __attribute__((availability(macos, introduced = 10.13)))39#define AVAILABLE_NEXT __attribute__((availability(macos, introduced = 10.14)))40#endif41 42#ifdef IOS43#define PLATFORM ios44#define NEXT 1245 46#define AVAILABLE_PREV __attribute__((availability(ios, introduced = 10)))47#define AVAILABLE_CURRENT __attribute__((availability(ios, introduced = 11)))48#define AVAILABLE_NEXT __attribute__((availability(ios, introduced = 12)))49#endif50 51#ifdef TVOS52#define PLATFORM tvos53#define NEXT 1354 55#define AVAILABLE_PREV __attribute__((availability(tvos, introduced = 10)))56#define AVAILABLE_CURRENT __attribute__((availability(tvos, introduced = 11)))57#define AVAILABLE_NEXT __attribute__((availability(tvos, introduced = 13)))58#endif59 60#ifdef WATCHOS61#define PLATFORM watchos62#define NEXT 563 64#define AVAILABLE_PREV __attribute__((availability(watchos, introduced = 3)))65#define AVAILABLE_CURRENT __attribute__((availability(watchos, introduced = 4)))66#define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5)))67#endif68 69void previouslyAvailable(void) AVAILABLE_PREV;70#ifdef WARN_PREV71// expected-note@-2 {{'previouslyAvailable' has been marked as being introduced}}72#endif73void currentlyAvailable(void) AVAILABLE_CURRENT;74#ifdef WARN_CURRENT75// expected-note@-2 {{'currentlyAvailable' has been marked as being introduced}}76#endif77void willBeAvailabile(void) AVAILABLE_NEXT;78#ifndef NO_WARNING79// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in}}80#endif81 82#ifdef TEST_FUNC_CURRENT83#define FUNC_AVAILABLE AVAILABLE_CURRENT84#endif85#ifdef TEST_FUNC_NEXT86#define FUNC_AVAILABLE AVAILABLE_NEXT87#endif88#ifndef FUNC_AVAILABLE89#define FUNC_AVAILABLE90#endif91 92typedef int AVAILABLE_NEXT new_int;93#ifndef NO_WARNING94// expected-note@-2 {{'new_int' has been marked as being introduced in}}95#endif96FUNC_AVAILABLE new_int x;97#ifndef NO_WARNING98#ifdef MAC99 // expected-warning@-3 {{'new_int' is only available on macOS 10.14 or newer}} expected-note@-3 {{annotate 'x' with an availability attribute to silence this warning}}100#endif101#ifdef IOS102 // expected-warning@-6 {{'new_int' is only available on iOS 12 or newer}} expected-note@-6 {{annotate 'x' with an availability attribute to silence this warning}}103#endif104#ifdef TVOS105 // expected-warning@-9 {{'new_int' is only available on tvOS 13 or newer}} expected-note@-9 {{annotate 'x' with an availability attribute to silence this warning}}106#endif107#ifdef WATCHOS108 // expected-warning@-12 {{'new_int' is only available on watchOS 5}} expected-note@-12 {{annotate 'x' with an availability attribute to silence this warning}}109#endif110#endif111 112void test(void) FUNC_AVAILABLE {113 previouslyAvailable();114#ifdef WARN_PREV115#ifdef MAC116 // expected-warning@-3 {{'previouslyAvailable' is only available on macOS 10.12 or newer}}117#endif118 // expected-note@-5 {{enclose 'previouslyAvailable' in an @available check to silence this warning}}119#endif120 currentlyAvailable();121#ifdef WARN_CURRENT122#ifdef MAC123 // expected-warning@-3 {{'currentlyAvailable' is only available on macOS 10.13 or newer}}124#endif125#ifdef IOS126 // expected-warning@-6 {{'currentlyAvailable' is only available on iOS 11 or newer}}127#endif128#ifdef TVOS129 // expected-warning@-9 {{'currentlyAvailable' is only available on tvOS 11 or newer}}130#endif131#ifdef WATCHOS132 // expected-warning@-12 {{'currentlyAvailable' is only available on watchOS 4 or newer}}133#endif134 // expected-note@-14 {{enclose 'currentlyAvailable' in an @available check to silence this warning}}135#endif136 willBeAvailabile();137#ifndef NO_WARNING138#ifdef MAC139 // expected-warning@-3 {{'willBeAvailabile' is only available on macOS 10.14 or newer}}140#endif141#ifdef IOS142 // expected-warning@-6 {{'willBeAvailabile' is only available on iOS 12 or newer}}143#endif144#ifdef TVOS145 // expected-warning@-9 {{'willBeAvailabile' is only available on tvOS 13 or newer}}146#endif147#ifdef WATCHOS148 // expected-warning@-12 {{'willBeAvailabile' is only available on watchOS 5 or newer}}149#endif150 // expected-note@-14 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}151#endif152 if (@available(PLATFORM NEXT, *))153 willBeAvailabile(); // OK154}155 156#ifdef NO_WARNING157#ifndef WARN_PREV158// expected-no-diagnostics159#endif160#endif161