[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 10:06:44 PDT 2008


On Sep 2, 2008, at 12:48 PM, Daniel Dunbar wrote:

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

It's not a typo, but it is a bug:-) __byref is deprecated and clang  
doesn't need to support it. I will remove it (thanks).

> (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.
>

I am following the GCC "lead" here. I thought it was odd as well.

Variables names with __ preceding them are less likely to break code.

I will discuss with Fariborz...

snaroff

>  - 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/a1524e9f/attachment.html>


More information about the cfe-commits mailing list