diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-26 19:27:00 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-26 19:27:00 +0000 |
| commit | ec599a906b7388f6ebdd3d00d6904473b69ec288 (patch) | |
| tree | 6eac50103586441591f2527e034c4f4fd958ed53 /clang/lib | |
| parent | 2993854bb464c08f060e1f704f4c0b6dbc9ccda8 (diff) | |
| download | bcm5719-llvm-ec599a906b7388f6ebdd3d00d6904473b69ec288.tar.gz bcm5719-llvm-ec599a906b7388f6ebdd3d00d6904473b69ec288.zip | |
SemaCXX: Support templates in availability attributes
If the availability context is `FunctionTemplateDecl`, we should look
through it to the `FunctionDecl`. This prevents a diagnostic in the
following case:
class C __attribute__((unavailable));
template <class T> void foo(C&) __attribute__((unavailable));
This adds tests for availability in templates in many other cases, but
that was the only case that failed before this patch.
I added a feature `__has_feature(attribute_availability_in_templates)`
so users can test for this.
rdar://problem/24561029
llvm-svn: 262050
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 58c3cc3369f..d41d25f7a44 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -467,6 +467,9 @@ static AvailabilityResult CheckAvailability(ASTContext &Context, } AvailabilityResult Decl::getAvailability(std::string *Message) const { + if (auto *FTD = dyn_cast<FunctionTemplateDecl>(this)) + return FTD->getTemplatedDecl()->getAvailability(Message); + AvailabilityResult Result = AR_Available; std::string ResultMessage; diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 50f07bd82bb..2c9a37525db 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1074,6 +1074,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("attribute_availability_tvos", true) .Case("attribute_availability_watchos", true) .Case("attribute_availability_with_strict", true) + .Case("attribute_availability_in_templates", true) .Case("attribute_cf_returns_not_retained", true) .Case("attribute_cf_returns_retained", true) .Case("attribute_cf_returns_on_parameters", true) |

