diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp index 846a31a7967309..5b0f34d1aa3aa1 100644 --- a/clang/lib/Sema/SemaAvailability.cpp +++ b/clang/lib/Sema/SemaAvailability.cpp @@ -928,11 +928,6 @@ void Sema::DiagnoseUnguardedAvailabilityViolations(Decl *D) { Stmt *Body = nullptr; if (auto *FD = D->getAsFunction()) { - // FIXME: We only examine the pattern decl for availability violations now, - // but we should also examine instantiated templates. - if (FD->isTemplateInstantiation()) - return; - Body = FD->getBody(); if (auto *CD = dyn_cast(FD)) diff --git a/clang/test/SemaObjC/unguarded-availability.m b/clang/test/SemaObjC/unguarded-availability.m index d0e23eabcb5985..ecd91990174ae5 100644 --- a/clang/test/SemaObjC/unguarded-availability.m +++ b/clang/test/SemaObjC/unguarded-availability.m @@ -177,16 +177,28 @@ void justAtAvailable(void) { #ifdef OBJCPP -int f(char) AVAILABLE_10_12; +int f(char) AVAILABLE_10_12; // #f_char_def int f(int); template int use_f() { - // FIXME: We should warn here! - return f(T()); + if (@available(macos 10.12, *)) { + return f(T()); // no warning expected + } else { + // expected-warning@#f_call {{'f' is only available on macOS 10.12 or newer}} + // expected-note@#f_char_inst {{in instantiation of function template specialization 'use_f' requested here}} + // expected-note@#f_char_def {{'f' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}} + // expected-note@#f_call {{enclose 'f' in an @available check to silence this warning}} + return f(T()); // #f_call + } } int a = use_f(); -int b = use_f(); +int b = use_f(); // #f_char_inst + +int use_f2() AVAILABLE_10_12 { + int c = use_f(); + int d = use_f(); // no warning expected +} template int use_at_available() { if (@available(macos 10.12, *))