diff options
-rw-r--r-- | clang/lib/Rewrite/RewriteModernObjC.cpp | 12 | ||||
-rw-r--r-- | clang/test/Rewriter/rewrite-block-literal-1.mm | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Rewrite/RewriteModernObjC.cpp b/clang/lib/Rewrite/RewriteModernObjC.cpp index 5d124aba9f2..28502ddcbda 100644 --- a/clang/lib/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Rewrite/RewriteModernObjC.cpp @@ -4156,11 +4156,15 @@ void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) { GetBlockDeclRefExprs(*CI); } // Handle specific things. - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) - if (DRE->refersToEnclosingLocal() && - HasLocalVariableExternalStorage(DRE->getDecl())) { - BlockDeclRefs.push_back(DRE); + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) { + if (DRE->refersToEnclosingLocal()) { + // FIXME: Handle enums. + if (!isa<FunctionDecl>(DRE->getDecl())) + BlockDeclRefs.push_back(DRE); + if (HasLocalVariableExternalStorage(DRE->getDecl())) + BlockDeclRefs.push_back(DRE); } + } return; } diff --git a/clang/test/Rewriter/rewrite-block-literal-1.mm b/clang/test/Rewriter/rewrite-block-literal-1.mm index 5213f500b98..f152117443a 100644 --- a/clang/test/Rewriter/rewrite-block-literal-1.mm +++ b/clang/test/Rewriter/rewrite-block-literal-1.mm @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 9254348 +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp +// rdar://11259664 void *sel_registerName(const char *); typedef void (^BLOCK_TYPE)(void); |