summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-26 14:53:44 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-26 14:53:44 +0000
commita4f2b430e097806b8bc86b47def257e80d3c6f87 (patch)
tree05ac3d88749fca46af3864ced2c3b299ddb01b69 /clang/lib/Sema/SemaTemplateDeduction.cpp
parent16b867416f0e94432d214b7b38a26a7b54775506 (diff)
downloadbcm5719-llvm-a4f2b430e097806b8bc86b47def257e80d3c6f87.tar.gz
bcm5719-llvm-a4f2b430e097806b8bc86b47def257e80d3c6f87.zip
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>. llvm-svn: 136078
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 888d3bee5f9..824b9d9abb8 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/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 &&
OpenPOWER on IntegriCloud