[cfe-commits] r55635 - in /cfe/trunk: lib/Lex/Preprocessor.cpp test/Parser/block-block-storageclass.c

Daniel Dunbar daniel at zuster.org
Tue Sep 2 09:48:04 PDT 2008


Two comments:

(1) I think this is a typo:
+    DefineBuiltinMacro(Buf, "__block=__attribute__((__
>
> blocks__(byref)))");


(2) Should we really be defining the attributes to nothing when
block support is not enabled? This may break working code which
uses those names.

 - Daniel

On Tue, Sep 2, 2008 at 8:20 AM, Steve Naroff <snaroff at apple.com> wrote:

> 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;
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20080902/2ec098b9/attachment.html>


More information about the cfe-commits mailing list