]> granicus.if.org Git - clang/commitdiff
Implement block pseudo-storage class modifiers (__block, __byref).
authorSteve Naroff <snaroff@apple.com>
Tue, 2 Sep 2008 15:20:19 +0000 (15:20 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 2 Sep 2008 15:20:19 +0000 (15:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55635 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Preprocessor.cpp
test/Parser/block-block-storageclass.c [new file with mode: 0644]

index 18b106ad84127fe13ed597dddfbe486d8e35a58e..27c2e676e650224f8c29934e7957992344dd966c 100644 (file)
@@ -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 (file)
index 0000000..c15d731
--- /dev/null
@@ -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;
+}