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 18b106a..27c2e67 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -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.
 }
 
diff --git a/test/Parser/block-block-storageclass.c b/test/Parser/block-block-storageclass.c
new file mode 100644
index 0000000..c15d731
--- /dev/null
+++ b/test/Parser/block-block-storageclass.c
@@ -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;
+}