[cfe-commits] r55635 - in /cfe/trunk: lib/Lex/Preprocessor.cpp test/Parser/block-block-storageclass.c
Steve Naroff
snaroff at apple.com
Tue Sep 2 08:20:21 PDT 2008
Author: snaroff
Date: Tue Sep 2 10:20:19 2008
New Revision: 55635
URL: http://llvm.org/viewvc/llvm-project?rev=55635&view=rev
Log:
Implement block pseudo-storage class modifiers (__block, __byref).
Added:
cfe/trunk/test/Parser/block-block-storageclass.c
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=55635&r1=55634&r2=55635&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Sep 2 10:20:19 2008
@@ -476,6 +476,13 @@
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.
}
Added: cfe/trunk/test/Parser/block-block-storageclass.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/block-block-storageclass.c?rev=55635&view=auto
==============================================================================
--- cfe/trunk/test/Parser/block-block-storageclass.c (added)
+++ cfe/trunk/test/Parser/block-block-storageclass.c Tue Sep 2 10:20:19 2008
@@ -0,0 +1,18 @@
+// RUN: clang -fsyntax-only -verify -parse-noop %s
+
+#include <stdio.h>
+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;
+}
More information about the cfe-commits
mailing list