diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 50e07553a1..fb0307fb28 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -9528,6 +9528,10 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, ExDeclType, TInfo, SC_None, SC_None); ExDecl->setExceptionVariable(true); + // In ARC, infer 'retaining' for variables of retainable type. + if (getLangOptions().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl)) + Invalid = true; + if (!Invalid && !ExDeclType->isDependentType()) { if (const RecordType *recordType = ExDeclType->getAs<RecordType>()) { // C++ [except.handle]p16: diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 0fd3b25def..8dd484a3b5 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2911,6 +2911,10 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, T, TInfo, SC_None, SC_None); New->setExceptionVariable(true); + // In ARC, infer 'retaining' for variables of retainable type. + if (getLangOptions().ObjCAutoRefCount && inferObjCARCLifetime(New)) + Invalid = true; + if (Invalid) New->setInvalidDecl(); return New; diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 9477192e23..123548e656 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -351,6 +351,12 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { Sema::LookupOrdinaryName, Sema::ForRedeclaration); if (D->isStaticDataMember()) SemaRef.LookupQualifiedName(Previous, Owner, false); + + // In ARC, infer 'retaining' for variables of retainable type. + if (SemaRef.getLangOptions().ObjCAutoRefCount && + SemaRef.inferObjCARCLifetime(Var)) + Var->setInvalidDecl(); + SemaRef.CheckVariableDeclaration(Var, Previous); if (D->isOutOfLine()) { |