[cfe-commits] r55767 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/Basic/DiagnosticKinds.def lib/AST/ASTContext.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp

Mike Stump mrs at apple.com
Thu Sep 4 16:58:24 PDT 2008


On Sep 4, 2008, at 12:14 PM, Eli Friedman wrote:
>> +    /// BlockVoidPointer - The assignment is between a closure  
>> pointer and
>> +    /// void*, we accept for now.
>
> I don't see any good reason to accept this; it'll just destroy the  
> block pointer.

void * is the canonical opaque type, and block pointers can be pushed  
into and pulled out of a void * per the usual C rules.

> Just to double-check, the comparison is roughly equivalent to memcmp  
> for block pointers?

Yes, I think so.

> The code as-is won't work correctly for cases like

> "int a(int(^b)(void)){return b  == (void*)0}".

gcc does this:

$ cat t.c
int a(int(^b)(void)) {return b  == (void*)0; }
mrs $ gcc -S t.c -fblocks -fomit-frame-pointer -O9
mrs $ cat t.s
	.text
	.align 4,0x90
.globl _a
_a:
	xorl	%eax, %eax
	cmpl	$0, 4(%esp)
	sete	%al
	ret
	.subsections_via_symbols

clang should do something similar when done.



More information about the cfe-commits mailing list