diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-07-18 00:14:59 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-07-18 00:14:59 +0000 |
| commit | a906ad2f9e368c7ea949bbdc814ebce662b5e61c (patch) | |
| tree | 24d0b999593fd257f111a1fadbeb4008b45770f7 /clang | |
| parent | 2151497dca31a0add0e71717b4cd4462a0c8d10f (diff) | |
| download | bcm5719-llvm-a906ad2f9e368c7ea949bbdc814ebce662b5e61c.tar.gz bcm5719-llvm-a906ad2f9e368c7ea949bbdc814ebce662b5e61c.zip | |
When performing the deduced/actual argument type check for C++
[temp.deduct.call]p4 under Objective-C++ ARC, make sure to adjust the
qualifiers to introduce the implicit strong lifetime when
needed. Fixes <rdar://problem/11825671>.
llvm-svn: 160412
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaObjCXX/arc-templates.mm | 17 |
2 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index dcf878115ee..9500ec3219d 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -2436,6 +2436,16 @@ CheckOriginalCallArgDeduction(Sema &S, Sema::OriginalCallArg OriginalArg, Qualifiers AQuals = A.getQualifiers(); Qualifiers DeducedAQuals = DeducedA.getQualifiers(); + + // Under Objective-C++ ARC, the deduced type may have implicitly been + // given strong lifetime. If so, update the original qualifiers to + // include this strong lifetime. + if (S.getLangOpts().ObjCAutoRefCount && + DeducedAQuals.getObjCLifetime() == Qualifiers::OCL_Strong && + AQuals.getObjCLifetime() == Qualifiers::OCL_None) { + AQuals.setObjCLifetime(Qualifiers::OCL_Strong); + } + if (AQuals == DeducedAQuals) { // Qualifiers match; there's nothing to do. } else if (!DeducedAQuals.compatiblyIncludes(AQuals)) { diff --git a/clang/test/SemaObjCXX/arc-templates.mm b/clang/test/SemaObjCXX/arc-templates.mm index 9eca84648f6..80092729d34 100644 --- a/clang/test/SemaObjCXX/arc-templates.mm +++ b/clang/test/SemaObjCXX/arc-templates.mm @@ -3,6 +3,8 @@ @interface A @end +@class NSString; + template<typename T, typename U> struct is_same { static const bool value = false; @@ -266,3 +268,18 @@ namespace rdar9828157 { float &fr = (f)(ap); } } + +namespace rdar10862386 { + // More deduction with lifetime qualifiers. + template <typename T> + int testing(const T &) { + return 1; + } + + void test() { + testing(1); + testing("hi"); + testing<NSString *>(@"hi"); + testing(@"hi"); + } +} |

