From: Erik Pilkington Date: Fri, 28 Feb 2020 23:24:23 +0000 (-0800) Subject: [Sema] Fix an assert when objc_externally_retained was applied to an unprototyped... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e4f5e629de8ba77ae6facba5c595ef23d95acf4;p=platform%2Fupstream%2Fllvm.git [Sema] Fix an assert when objc_externally_retained was applied to an unprototyped function rdar://58893199 --- diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index cf3fa38..3a6c2af 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6561,7 +6561,9 @@ static void handleObjCExternallyRetainedAttr(Sema &S, Decl *D, // If D is a function-like declaration (method, block, or function), then we // make every parameter psuedo-strong. - for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); I != E; ++I) { + unsigned NumParams = + hasFunctionProto(D) ? getFunctionOrMethodNumParams(D) : 0; + for (unsigned I = 0; I != NumParams; ++I) { auto *PVD = const_cast(getFunctionOrMethodParam(D, I)); QualType Ty = PVD->getType(); diff --git a/clang/test/SemaObjC/externally-retained.m b/clang/test/SemaObjC/externally-retained.m index 24c531c..f9fbdb0 100644 --- a/clang/test/SemaObjC/externally-retained.m +++ b/clang/test/SemaObjC/externally-retained.m @@ -118,3 +118,6 @@ void test13(ObjCTy *first, __weak ObjCTy *second, __unsafe_unretained ObjCTy *th } #pragma clang attribute ext_ret.pop + +__attribute__((objc_externally_retained)) +void unprototyped();