From: Steve Naroff Date: Tue, 2 Sep 2008 15:20:19 +0000 (+0000) Subject: Implement block pseudo-storage class modifiers (__block, __byref). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=042f955a20e67cd8c8cdfede96bc6ec5a7234294;p=clang Implement block pseudo-storage class modifiers (__block, __byref). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55635 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 18b106ad84..27c2e676e6 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -476,6 +476,13 @@ static void InitializePredefinedMacros(Preprocessor &PP, DefineBuiltinMacro(Buf, "__int64=long long"); DefineBuiltinMacro(Buf, "__declspec(X)="); } + if (PP.getLangOptions().Blocks) { + DefineBuiltinMacro(Buf, "__byref=__attribute__((__blocks__(byref)))"); + DefineBuiltinMacro(Buf, "__block=__attribute__((__blocks__(byref)))"); + } else { + DefineBuiltinMacro(Buf, "__byref="); + DefineBuiltinMacro(Buf, "__block="); + } // FIXME: Should emit a #line directive here. } diff --git a/test/Parser/block-block-storageclass.c b/test/Parser/block-block-storageclass.c new file mode 100644 index 0000000000..c15d731ec8 --- /dev/null +++ b/test/Parser/block-block-storageclass.c @@ -0,0 +1,18 @@ +// RUN: clang -fsyntax-only -verify -parse-noop %s + +#include +void _Block_byref_release(void*src){} + +int main() { + __block int X = 1234; + __block const char * message = "HELLO"; + + X = X - 1234; + + X += 1; + + printf ("%s(%d)\n", message, X); + X -= 1; + + return X; +}