From: Fariborz Jahanian Date: Fri, 15 Jan 2010 18:14:52 +0000 (+0000) Subject: Do not do the block-specific rewrite when there is no block literals. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bf07012cf92253380ce427924870288a34230d1b;p=clang Do not do the block-specific rewrite when there is no block literals. Fixes radar 7546096. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93519 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index fc9401d290..386d9b0812 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -4043,7 +4043,7 @@ std::string RewriteObjC::SynthesizeBlockDescriptor(std::string DescTag, void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, const char *FunName) { // Insert declaration for the function in which block literal is used. - if (CurFunctionDeclToDeclareForBlock) + if (CurFunctionDeclToDeclareForBlock && !Blocks.empty()) RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock); // Insert closures that were part of the function. for (unsigned i = 0; i < Blocks.size(); i++) { diff --git a/test/Rewriter/rewrite-extern-c.mm b/test/Rewriter/rewrite-extern-c.mm new file mode 100644 index 0000000000..1c8e90faed --- /dev/null +++ b/test/Rewriter/rewrite-extern-c.mm @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -o - %s +// radar 7546096 + +extern "C" { + short foo() { } +} +typedef unsigned char Boolean; +