diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-26 14:53:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-26 14:53:44 +0000 |
commit | da8b24961acfbeff47f585109b7559ba60e574cb (patch) | |
tree | 4b20c2c17d9cd055a0da145ec8905457381c0baa /lib/Sema/SemaTemplateDeduction.cpp | |
parent | 9f1210c3280104417a4ad30f0a00825ac8fa718a (diff) |
Objective-C++ ARC: When performing template argument deduction for a
lifetime-qualified template parameter, ensure that the deduced
template argument is a lifetime type. Fixes <rdar://problem/9828157>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 888d3bee5f..824b9d9abb 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -1018,6 +1018,17 @@ DeduceTemplateArguments(Sema &S, DeducedQs.removeObjCLifetime(); // Objective-C ARC: + // If template deduction would produce a lifetime qualifier on a type + // that is not a lifetime type, template argument deduction fails. + if (ParamQs.hasObjCLifetime() && !DeducedType->isObjCLifetimeType() && + !DeducedType->isDependentType()) { + Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->getParam(Index)); + Info.FirstArg = TemplateArgument(Param); + Info.SecondArg = TemplateArgument(Arg); + return Sema::TDK_Underqualified; + } + + // Objective-C ARC: // If template deduction would produce an argument type with lifetime type // but no lifetime qualifier, the __strong lifetime qualifier is inferred. if (S.getLangOptions().ObjCAutoRefCount && |