From: Jordan Rose Date: Tue, 24 Jul 2012 21:55:34 +0000 (+0000) Subject: Add __has_feature(attribute_availability_with_message). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b43f63822e051f2d28d8e083b688b2f113d6ba9c;p=clang Add __has_feature(attribute_availability_with_message). This tests for the ability to include a "message" field in availability attributes, like so: extern void ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); This was actually supported in Clang 3.1, but we got a request for a __has_feature so that header files can use this more safely. It's unfortunate that the 3.1 release doesn't include this, however. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160699 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index c9d400fc66..3a7f02cafb 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -619,6 +619,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("address_sanitizer", LangOpts.AddressSanitizer) .Case("attribute_analyzer_noreturn", true) .Case("attribute_availability", true) + .Case("attribute_availability_with_message", true) .Case("attribute_cf_returns_not_retained", true) .Case("attribute_cf_returns_retained", true) .Case("attribute_deprecated_with_message", true) diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index a13e351a6e..b4a6f9616d 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -37,3 +37,9 @@ void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warn void f7(int) __attribute__((availability(ios,introduced=2.0))); void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} + + +// +#if !__has_feature(attribute_availability_with_message) +# error "Missing __has_feature" +#endif