[llvm-commits] [llvm-gcc-4.2] r55723 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/

Bill Wendling isanbard at gmail.com
Wed Sep 3 13:45:00 PDT 2008


Author: void
Date: Wed Sep  3 15:44:59 2008
New Revision: 55723

URL: http://llvm.org/viewvc/llvm-project?rev=55723&view=rev
Log:
Adding a mass of C++ Blocks tests. This syncs with Apple's GCC r150332.

Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5774132.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5862465.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5992047.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-6084601.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-args.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-as-object.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcglobal.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcivar.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcstrongcast.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgcivar.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-bad-def.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-storageclass.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-4.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-5.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-6.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-7.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-8.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-attribute.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-block.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-call.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-codegen-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-complicated-type.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-conditional-test.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-const.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-continuation.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-copy-destroy.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-cxx98-off-default.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dup-invoke_impl.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-encoding.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-enum.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-error-global-byref.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-do.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-goto.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-nested-while.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-switch.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-while.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-block.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-implicit-byref.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-helloworld.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-block.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-global-block.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-implicit-byref.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivar.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivarlayout.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-literal.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-local-stack.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-misc.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-3.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global-copied-var-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-3.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nonnull-test.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-assignment.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type-match.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-predef.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-exp.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readonly-diag.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgc.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgcivar.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-return.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-sync-compare-and-swap.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-parameter.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-warn.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/fold-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/init-3.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-1.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-2.C
Removed:
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/4474655.C

Removed: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/4474655.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/4474655.C?rev=55722&view=auto

==============================================================================
    (empty)

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5774132.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/5774132.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5774132.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/5774132.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,8 @@
+extern "C" void abort (void);
+extern "C" int printf(const char*, ...);
+struct foo { unsigned long long x; } x;
+int main() {
+  /* printf("%d\n", __alignof__(x.x)); */
+  if (__alignof__ (x) != __alignof__ (x.x))
+    abort ();
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5862465.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-5862465.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5862465.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5862465.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,11 @@
+/* APPLE LOCAL file 5862465 */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+void enumerateObjectsWithOptions(unsigned int x, void (^block)(char *obj, unsigned int idx, signed char *stop))
+{
+  signed char stop = (signed char)0;
+  char *item;
+  unsigned int idx = 10;
+  for ( ; idx > 0 ; idx--)
+    block(item, idx, &stop);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-5988451.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,49 @@
+/* APPLE LOCAL file radar 5988451 */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fblocks" { target *-*-darwin* } } */
+/* { dg-do compile } */
+
+#import <Cocoa/Cocoa.h>
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_item_s *dispatch_item_t;
+
+typedef void (^dispatch_block_t)(dispatch_item_t item);
+
+void dispatch_call(dispatch_queue_t queue,
+ dispatch_block_t work,
+ dispatch_block_t completion,
+ void* context,
+ dispatch_item_t *item);
+
+void dispatch_apply_wait(dispatch_block_t work,
+     unsigned iterations,
+     void *context);
+
+
+
+ at interface TestController : NSObject {
+
+}
+
+-(IBAction) test:(id)sender;
+
+ at end
+
+ at implementation TestController
+
+-(IBAction)test:(id)sender
+{
+  dispatch_queue_t queue;
+
+  dispatch_call(queue,
+    ^(dispatch_item_t item) {
+      dispatch_apply_wait(^(dispatch_item_t item) {
+                            [NSValue valueWithPointer:self];
+                          },
+                          10,NULL);
+    },
+    ^(dispatch_item_t item) {NSLog(@"test");},
+    NULL, NULL);
+}
+
+
+ at end

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5992047.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-5992047.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5992047.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5992047.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,22 @@
+/* APPLE LOCAL file radar 5992047 */
+/* Check that with a previous declaration of _Block_destroy, test case
+   compiles with no error or ICE. */
+/* { dg-options "-fblocks" } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#define Block_destroy(xxx) _Block_destroy((const void *)(xxx))
+void _Block_destroy(const void *aBlock);
+
+typedef struct dispatch_item_s *dispatch_item_t;
+typedef void (^completion_block_t)(void);
+
+int main()
+{
+  completion_block_t X;
+
+  completion_block_t (^block)(dispatch_item_t) = ^(dispatch_item_t item) {
+    return X;
+  };
+
+  block(0);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-6084601.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-6084601.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-6084601.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-6084601.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,11 @@
+/* APPLE LOCAL file radar 6084601 */
+/* block are OK with -std=c99 when objective-c programs are involved. */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -std=c++98 -Werror" { target *-*-darwin* } } */
+
+typedef int (^test_block_t)();
+
+int main(int argc, char **argv) {
+    test_block_t tb = ^(){ return 1; };
+
+    return tb();
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-args.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-args.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-args.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-args.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,26 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void take(void*);
+
+void test() {
+  take(^(int x){});
+  take(^(int x, int y){});
+  take(^(int x, int y){});
+  take(^(int x, int x){});  /* { dg-error "redeclaration of" } */
+			    /* { dg-error "previously declared" "" { target *-*-* } 11 } */
+
+
+  take(^(int x) { return x+1; });
+
+  int (^CP)(int) = ^(int x) { return x*x; };
+  take(CP);
+
+  int arg;
+  ^{return 1;}();
+  ^{return 2;}(arg);  /* { dg-error "too many arguments to block call" } */
+  ^(void){return 3;}(1);  /* { dg-error "too many arguments to block call" } */
+  ^(){return 4;}(arg);   /* { dg-error "too many arguments to block call" } */
+  ^(int x, ...){return 5;}(arg, arg);   /* Explicit varargs, ok. */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-as-object.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-as-object.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-as-object.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-as-object.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,24 @@
+/* APPLE LOCAL file radar 5809099 */
+/* compile-only test to test that we can cast back and forth a block pointer
+   type to an 'id' type and sending a message to an object of block pointer type.
+*/
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++" { target *-*-darwin* } } */
+#import <Foundation/Foundation.h>
+
+void bar() { }
+
+void foo() {
+   id object = [[NSObject new] init];
+   void (^x)(void) = ^{ bar(); };
+   void *y = (void *)x;
+   x = (void (^)(void))y;
+   /* Test for type-cast of an 'id' type to a block pointer. */
+   x = (void (^)(void))[object result];
+
+   /* Test for cat of a block pointer to an 'id'. */
+   object = (id)x;
+
+  /* Test for sending a message to a block pointer. */
+  [x result];
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcglobal.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assigngcglobal.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcglobal.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcglobal.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,38 @@
+/* APPLE LOCAL file radar 5832193 */
+/* assigning a Block into a global should elicit a global write-barrier under GC */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+
+id objc_assign_global(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_ivar(id val, id dest, long offset) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_strongCast(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+
+void (^GlobalVoidVoid)(void);
+
+
+int main(char *argc, char *argv[]) {
+  __byref int i = 0;
+   // assigning a Block into a global should elicit a global write-barrier under GC
+   GlobalVoidVoid = ^ { ++i; };
+   return GlobalInt - 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcivar.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assigngcivar.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcivar.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcivar.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,57 @@
+/* APPLE LOCAL file radar 5832193 */
+/* assigning a Block into an ivar should elicit a  write-barrier under GC */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#ifdef objc_assign_ivar
+#define __objc_assign_ivar objc_assign_ivar
+#endif
+#include <Foundation/Foundation.h>
+
+#undef objc_assign_ivar
+
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+int GlobalInt = 0;
+
+id objc_assign_global(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_ivar_Fast(id val, id dest, ptrdiff_t offset) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_ivar(id val, id dest, ptrdiff_t offset) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_strongCast(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+ at interface TestObject : NSObject {
+ at public
+    void (^ivarBlock)(void);
+    id x;
+}
+ at end
+
+ at implementation TestObject
+ at end
+
+
+int main(char *argc, char *argv[]) {
+  __byref int i = 0;
+  TestObject *to = [[TestObject alloc] init];
+  // assigning a Block into an ivar should elicit a  write-barrier under GC
+  to->ivarBlock =  ^ { ++i; };		// fails to gen write-barrier
+  //to->x = to;				// gens write-barrier
+  return GlobalInt - 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcstrongcast.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assigngcstrongcast.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcstrongcast.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assigngcstrongcast.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,45 @@
+/* APPLE LOCAL file radar 5832193 */
+/* assigning a Block into an struct slot should elicit a write-barrier under GC */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#ifdef objc_assign_ivar
+#define __objc_assign_ivar objc_assign_ivar
+#endif
+#include <Foundation/Foundation.h>
+
+#undef objc_assign_ivar
+
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+int GlobalInt = 0;
+
+id objc_assign_global(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_ivar(id val, id dest, ptrdiff_t offset) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+id objc_assign_strongCast(id val, id *dest) {
+    GlobalInt = 1;
+    return (id)0;
+}
+
+typedef struct {
+    void (^ivarBlock)(void);
+} StructWithBlock_t;
+
+
+int main(char *argc, char *argv[]) {
+   StructWithBlock_t *swbp = (StructWithBlock_t *)malloc(sizeof(StructWithBlock_t*));
+   __byref int i = 10;
+   // assigning a Block into an struct slot should elicit a write-barrier under GC
+   swbp->ivarBlock = ^ { ++i; };
+   return GlobalInt - 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assignweakgc-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,41 @@
+/* APPLE LOCAL file radar 5882266 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+int GlobalInt2 = 0;
+
+id objc_assign_weak(id value, id *location) {
+  GlobalInt = 1;
+  *location = value;
+  return value;
+}
+
+id objc_read_weak(id *location) {
+  GlobalInt2 = 1;
+  return *location;
+}
+
+//void (^GlobalVoidVoid)(void);
+
+int* (^__weak Henry)(void);
+
+int main(char *argc, char *argv[]) {
+    // an object should not be retained within a stack Block
+  __byref int i = 0;
+  void (^local)(void);
+  Henry = ^ { ++i; return &i; };
+  if (GlobalInt == 1) {
+    printf("%s: success\n", argv[0]);
+    exit(0);
+  } else {
+    printf("%s: problem with weak write-barrier assignment of stack block\n", argv[0]);
+  }
+  exit(1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assignweakgc.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgc.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,41 @@
+/* APPLE LOCAL file radar 5882266 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+int GlobalInt2 = 0;
+
+id objc_assign_weak(id value, id *location) {
+    GlobalInt = 1;
+    *location = value;
+    return value;
+}
+
+id objc_read_weak(id *location) {
+    GlobalInt2 = 1;
+    return *location;
+}
+
+//void (^GlobalVoidVoid)(void);
+
+void (^__weak Henry)(void);
+
+int main(char *argc, char *argv[]) {
+  // an object should not be retained within a stack Block
+  __byref int i = 0;
+  void (^local)(void);
+  Henry = ^ { ++i; };
+  if (GlobalInt == 1) {
+    printf("%s: success\n", argv[0]);
+    exit(0);
+  } else {
+    printf("%s: problem with weak write-barrier assignment of stack block\n", argv[0]);
+  }
+  exit(1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgcivar.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-assignweakgcivar.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgcivar.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-assignweakgcivar.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,50 @@
+/* APPLE LOCAL file radar 5882266 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+int GlobalInt2 = 0;
+
+id objc_assign_weak(id value, id *location) {
+    GlobalInt = 1;
+    *location = value;
+    return value;
+}
+
+id objc_read_weak(id *location) {
+    GlobalInt2 = 1;
+    return *location;
+}
+
+ at interface Foo : NSObject {
+ at public
+    void (^__weak ivar)(void);
+}
+ at end
+ at implementation Foo
+ at end
+
+//void (^GlobalVoidVoid)(void);
+
+void (^__weak Henry)(void);
+
+int main(char *argc, char *argv[]) {
+  // an object should not be retained within a stack Block
+  __byref int i = 0;
+  void (^local)(void);
+  Foo *foo = [[Foo alloc] init];
+  foo->ivar = ^ { ++i; };
+  if (GlobalInt == 1) {
+    printf("%s: success\n", argv[0]);
+    exit(0);
+  } else {
+    printf("%s: problem with weak write-barrier assignment of ivar\n", argv[0]);
+  }
+  exit(1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-bad-def.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-bad-def.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-bad-def.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-bad-def.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file radar 5985368 */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+int main(void)
+{
+        void (^b)(void) { }; /* { dg-error "expected primary-expression" } */
+                            /* { dg-error "expected" "" { target *-*-* } 7 } */
+
+
+        return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-block-property-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,22 @@
+/* APPLE LOCAL file radar 5831920 */
+#import <Foundation/Foundation.h>
+/* Test a property with block type. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++" { target *-*-darwin* } } */
+
+#include <stdio.h>
+
+void * _NSConcreteStackBlock;
+
+ at interface TestObject {
+
+}
+ at property(copy, readonly) int (^getIntCopy)(void);
+ at property(retain, readonly) int (^getIntRetain)(void);
+ at end
+
+
+
+int main(char *argc, char *argv[]) {
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-block-property-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-property-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,48 @@
+/* APPLE LOCAL file radar 5831920 */
+#import <Foundation/Foundation.h>
+/* Test a property with block type. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -framework Foundation" { target *-*-darwin* } } */
+
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+ at interface TestObject : NSObject {
+
+int (^getIntCopy)(void);
+
+int (^getIntRetain)(void);
+
+}
+ at property int (^getIntCopy)(void);
+ at property int (^getIntRetain)(void);
+ at end
+
+ at implementation TestObject
+ at synthesize getIntCopy;
+ at synthesize getIntRetain;
+
+ at end
+
+int DoBlock (int (^getIntCopy)(void))
+{
+  return getIntCopy();
+}
+
+
+
+int main(char *argc, char *argv[]) {
+  int count;
+  __byref int val = 0;
+  TestObject *to = [[TestObject alloc] init];
+  to.getIntRetain = ^ { printf("\n Hello(%d)\n", val); return ++val; };
+  to.getIntCopy = to.getIntRetain;
+
+  count = DoBlock (to.getIntCopy);
+  if (count != 1)
+    abort();
+  count = DoBlock (to.getIntRetain);
+  count = DoBlock (to.getIntRetain);
+  return count - 3;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-storageclass.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-block-storageclass.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-storageclass.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-block-storageclass.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,20 @@
+/* APPLE LOCAL file 5932809 */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#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;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,15 @@
+/* APPLE LOCAL file 5932809 */
+/* { dg-options "-fblocks" } */
+/* { dg-do compile } */
+
+__byref  int X; /* { dg-warning "__byref attribute is only allowed on local variables - ignored" } */
+
+int foo(__byref int param) { /* { dg-warning "byref attribute can be specified on variables only - ignored" } */
+  __byref int OK = 1;
+
+  extern __byref double extern_var;	/* { dg-warning "__byref attribute is only allowed on local variables - ignored" } */
+  if (X) {
+	static __byref char * pch;	/* { dg-warning "__byref attribute is only allowed on local variables - ignored" } */	
+  }
+  return OK - 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-4.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-4.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-4.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-4.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,20 @@
+/* APPLE LOCAL file 5932809 */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+extern "C" {
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+};
+
+int main() {
+   __byref  int X = 1234;
+
+   int (^CP)(void) = ^{ X = X+1;  return X; }; 
+   CP();
+   printf ("X = %d\n", X);
+   return X - 1235;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-5.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-5.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-5.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-5.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,38 @@
+/* APPLE LOCAL file 5932809 */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+extern "C" void exit(int);
+
+typedef double (^myblock)(int);
+
+
+double test(myblock I) {
+  return I(42);
+}
+
+int main() {
+  int x = 1;
+  __byref int y = 2;
+  __byref int br_x;
+  int y1;
+  double res = test(^(int z){ y = x+z; return (double)x; }); 
+  printf("result = %f  x = %d y = %d\n", res, x, y);
+  if (x != 1 || y != 43)
+   exit(1);
+
+  br_x = x;
+  y1 = y;
+
+  res = test(^(int z){ br_x = br_x+z; return (double)y1; }); 
+  printf("result = %f  br_x = %d y1 = %d\n", res, br_x, y1);
+  if (br_x != 43 || y1 != 43)
+    exit(1);
+
+  return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-6.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-6.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-6.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-6.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,32 @@
+/* APPLE LOCAL file 5932809 */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+extern "C" void exit(int);
+
+typedef double (^myblock)(int);
+
+
+double test(myblock I) {
+  return I(42);
+}
+
+int main() {
+  __byref int x = 1;
+  __byref int y = 2;
+  double res = test(^(int z){ y = x+z; return (double)x; }); 
+  printf("result = %f  x = %d y = %d\n", res, x, y);
+  if (x != 1 || y != 43)
+   exit(1);
+
+  res = test(^(int z){ x = x+z; return (double)y; }); 
+  printf("result = %f  x = %d y = %d\n", res, x, y);
+  if (x != 43 || y != 43)
+    exit(1);
+  return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-7.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-7.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-7.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-7.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,41 @@
+/* APPLE LOCAL file radar 5932809 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -lobjc" { target *-*-darwin* } } */
+
+#include <stdio.h>
+
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int i;
+
+int foo() {
+   __byref  id FFFFFF;
+   __byref  id Q;
+   ^{ FFFFFF = 0; }; 
+
+   if (i)
+   {
+     __byref  id FFFFFF;
+     __byref  id Q;
+     ^{ FFFFFF = 0; }; 
+   }
+}
+
+int main() {
+   __byref  id X;
+   __byref  id X1;
+   ^{  X = 0; }; 
+
+   if (i)
+   {
+     __byref  id X;
+     __byref  id X1;
+     ^{ X = 0; }; 
+   }
+   return 0;
+}
+
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-8.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-blocks-test-8.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-8.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-blocks-test-8.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,122 @@
+/* APPLE LOCAL file radar 5932809 */
+/* Test the __byreg runtime features. */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -framework Foundation" { target i?86-*-darwin*  } } */
+/* { dg-do run { target i?86-*-darwin* } } */
+/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */
+
+#include <objc/Object.h>
+#import <Foundation/Foundation.h>
+
+void * _NSConcreteStackBlock;
+
+int CalledRetain = 0;
+
+extern "C" id objc_msgSend(id target, SEL cmd, ...) {
+    printf("[%p %s] called\n", target, sel_getName(cmd));
+    if (!strcmp(sel_getName(cmd), "retain")) {
+        CalledRetain = 1;
+    }
+    return target;
+}
+
+ at interface DumbObject : NSObject {
+}
+ at end
+id newDumbObject() {
+    DumbObject *result = (DumbObject *)calloc(sizeof(DumbObject), 1);
+    result->isa = objc_getClass("DumbObject"); /* {  dg-warning "instance variable" } */
+    return result;
+}
+
+ at implementation DumbObject
++ new {
+    return newDumbObject();
+}
++ (void) initialize { }
+- forward:(SEL)msg :(long *)params {
+    printf("forward:: with %s called\n", sel_getName(msg));
+    return self;
+}
+ at end
+
+//#include <Block_private.h>
+
+enum {
+    BLOCK_NEEDS_FREE =        (1 << 24),
+    BLOCK_HAS_COPY_DISPOSE =  (1 << 25),
+    BLOCK_NO_COPY =           (1 << 26), // interim byref: no copies allowed
+    BLOCK_IS_GC =             (1 << 27),
+};
+
+struct Block_basic {
+    void *isa;
+    int Block_flags;  // int32_t
+    int Block_size; // XXX should be packed into Block_flags
+    void (*Block_invoke)(void *);
+    void (*Block_copy)(void *dst, void *src);
+    void (*Block_dispose)(void *);
+    //long params[0];  // generic space for const & byref hidden params, return value, variable on needs of course
+};
+struct Block_byref {
+    //long reserved;
+    struct Block_byref *forwarding;
+    int flags;//refcount;
+    int size;
+    void (*byref_keep)(struct Block_byref *dst, struct Block_byref *src);
+    void (*byref_destroy)(struct Block_byref *);
+    // long shared[0];
+};
+
+
+int ByrefAssignCopy = 0;
+
+void _Block_byref_assign_copy(void *destp, void *source) {
+    struct Block_byref *src = (struct Block_byref *)source;
+    ByrefAssignCopy = 1;
+    // lets look at the Block_byref
+    if ((src->flags & BLOCK_HAS_COPY_DISPOSE) == 0) {
+        printf("byref data block does not have bit saying that copy/dispose helper routines are present\n");
+        return;
+    }
+    printf("calling out to byref copy helper at %p\n", src->byref_keep);
+    int junk[100];
+    src->byref_keep((struct Block_byref *)junk, src);
+}
+
+void _Block_byref_release(void *source) {
+    struct Block_byref *src = (struct Block_byref *)source;
+    src->byref_destroy(src);
+}
+
+int main(int argc, char *argv[]) {
+    id __byref dumbo = newDumbObject(); //[DumbObject new];
+    void (^dummy)(void) = ^{ 
+        [dumbo self];
+    };
+
+    struct Block_basic *aBlock = (struct Block_basic *)(void *)dummy;
+    if ((aBlock->Block_flags & BLOCK_HAS_COPY_DISPOSE) == 0) {
+        printf("Block should have a NON_POD copy/destroy helpers and flags to say so, but doesn't\n");
+        return 1;
+    }
+
+    char result[200];
+    printf("calling out to copy support helper at %p\n", aBlock->Block_copy);
+    (*aBlock->Block_copy)(result, aBlock); // do fixup
+
+    // The copy/destroy helper should have had a callout  to _Block_byref_assign_copy for its byref block
+    if (! ByrefAssignCopy) {
+        printf("_Block_copy_assign not called\n");
+        return 1;
+    }
+
+    // the copy/destroy helper of the byref should have done dst->object = [src->object retain]
+    if (! CalledRetain) {
+        printf("byref block support helper did not call retain\n");
+        return 1;
+    }
+
+    (*aBlock->Block_dispose)(aBlock);
+
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-attribute.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-byref-attribute.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-attribute.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-attribute.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,13 @@
+/* APPLE LOCAL file radar 6096219 */
+/* Test that __byref attribute can be used directly. */
+/* { dg-options "-mmacosx-version-min=10.5 -fblocks" { target *-*-darwin* } } */
+/* { dg-do compile } */
+
+int main()
+{
+        __byref int JJJJ;
+	__attribute__((__blocks__(byref))) int III;
+
+	int (^XXX)(void) = ^{ return III+JJJJ; };
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-block.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-byref-block.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-block.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref-block.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,16 @@
+/* APPLE LOCAL file radar 6180456  */
+/* { dg-do run { target *-*-darwin*  } } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin*  } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "-m64" } { "" } } */
+
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+  __block void(*bobTheFunction)(void);
+  __block void(^bobTheBlock)(void);
+
+  bobTheBlock = ^{;};
+
+  return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-byref.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-byref.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,26 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* Testing byref syntax checking. */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+int main() {
+	__byref int x, y;
+	^{ };
+
+	^{ int r; return x+y+r; }; 
+
+	^{ int r; return x+y+r; 
+           ^{
+	      int r; return x+y; 
+	    };
+         };
+
+	/* Assigning to byref variables. */
+	^{ x = 1;}; 
+
+	^{ 
+	   if (x != y)
+	     x = y = 100;
+	 };
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-call.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-call.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-call.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-call.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,54 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+
+int (^IFP) ();
+int (^II) (int);
+int main() {
+	int (^PFR) (int) = IFP;	/* { dg-error "cannot convert" } */
+	PFR = II;
+
+
+	int (^IFP) () = PFR;	/* { dg-error "cannot convert" } */
+
+
+	const int (^CIC) () = IFP;
+
+	const int (^CICC) () = CIC;
+
+	int * const (^IPCC) () = 0;
+
+	int * const (^IPCC1) () = IPCC;
+
+	int * (^IPCC2) () = IPCC;	
+
+	int (^IPCC3) (const int) = PFR;	
+
+	int (^IPCC4) (int, char (^CArg) (double));
+
+
+	int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
+
+	int (^IPCC6) (int, char (^CArg) (float))  = IPCC4; /* { dg-error "cannot convert" } */
+
+	IPCC2 = 0;
+	IPCC2 = 1; /* { dg-error "cannot convert" } */
+	int (^x)() = 0;
+	int (^y)() = 3;   /* { dg-error "cannot convert" } */
+	int a = 1;
+	int (^z)() = a+4;   /* { dg-error "cannot convert" } */
+	return 0;
+}
+
+int blah() {
+	int (^IFP) (float);
+	char (^PCP)(double, double, char);
+
+	IFP(1.0);
+	IFP (1.0, 2.0);	/* { dg-error "too many arguments to block call" } */
+
+	char ch = PCP(1.0, 2.0, 'a');
+	return PCP(1.0, 2.0);	/* { dg-error "too few arguments to block call" } */
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-codegen-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-codegen-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-codegen-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-codegen-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,33 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+extern "C" void exit(int);
+
+extern void exit(int);
+
+typedef double (^myblock)(int);
+
+
+double test(myblock I) {
+  return I(42);
+}
+
+int main() {
+  __byref int x = 1;
+  __byref int y = 2;
+  double res = test(^(int z){ y = x+z; return (double)x; }); 
+  printf("result = %f  x = %d y = %d\n", res, x, y);
+  if (x != 1 || y != 43)
+   exit(1);
+
+  res = test(^(int z){ x = x+z; return (double)y; }); 
+  printf("result = %f  x = %d y = %d\n", res, x, y);
+  if (x != 43 || y != 43)
+    exit(1);
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-complicated-type.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-complicated-type.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-complicated-type.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-complicated-type.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,20 @@
+/* APPLE LOCAL file radar 5988995 */
+/* Type compatibility issue for blocks which return blocks. */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+int (^f)(char, int);
+
+int (^farray[10])(float, int);
+
+int (^func(int x))(char, int) {
+   return f;
+}
+
+// intent: block taking int returning block that takes char,int and returns int
+int (^(^block)(double x))(char, short);
+
+void foo() {
+   block = ^(double x){ return ^(char c, short y) { return (int)c + y; };}; /* { dg-error "returning block that lives on the local stack" } */
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-conditional-test.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-conditional-test.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-conditional-test.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-conditional-test.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,25 @@
+/* APPLE LOCAL file radar 5928316 */
+/* Test for use of block pointer in a conditional expression. */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+extern "C" void abort (void);
+
+typedef int (^myblock)(int);
+
+int main() {
+        myblock b = ^(int a){ return a * a; };
+        if (1 && (b)) {
+                int i = b(3);
+	        if (i != 9)
+		  abort();
+		i = b(10);
+		if (i != 100)
+		  abort();
+        }
+        return 0;
+}
+
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-const.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-const.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-const.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-const.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,17 @@
+/* APPLE LOCAL file radar 5814025 */
+/* Test that a one cannot assign to a 'const' block pointer variable. */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+#import <stdio.h>
+
+void foo(void) { printf("I'm in foo\n"); }
+void bar(void) { printf("I'm in bar\n"); }
+
+int main(char *argc, char *argv[]) {
+    void (^const  blockA)(void) = ^ { printf("hello\n"); };
+    blockA = ^ { printf("world\n"); }; /* { dg-error "assignment of read-only variable" } */
+    return 0;
+}
+
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-continuation.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-continuation.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-continuation.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-continuation.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,44 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void takeblock (void (^)());
+
+int main() {
+  while (1) {
+    takeblock(^{
+	break;		/* { dg-error "break statement not within loop or switch" } */
+	while (1) break;/* ok */
+	goto label1;	/* { dg-error "goto not allowed in block literal" } */
+			/* { dg-error "label" "" { target *-*-* } 12 } */
+      });
+  label1:
+    break; /* OK */
+    if (1)
+      continue; /* OK */
+  }
+
+  void (^vcl)(void) =
+    ^{
+    break; /* { dg-error "break statement not within loop or switch" } */
+
+    while (1) {
+      void (^vcl1) (void) = ^{};
+
+      break;
+    }
+  };
+
+  void (^VCL)(void) =
+    ^{
+    while (1) {
+      int i;
+      void (^vcl1) (void) = ^{ continue; }; /* { dg-error "continue statement not within a loop" } */
+      break;
+      for (i = 0; i < 100; i++)
+	if (i == 10)
+	  break;
+    }
+  };
+  goto label1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-copy-destroy.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-copy-destroy.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-copy-destroy.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-copy-destroy.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,30 @@
+/* APPLE LOCAL file 5782740 - blocks */
+/* Test generation of copy/destroy helper function. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fblocks" { target *-*-darwin* } } */
+
+#import <Cocoa/Cocoa.h>
+
+ at interface Root @end
+
+extern void bar(double (^cp)(int));
+
+ at implementation Root
+
+- (void)example {
+ __byref int y, x;
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ NSAutoreleasePool *relpool = [NSAutoreleasePool new];
+ bar(^(int z){ y = x+z;  [pool drain]; if (y) y++; [relpool release]; return y+2.0; }); 
+}
+ at end
+
+int main()
+{
+	int x = 10;
+	int (^P) (void) = ^ { return x; };
+
+	int (^Q) (void) = ^ { return P(); };
+}
+/* { dg-final { scan-assembler "___copy_helper_block_" } } */
+/* { dg-final { scan-assembler "___destroy_helper_block_" } } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-cxx98-off-default.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-cxx98-off-default.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-cxx98-off-default.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-cxx98-off-default.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,10 @@
+/* APPLE LOCAL file radar 5811887 */
+/* Test that with -std=c++98 blocks is off by default. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++98" } */
+
+int main() {
+  void (^Vblock)(void) = ^{};	/* { dg-error "expected primary" } */
+				/* { dg-error "was not declared" "" { target *-*-* } 7 } */
+				/* { dg-error "expected" "" { target *-*-* } 7 } */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-debug-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file 5939894 */
+/* Verify that the desired debugging type is generated for a structure
+   member that is a pointer to a block.  */
+
+/* { dg-do compile } */
+/* { dg-options "-g -O0 -fblocks -dA" } */
+/* { dg-final { scan-assembler "invoke_impl.*DW_AT_name" } } */
+
+struct inStruct {
+  void (^genericBlockPtr)();
+} is;
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-debug-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-debug-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,10 @@
+/* APPLE LOCAL file 5939894 */
+/* Verify that the desired debugging type is generated for a pointer
+   to a block.  */
+
+/* { dg-do compile } */
+/* { dg-options "-g -O0 -fblocks -dA" } */
+/* { dg-final { scan-assembler "invoke_impl.*DW_AT_name" } } */
+
+void (^os)();
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dup-invoke_impl.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-dup-invoke_impl.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dup-invoke_impl.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-dup-invoke_impl.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,43 @@
+/* APPLE LOCAL file radar 5939894 */
+/* Check that if a definition of struct invoke_impl already exist, then use it. */
+/* { dg-options "-fblocks" } */
+/* { dg-do compile } */
+
+struct invoke_impl {
+ void   *isa;
+ int Flags;
+ int Size;
+ void *FuncPtr;
+};
+
+enum numbers
+{
+    zero, one, two, three, four
+};
+
+typedef enum numbers (^myblock)(enum numbers);
+
+
+double test(myblock I) {
+  return I(three);
+}
+
+int main() {
+  __byref enum numbers x = one;
+  __byref enum numbers y = two;
+
+  myblock CL = ^(enum numbers z)
+		{ y = z; 
+		 test (
+		 ^ (enum numbers z) { 
+		   x = z;
+		   return (enum numbers) four;
+		  }
+		  );
+		  return x;
+		};
+
+  enum numbers res = (numbers)test(CL);
+
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-encoding.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-encoding.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-encoding.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-encoding.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,24 @@
+/* APPLE LOCAL file radar 5849129 */
+/* Test for encoding of a block pointer as '@'. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+
+ at interface Test : NSObject
+- (void)method1:(void *(^)(void *))a;
+- (void)method2:(void *(^[5])(void *))b;
+ at end
+
+ at implementation Test
+- (void)method1:(void *(^)(void *))a {}
+- (void)method2:(void *(^[5])(void *))b {}
+ at end
+
+int main() {
+    return 0;
+}
+/* { dg-final { scan-assembler "v12 at 0:4@?" { target ilp32 } } } */
+/* { dg-final { scan-assembler "v24 at 0:8@?" { target lp64 } } } */
+/* { dg-final { scan-assembler "v12 at 0:4\[5@?\]" { target ilp32 } } } */
+/* { dg-final { scan-assembler "v24 at 0:8\[5@?\]" { target lp64 } } } */

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-enum.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-enum.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-enum.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-enum.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,38 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* Test use of enumerators in blocks. */
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+extern "C" void exit(int);
+
+enum numbers
+{
+    zero, one, two, three
+};
+
+typedef enum numbers (^myblock)(enum numbers);
+
+
+enum numbers test(myblock I) {
+  return I(three);
+}
+
+int main() {
+  __byref enum numbers x = one;
+  __byref enum numbers y = two;
+
+  enum numbers res = test(^(enum numbers z){ y = z; return x; }); 
+
+  if (x != one || y != three || res != one)
+   exit(1);
+
+  res = test(^(enum numbers z){ x = z; return x; }); 
+  if (x != three || res != three)
+    exit(1);
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-error-global-byref.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-error-global-byref.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-error-global-byref.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-error-global-byref.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,28 @@
+/* APPLE LOCAL file radar 5803600 */
+/* Test for propery handling of 'byref' globals in nested blocks. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+
+void CallBlock (void (^voidvoidBlock)(void)) {
+   voidvoidBlock();
+}
+
+int glob = 10;
+static int stat = 10;
+
+int foo() {
+    static int static_local = 10;
+    int local;
+    CallBlock( ^ {++glob;  		
+		  CallBlock(^ { 
+				++glob;
+				stat++;
+			        ++static_local;
+			      });
+		  ++local;  		/* { dg-error "increment of read-only variable" } */
+		  ++static_local;
+		 });
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-do.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-do.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-do.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-do.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,32 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+
+extern void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+int main() {
+  {
+    __byref int O1;
+    int p = 0;
+    do {
+      __byref int I1;
+      do {
+	__byref int J1;
+	if (p == 2)
+	  break;
+      } while ( ++p < 3);
+      if (p == 4)
+	break;
+    } while (++p != 5);
+  }
+
+  return count-7;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-for.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,25 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+int main() {
+  {
+    __byref int O1;
+    int i;
+    for (i = 1; i <= 5; i++)
+      {
+	__byref int I1;
+      }
+    if (count != 5)
+      abort();
+  }
+  return count - 6;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-for1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-for1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,33 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+#include <stdio.h>
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+int main() {
+  {
+    __byref int O1;
+    int i;
+    int p;
+    for (i = 1; i <= 5; i++) {
+      __byref int I1;
+      p = 0;
+      while (p != 10) {
+	__byref int II1;
+	if (p == 2)
+	  break;
+	++p;
+      }
+    }
+  }
+  return count-21;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-goto.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-goto.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-goto.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-goto.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,22 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do compile } */
+
+int main(int p) {
+  p = -5;
+  __byref int O1;
+  int i;
+ LOUT: ;
+  for (i = 1; i < 100; i++) {
+    __byref int I1;
+    while (p < 0) {
+      __byref int II1;	
+      if (p == 100)
+	goto LOUT;
+      ++p;
+      if (p == 2345)
+	break;
+    }
+  }
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-nested-while.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-nested-while.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-nested-while.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-nested-while.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+#include <stdio.h>
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+void objc_get_type_qualifiers (int flag, int type) {
+  while (flag--)
+    while (type++ < 4) {
+      __byref int W1;
+      __byref int W2;
+      if (type == 2)
+	break;
+    }
+}
+
+int main() {
+  objc_get_type_qualifiers (1, 0);
+  if (count != 4)
+    abort();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-return.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+#include <stdio.h>
+
+extern "C" void abort(void);
+void _Block_byref_assign_copy(void *a, void *b){};
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+
+int main1() {
+  __byref  int X = 1234;
+  if (X) {
+    __byref int local_BYREF = 100;
+    X += 100 + local_BYREF;
+    return count-2;
+  }
+  return -1;
+}
+
+int main() {
+  main1();
+  return count-2;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-return1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-return1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,40 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+#include <stdio.h>
+
+extern "C" void abort(void);
+void _Block_byref_assign_copy(void *a, void *b){};
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+void *_NSConcreteStackBlock;
+
+void FOO(int arg) {
+  __byref int X = 1234;
+  if (arg) {
+    __byref int local_BYREF = 100;
+    X += 100 + local_BYREF;
+    return;
+  }
+  ^{ X++; };
+  X = 1000;
+}
+
+int main() {
+  FOO(1);
+  if (count != 2)
+    abort();
+
+  count = 0;
+  FOO(0);
+  if (count != 1)
+    abort();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-switch.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-switch.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-switch.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-switch.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,70 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+#include <stdio.h>
+
+extern "C" void abort(void);
+void _Block_byref_assign_copy(void *a, void *b){};
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  printf ("%p\n", arg);
+  ++count;
+}
+
+int foo(int p, int q) {
+  __byref int O1;
+  switch (p) {
+  case 1:
+    {
+      __byref int I1;
+      I1 += 1;
+      break;
+    }
+  case 10:
+    {
+      __byref int J1;
+      break;
+    }
+  default :
+    {
+      __byref int D1;
+      __byref int D2;
+      switch (q)
+	{
+	case 11:
+	  {
+	    __byref int  Q1;
+	    break;
+	  }
+	default:
+	  {
+	    __byref int  ID1;
+	    __byref int  ID2;
+	  }
+	};
+      break;
+    }
+  }
+  return 0;
+}
+
+int main() {
+  foo (1, 0);
+  if (count != 2)
+    abort();
+
+  count = 0;
+  foo (12, 11);
+  if (count != 4)
+    abort();
+
+  count = 0;
+  foo (12, 13);
+  if (count != 5)
+    abort();
+
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-while.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-escape-while.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-while.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-escape-while.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,24 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+int main() {
+  {
+    __byref int O1;
+    int i = 0;
+    while (++i != 5) {
+      __byref int I1;
+    }
+    if (count != 4)
+      abort();
+  }
+  return count - 5;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-block.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-global-block.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-block.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-block.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,34 @@
+/* APPLE LOCAL file radar 5822844 */
+/* Test that blocks can be declared at global scope. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin* } } */
+#include <stdio.h>
+
+static void* _NSConcreteGlobalBlock;
+
+
+typedef void (^ HelloBlock_t)(const char * name);
+
+HelloBlock_t helloBlock = ^(const char * name)
+{
+  printf("Hello there, %s!\n", name);
+};
+
+static HelloBlock_t s_helloBlock = ^(const char * name)
+{
+  printf("Hello there, %s!\n", name);
+};
+
+int X = 1234;
+int (^CP)(void) = ^{ X = X+1;  return X; };
+
+int
+main(int argc, char * argv[])
+{
+  helloBlock("world");
+  s_helloBlock("world");
+
+  CP();
+  printf ("X = %d\n", X);
+  return X - 1235;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-global-byref-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,30 @@
+/* APPLE LOCAL file radar 5803005 */
+/* Test that all global variables referenced in blocks are treated as 'byref' as default. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+
+void CallBlock (void (^voidvoidBlock)(void)) {
+   voidvoidBlock();
+}
+
+int glob = 10;
+static int stat = 10;
+
+int foo() {
+  static int local = 10;
+  CallBlock( ^ { ++glob; ++stat; ++local;
+	         CallBlock(^ { ++glob; ++stat; ++local; });
+		 ++glob; ++stat; ++local; });
+
+  if (glob != 13 || stat != 13 || local != 13)
+    return 1;
+  return 0;
+}
+
+int main() {
+  return foo ();
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-global-byref-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,34 @@
+/* APPLE LOCAL file radar 6014138 */
+/* Test use of __byref on locals which will be used as 'byref' variables in blocks. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+void CallBlock (void (^voidvoidBlock)(void)) {
+   voidvoidBlock();
+}
+
+
+int foo() {
+    __byref int local_byref_1 = 10;
+    __byref int local_byref_2 = 10;
+    __byref int local_byref_3 = 10;
+
+    CallBlock( ^ { ++local_byref_1; ++local_byref_2; ++local_byref_3; 
+	          CallBlock(^ { ++local_byref_1; ++local_byref_2; ++local_byref_3; }); 
+		  ++local_byref_1; ++local_byref_2; ++local_byref_3; });
+
+    if (local_byref_1 != 13 || local_byref_2 != 13 || local_byref_3 != 13)
+      return 1;
+    return 0;
+}
+
+int main()
+{
+  return foo ();
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-global-byref.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-byref.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5803600 */
+/* Test that all global variables referenced in blocks are treated as 'byref' as default. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+
+void CallBlock (void (^voidvoidBlock)(void)) {
+   voidvoidBlock();
+}
+
+int glob = 10;
+static int stat = 10;
+
+int foo() {
+    static int local = 10;
+    CallBlock( ^ { ++glob; ++stat; ++local; 
+		  CallBlock(^ { ++glob; ++stat; ++local; }); 
+		  ++glob; ++stat; ++local; });
+
+    if (glob != 13 || stat != 13 || local != 13)
+      return 1;
+    return 0;
+}
+
+int main()
+{
+  return foo ();
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-implicit-byref.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-global-implicit-byref.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-implicit-byref.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-global-implicit-byref.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,20 @@
+/* APPLE LOCAL file radar 5803005 */
+/* Test that all globals are 'byref' as default. */
+/* { dg-options "-mmacosx-version-min=10.5" { target *-*-darwin* } } */
+/* { dg-do compile } */
+
+int a;
+static int s;
+extern int i;
+
+void foo() {
+   extern int b;
+   static int c;
+
+   ^ {  a  = 1;  // byref OK
+         b  = 2; // byref OK
+         s  = 5; // byref OK
+	 i = 12; // byref OK
+         c = 3;  // implicit byref OK
+     };
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-helloworld.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-helloworld.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-helloworld.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-helloworld.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,17 @@
+/* APPLE LOCAL file radar 6040305 */
+/* Test that we can run a simple block literal. */
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+#include <stdio.h>
+
+void* _NSConcreteStackBlock;
+
+int main()
+{
+    void (^xxx)(void) = ^{ printf("Hello world!\n"); };
+    
+    xxx();
+    return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-block.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-id-block.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-block.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-block.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,38 @@
+/* APPLE LOCAL file radar 5831855 */
+#import <Foundation/Foundation.h>
+/* Test that a block pointer can be converted back-and-forth to 'id' in
+   both initializsation and assignment without requiring a cast. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++" { target *-*-darwin* } } */
+
+void * _NSConcreteStackBlock;
+
+typedef void (^blockATYPE)(void);
+
+id myBlockFunc (void (^blockA)(void))
+{
+  return blockA;
+}
+
+blockATYPE MyBlockIdFunc (id id_arg)
+{
+  return id_arg;
+}
+
+int main(char *argc, char *argv[]) {
+    void (^blockA)(void) = ^ { printf("hello\n"); };
+    // an 'id' can be initialized wit a block.
+    id aBlock = blockA;
+
+    // a block should be assignable to an id
+    aBlock = blockA;
+
+    // an 'id' should be assignable to a block
+    blockA = aBlock;
+
+    blockA = myBlockFunc (^ { printf("hello\n"); });
+
+    aBlock = MyBlockIdFunc (aBlock);
+
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-global-block.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-id-global-block.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-global-block.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-id-global-block.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,39 @@
+/* APPLE LOCAL file radar 5822844 - global blocks */
+#import <Foundation/Foundation.h>
+/* Test that a block pointer can be converted back-and-forth to 'id' in
+   both initializsation and assignment without requiring a cast. */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -ObjC++" { target *-*-darwin* } } */
+
+void * _NSConcreteGlobalBlock;
+
+typedef void (^blockATYPE)(void);
+
+id myBlockFunc (void (^blockA)(void))
+{
+  return blockA;
+}
+
+blockATYPE MyBlockIdFunc (id id_arg)
+{
+  return id_arg;
+}
+
+void (^blockA)(void) = ^ { printf("hello\n"); };
+
+int main(char *argc, char *argv[]) {
+    // an 'id' can be initialized wit a block.
+    id aBlock = blockA;
+
+    // a block should be assignable to an id
+    aBlock = blockA;
+
+    // an 'id' should be assignable to a block
+    blockA = aBlock;
+
+    blockA = myBlockFunc (^ { printf("hello\n"); });
+
+    aBlock = MyBlockIdFunc (aBlock);
+
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-implicit-byref.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-implicit-byref.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-implicit-byref.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-implicit-byref.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,65 @@
+/* APPLE LOCAL file radar 5811191 */
+/* Test that all 'ivars' are treated as implicit byref. Its inclusing inside |...|
+   block is treated with a warning and ignored.
+*/
+/* { dg-do run } */
+/* { dg-options "-ObjC++ -mmacosx-version-min=10.5 -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+#import <Foundation/Foundation.h>
+
+void * _NSConcreteStackBlock;
+
+enum {
+    BLOCK_NEEDS_FREE =        (1 << 24),
+    BLOCK_HAS_COPY_DISPOSE =  (1 << 25),
+    BLOCK_NO_COPY =           (1 << 26), // interim byref: no copies allowed
+    BLOCK_IS_GC =             (1 << 27),
+};
+
+struct Block_basic {
+    void *isa;
+    //char flags; char size; short refcount;
+    int Block_flags;  // int32_t
+    int Block_size; // XXX should be packed into Block_flags
+    void (*Block_invoke)(void *);
+    void (*Block_copy)(void *dst, void *src);
+    void (*Block_dispose)(void *);
+    //long params[0];  // generic space for const & byref hidden params, return value, variable on needs of course
+};
+
+ at interface TestObject : NSObject {
+ at public
+    id aSlot;
+}
+- (int) testVerbosely:(int)verbose;
+
+
+ at end
+
+ at implementation TestObject
+
+
+- (int) testVerbosely:(int)verbose
+ {
+    aSlot = [[NSObject alloc] init];
+
+
+    void (^myBlock)(void) = ^{
+        printf("[aSlot retainCount] == %d\n", (int)[aSlot retainCount]);
+    };
+    struct Block_basic *basic = (struct Block_basic *)(void *)myBlock;
+    if (basic->Block_flags & BLOCK_NO_COPY)
+      abort ();
+
+   return 0;
+}
+
+
+ at end
+
+int main(int argc, char *argv[]) {
+    TestObject *to = [[TestObject alloc] init];
+
+    [to testVerbosely:1];
+    return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivar.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-ivar.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivar.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivar.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,69 @@
+/* APPLE LOCAL file 5782740 - blocks */
+/* Test generation of copy/destroy helper function. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fblocks" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+
+extern "C" void *Block_copy(const void *aBlock);
+
+ at interface TestObject : NSObject {
+ at public
+    int refcount;
+    id aSlot;
+}
+- (int) testVerbosely:(int)verbose;
+
+ at end
+
+ at implementation TestObject
+
+- (id) retain {
+    ++refcount;
+    return self;
+}
+
+- (int)retainCounter {
+    return refcount + 1;
+}
+
+- (void) release {
+   if (refcount == 0) [self dealloc];
+   else --refcount;
+}
+
+- (int) testVerbosely:(int)verbose
+ {
+    int errors = 0;
+    aSlot = [[NSObject alloc] init];
+
+    int initialRetainCounter = [self retainCounter];
+
+    void (^myBlock)(void) = ^{
+        printf("[aSlot retainCount] == %d\n", (int)[aSlot retainCount]);
+    };
+
+    int afterBlockRetainCounter = [self retainCounter];
+
+    void (^myBlockCopy)(void) = (void (^)(void))Block_copy(myBlock);
+
+    int afterBlockCopyRetainCounter = [self retainCounter];
+
+    if (afterBlockRetainCounter > initialRetainCounter) {
+        printf("testVerbosely: after block, retain count is %d vs before %d\n", afterBlockRetainCounter, initialRetainCounter);
+        ++errors;
+    }
+
+    if (afterBlockCopyRetainCounter <= afterBlockRetainCounter) {
+        printf("testVerbosely: block copy did not retain interior object\n");
+        ++errors;
+    }
+
+    if (errors == 0 && verbose) printf("testVerbosely: objc import object test success\n");
+    return errors;
+
+}
+ at end
+/* { dg-final { scan-assembler "___copy_helper_block_" } } */
+/* { dg-final { scan-assembler "___destroy_helper_block_" } } */
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivarlayout.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-ivarlayout.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivarlayout.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-ivarlayout.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,43 @@
+/* APPLE LOCAL file radar 6133042 */
+/* Check that ivars of block pointer types are scanned by GC */
+/* { dg-do run } */
+/* { dg-options "-ObjC++ -mmacosx-version-min=10.6 -fblocks -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-require-effective-target objc_gc } */
+
+#include <Foundation/Foundation.h>
+extern "C" const char *class_getIvarLayout(Class cls);
+
+ at interface TestObject : NSObject {
+    int (^getInt)(void);
+    BOOL b1;
+    int (^getFloat)(void);
+}
+ at property(assign, readonly) int (^getInt)(void);
+ at end
+
+ at implementation TestObject
+ at dynamic getInt;
+ at end
+
+int main(char *argc, char *argv[]) {
+    const char *layout = (char *)class_getIvarLayout([TestObject self]);
+    printf("layout is:\n");
+    int cursor = 0;
+    // we're looking for slot 1
+    int seeking = 1;
+    while (*layout) {
+        int skip = (*layout) >> 4;
+        int process = (*layout) & 0xf;
+        printf("(%x) skip %d, process %d\n", (*layout), skip, process);
+        cursor += skip;
+        if ((cursor <= seeking) && ((cursor + process) > seeking)) {
+            printf("Will scan desired %d element!\n", seeking);
+            return 0;
+        }
+        cursor += process;
+        ++layout;
+    }
+    printf("%s: ***failure, didn't scan slot %d\n", argv[0], seeking);
+    return 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-literal.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-literal.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-literal.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-literal.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,55 @@
+/* APPLE LOCAL file radar 5732232, 6034839 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void I( void (^)(void));
+void (^noop)(void);
+
+void nothing();
+int printf(const char*, ...);
+
+typedef void (^T) (void);
+
+void takeblock(T);
+int takeintint(int (^C)(int)) { return C(4); }
+
+T somefunction() {
+  if (^{ })
+    nothing();
+
+  noop = ^{};
+
+  noop = ^{printf("\nBlock\n"); };
+
+  I(^{ });
+
+  noop = ^; /* { dg-error "expected" } */
+
+  return ^{printf("\nBlock\n"); };  /* { dg-error "returning block that lives on the local stack" } */
+}
+
+void test2() {
+  int x = 4;
+
+  takeblock(^{ printf("%d\n", x); });
+  takeblock(^{ x = 4; });  /* { dg-error "assignment of read-only variable" } */
+}
+
+void (^test3())(void) {
+  return ^{};    /* { dg-error "returning block that lives on the local stack" } */
+}
+
+void test4() {
+  void (^noop)(void) = ^{};
+  void (*noop2)() = 0;
+}
+
+void test5() {
+  int y;
+
+  int (^c)(char);
+  (1 ? c : 0)('x');
+  (1 ? 0 : c)('x');
+
+  (1 ? c : c)('x');
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-local-stack.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-local-stack.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-local-stack.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-local-stack.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,8 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void (^test3())(void) {
+  return ^{};   /* { dg-error "returning block that lives on the local stack" } */
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-misc.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-misc.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-misc.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-misc.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,52 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void donotwarn();
+
+int (^IFP) ();
+int (^II) (int);
+int test1() {
+  int (^PFR) (int) = 0;	// OK
+  PFR = II;	// OK
+
+  if (PFR == II)	// OK
+    donotwarn();
+
+  if (PFR == IFP)  /* { dg-error "comparison between distinct pointer types" } */
+    donotwarn();
+
+  if (PFR == (int (^) (int))IFP) // OK
+    donotwarn();
+
+  if (PFR == 0) // OK
+    donotwarn();
+
+  if (PFR)	// OK
+    donotwarn();
+
+  if (!PFR)	// OK
+    donotwarn();
+
+  return PFR != IFP;  /* { dg-error "comparison between distinct pointer types" } */
+}
+
+int test2(double (^S)()) {
+  double (^I)(int)  = (double (^)(int))(void*) S;
+  (void*)I = (void *)S;  /* { dg-warning "target of assignment not really an lvalue; this will be a hard error in the future" } */
+
+  void *pv = I;
+
+  pv = S;		
+
+  I(1);
+
+  return (void*)I == (void *)S;
+}
+
+int^ x;  /* { dg-error "block pointer to non-function type is invalid" } */
+int^^ x1; /* { dg-error "block pointer to non-function type is invalid" } */
+
+int test3() {
+  char *^ y;  /* { dg-error "block pointer to non-function type is invalid" } */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-copied-var-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,30 @@
+/* APPLE LOCAL file radar 5988451 - nested blocks */
+/* This routine tests a nested block when a copied-in variable in the
+   inner block must be 'frozen' at the outer block so, it has the value
+   at the point of inner block declaration and not when block is envoked.
+*/
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+extern "C" void abort(void);
+
+void * _NSConcreteStackBlock;
+
+
+void callVoidVoid(void (^closure)(void)) {
+  closure();
+}
+
+int main(int argc, char *argv[]) {
+  int local_i_var = 1;
+
+  void (^vv)(void) = ^{
+    if (argc > 0) {
+      callVoidVoid(^{ if (local_i_var != 1) abort();  });
+    }
+  };
+
+  local_i_var = 2;
+  vv();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-copied-var-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5988451 */
+/* More testing of copied in variables in nested blocks. */
+/* { dg-options "-fblocks -mmacosx-version-min=10.5 -ObjC++ -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+
+#import <Foundation/Foundation.h>
+void *_NSConcreteStackBlock;
+
+id Global = nil;
+
+void callVoidVoid(void (^closure)(void)) {
+    closure();
+}
+
+int main(int argc, char *argv[]) {
+    id x = [[NSObject alloc] init];
+    id initial_x = x;
+
+    void (^vv)(void) = ^{
+        if (argc > 0) {
+            callVoidVoid(^{ Global = x; });
+        }
+    };
+
+    x = nil;
+    vv();
+    if (Global != initial_x) {
+        exit(1);
+    }
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-3.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-copied-var-3.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-3.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var-3.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,35 @@
+/* APPLE LOCAL file radar 5988451 */
+/* Testing of copied in parameter in nested blocks. */
+/* { dg-options "-fblocks -mmacosx-version-min=10.5 -ObjC++ -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+
+#import <Foundation/Foundation.h>
+void *_NSConcreteStackBlock;
+
+id Global = nil;
+
+void callVoidVoid(void (^closure)(void)) {
+    closure();
+}
+
+int foo(int argc, id x) {
+    id initial_x = x;
+
+    void (^vv)(void) = ^{
+        if (argc > 0) {
+            callVoidVoid(^{ Global = x; });
+        }
+    };
+
+    x = nil;
+    vv();
+    if (Global != initial_x) {
+        exit(1);
+    }
+    return 0;
+}
+
+int main()
+{
+  return foo(1, [[NSObject alloc] init]);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-copied-var.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-copied-var.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5988451 - nested blocks */
+/* This test is to make sure that the inner block uses the value of the
+   copied-in variable at its point of declaration and not when block is envoked.
+*/
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+extern "C" void abort(void);
+
+void * _NSConcreteStackBlock;
+
+
+void callVoidVoid(void (^closure)(void)) {
+    closure();
+}
+
+int main(int argc, char *argv[]) {
+    int local_i_var = 1;
+
+    void (^vv)(void) = ^{
+        if (local_i_var != 1)
+	  abort();
+        if (argc > 0) {
+            callVoidVoid(^{ if (local_i_var != 1) abort();  });
+        }
+    };
+
+    local_i_var = 2;
+    vv();
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global-copied-var-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-global-copied-var-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global-copied-var-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global-copied-var-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,35 @@
+/* APPLE LOCAL file radar global blocks */
+/* More testing of copied in variables in nested blocks. */
+/* { dg-options "-fblocks -mmacosx-version-min=10.6 -ObjC++ -framework Foundation" { target *-*-darwin* } } */
+/* { dg-do run } */
+
+#import <Foundation/Foundation.h>
+void *_NSConcreteGlobalBlock;
+
+id Global = nil;
+
+void callVoidVoid(void (^closure)(void)) {
+    closure();
+}
+
+int argc = 1;
+
+id x;
+
+void (^vv)(void) = ^{
+        if (argc > 0) {
+            callVoidVoid(^{ Global = x; });
+        }
+};
+
+int main() {
+    x = [[NSObject alloc] init];
+    id initial_x = x;
+
+    vv();
+
+    if (Global != initial_x) {
+        exit(1);
+    }
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested-global.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested-global.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,58 @@
+/* APPLE LOCAL file radar 5822844 - global blocks */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+#ifdef __cplusplus
+extern "C" void exit(int);
+#else
+extern void exit(int);
+#endif
+
+void * _NSConcreteGlobalBlock;
+
+enum numbers {
+  zero, one, two, three, four
+};
+
+typedef enum numbers (^myblock)(enum numbers);
+
+
+double test(myblock I) {
+  return I(three);
+}
+
+enum numbers x = one;
+enum numbers y = two;
+
+static myblock CL = ^(enum numbers z)
+		{ enum numbers savex = x;
+		  { __block enum numbers x = savex;
+		  y = z;
+		  if (y != three)
+		    exit (6);
+		  test (
+			^ (enum numbers z) {
+			    if (y != three) {
+			      exit(1);
+			    }
+			    if (x != one)
+			      exit(2);
+			    x = z;
+			    if (x != three)
+			      exit(3);
+			    if (y != three)
+			      exit(4);
+			    return (enum numbers) four;
+			});}
+		  return x;
+		  };
+
+int main() {
+  enum numbers res = (enum numbers)test(CL);
+
+  if (res != one)
+    exit (5);
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nested.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nested.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,56 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+#ifdef __cplusplus
+extern "C" void exit(int);
+#else
+extern void exit(int);
+#endif
+
+enum numbers {
+  zero, one, two, three, four
+};
+
+typedef enum numbers (^myblock)(enum numbers);
+
+
+double test(myblock I) {
+  return I(three);
+}
+
+int main() {
+  __byref enum numbers x = one;
+  __byref enum numbers y = two;
+
+  myblock CL = ^(enum numbers z)
+		{ enum numbers savex = x;
+		  { __byref enum numbers x = savex;
+		  y = z;
+		  if (y != three)
+		    exit (6);
+		  test (
+			^ (enum numbers z) {
+			    if (y != three) {
+			      exit(1);
+			    }
+			    if (x != one)
+			      exit(2);
+			    x = z;
+			    if (x != three)
+			      exit(3);
+			    if (y != three)
+			      exit(4);
+			    return (enum numbers) four;
+			});}
+		  return x;
+		  };
+
+  enum numbers res = (enum numbers)test(CL);
+
+  if (res != one)
+    exit (5);
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-noescape-helper-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,36 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* Test for generation of escape _Block_byref_release call when a local
+   __byref variable is copied in. */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+
+void *_NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+void junk(void (^block)(void)) {
+  block();
+}
+
+int test() {
+  {
+    int __byref i = 10;
+    void (^dummy)(void) = ^{ printf("i = %d\n", i); };
+    junk(dummy);
+  }
+  return count;
+}
+
+int main() {
+  if ( test() != 1)
+    abort();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-noescape-helper-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,37 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* Test for generation of escape _Block_byref_release call when a local
+   __byref variable is copied in and block has a return statement. */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+
+void *_NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+void junk(int (^block)(void)) {
+  block();
+}
+
+int test() {
+  {
+    int __byref i = 10;
+    int (^dummy)(void) = ^{ printf("i = %d\n", i); return i; };
+    junk(dummy);
+  }
+  return count;
+}
+
+int main() {
+  if ( test() != 1)
+    abort();
+  return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-3.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-noescape-helper-3.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-3.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper-3.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,35 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* Test for generation of escape _Block_byref_release call when a __byref
+   variable inside a block is declared and used. */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+
+void *_NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+void junk(void (^block)(void)) {
+  block();
+}
+
+int test() {
+  {
+    void (^dummy)(void) = ^{ int __byref i = 10; printf("i = %d\n", i); };
+    junk(dummy);
+  }
+  return count;
+}
+
+int main() {
+  if (test() != 1)
+    abort();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-noescape-helper.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-noescape-helper.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,34 @@
+/* APPLE LOCAL file radar 6083129 byref escapes */
+/* { dg-options "-fblocks" } */
+/* { dg-do run } */
+
+#include <stdio.h>
+
+void *_NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+
+extern "C" void abort(void);
+
+static int count;
+static void _Block_byref_release(void * arg) {
+  ++count;
+}
+
+void junk(void (^block)(void)) {
+  block();
+}
+
+int test() {
+  {
+    __byref int i = 10;
+    void (^dummy)(void) = ^{ ++i; };
+    junk(dummy);
+  }
+  return count;
+}
+
+int main() {
+  if (test() != 1)
+    abort();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nonnull-test.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nonnull-test.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nonnull-test.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nonnull-test.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5925781 */
+/* Test for the "nonnull" function attribute.  */
+/* { dg-do compile } */
+/* { dg-options "-Wnonnull" } */
+
+#include <stddef.h>
+
+extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
+
+extern void func3 (void (^block1)(), int, void (^block2)(), int)
+  __attribute__((nonnull(1,3)));
+
+extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
+  __attribute__((nonnull(2)));
+
+void
+foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
+{
+  func1(cp1, cp2, i1);
+
+  func1(NULL, cp2, i1); /* { dg-warning "null" "null with argless nonnull 1" } */
+  func1(cp1, NULL, i1); /* { dg-warning "null" "null with argless nonnull 2" } */
+  func1(cp1, cp2, 0);
+
+
+  func3(NULL, i2, cp3, i3); /* { dg-warning "null" "null with explicit nonnull 1" } */
+  func3(cp3, i2, NULL, i3); /* { dg-warning "null" "null with explicit nonnull 3" } */
+
+  func4(NULL, cp1); /* { dg-warning "null" "null with multiple attributes 1" } */
+  func4(cp1, NULL); /* { dg-warning "null" "null with multiple attributes 2" } */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-assignment.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-pointer-assignment.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-assignment.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-assignment.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file radar 5878380 */
+/* Issue diagnostics, instead of ICE, on invalid block pointer assignment. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++" { target *-*-darwin* } } */
+
+static int sNSImageSnapshotInWindowsComputedValue = -2;
+
+static void _NSImageSnapshotInWindows(void)
+{
+  static int nInvalid = ^{ return 1; };	/* { dg-error "cannot convert" } */
+  sNSImageSnapshotInWindowsComputedValue = ^{ return 1; }; /* { dg-error "cannot convert" } */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type-match.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-pointer-type-match.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type-match.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type-match.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,18 @@
+/* APPLE LOCAL file 5795493 - blocks */
+/* Check that function decl and definition which have blocks (blocks) as their
+   type do the type-matching correctly and do not issue bogus warning. */
+/* { dg-do compile } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fblocks" { target *-*-darwin* } } */
+
+void useBlock (void (^arg)(void));
+
+void useBlock (void (^arg)(void)) {}
+
+ at interface Fred
+- (void) useBlock:(void (^)(void)) aBlock;
+ at end
+
+ at implementation Fred
+- (void) useBlock:(void (^)(void)) aBlock { }
+ at end
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-pointer-type.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer-type.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,113 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* Test that mixup of a pointer type and a block pointer type does not cause program to crash. */
+/* { dg-do run } */
+/* { dg-options "-fblocks" } */
+
+void * _NSConcreteStackBlock;
+#ifndef _BLOCK_PRIVATE_H_
+#define _BLOCK_PRIVATE_H_
+
+enum {
+    BLOCK_NEEDS_FREE =        (1 << 24),
+    BLOCK_HAS_COPY_DISPOSE =  (1 << 25),
+    BLOCK_NO_COPY =           (1 << 26), // interim byref: no copies allowed
+    BLOCK_IS_GC =             (1 << 27),
+};
+
+struct Block_basic {
+    long reserved;
+    //char flags; char size; short refcount;
+    int Block_flags;  // int32_t
+    int Block_size; // XXX should be packed into Block_flags
+    void (*Block_invoke)(void *);
+    void (*Block_copy)(void *dst, void *src);
+    void (*Block_dispose)(void *);
+};
+
+struct Block_byref {
+    long reserved;
+    struct Block_byref *forwarding;
+    int refcount;
+    int size;
+    void (*byref_keep)(struct Block_byref *dst, struct Block_byref *src);
+    void (*byref_destroy)(struct Block_byref *);
+};
+
+/* runtime entry for destroying shared data blocks */
+void Block_destroy_byref(struct Block_byref *shared_struct);
+/* runtime entry for sharing shared data blocks */
+struct Block_byref *Block_share_byref(struct Block_byref *shared_struct);
+
+/* runtime entry to get total size of a block */
+int Block_size(struct Block_basic *aBlock);
+
+// set the allocator/deallocator pair (used by ObjC to establish GC)
+void _Block_set_allocator_pair(void *(*alloc)(const unsigned long), void (*dealloc)(const void *));
+
+#endif
+
+int GlobalInt;
+void setGlobalInt(int value) { GlobalInt = value; }
+int getGlobalInt() { int tmp = GlobalInt; GlobalInt = 0; return tmp; }
+
+
+//
+// Example block code generated for specific Blocks
+//
+
+//
+// Partially bound block referencing const and byref args
+//
+
+/* Inclusion of this block block causes program to crash, even though it does not envoke it */
+#if __BLOCKS__
+int parameters_example_real(int verbose) {
+    int desiredValue = 100;
+    void (^myBlock)(int);
+    myBlock = ^ (int param) {
+        setGlobalInt(param);
+    };
+    myBlock(desiredValue);
+    int globalValue = getGlobalInt();
+   // if (error_found("parameters_real", globalValue, desiredValue, verbose)) return 1;
+    return 0;
+}
+
+#endif __BLOCKS__
+
+struct parameters_example_struct {
+    struct Block_basic base;
+};
+
+// the "thunks" compiled for the invoke entry point of the parameters_example
+
+void invoke_parameters_example(struct parameters_example_struct *aBlock, int param) {
+  {
+    setGlobalInt(param);
+  }
+}
+
+
+// The rewritten version of the code above
+
+int parameters_example(int verbose) {
+    int desiredValue = 100;
+    struct parameters_example_struct literal = {
+        { 0, 0, sizeof(struct parameters_example_struct),
+            (void (*)(void *))invoke_parameters_example,
+        },
+    };
+    struct parameters_example_struct *myBlock = &literal;
+
+    // get a type correct function pointer for the invocation function
+    void (*correct)(struct parameters_example_struct *, int);
+    correct = (void (*)(struct parameters_example_struct *, int))myBlock->base.Block_invoke;
+    // call the block with itself as first arg and the parameter 100
+    correct(myBlock, desiredValue);
+
+    return 0;
+
+}
+
+int main(int argc, char *argv[]) { parameters_example(1); return 0; }
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-pointer.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-pointer.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,27 @@
+/* APPLE LOCAL file - testcase for Radar 5811943  */
+/* { dg-do compile } */
+/* { dg-options "-g -O0 -fblocks -dA" } */
+/* { dg-final { scan-assembler "DW_AT_APPLE_block" } } */
+
+#include <stdio.h>
+void * _NSConcreteStackBlock;
+
+int
+blockTaker (int (^myBlock)(int), int other_input)
+{
+  return 5 * myBlock (other_input);
+}
+
+int main (int argc, char **argv)
+{
+  int (^blockptr) (int) = ^(int inval) {
+    printf ("Inputs: %d, %d.\n", argc, inval);
+    return argc * inval;
+  };
+
+
+  argc = 10;
+  printf ("I got: %d.\n",
+	  blockTaker (blockptr, 6));
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-predef.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-predef.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-predef.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-predef.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,9 @@
+/* APPLE LOCAL file radar 5868913 */
+/* Test that __BLOCKS__ is undefined in g++ */
+/* { dg-do compile } */
+
+#ifndef __OBJC__
+#if __BLOCKS__
+#error TEST FAILS
+#endif
+#endif

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-question-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,26 @@
+/* APPLE LOCAL file blocks 6065211 */
+/* { dg-options "-fblocks" } */
+
+template <class T>
+void f(T a) { }
+
+enum e { no, yes };
+
+void foo() {
+  void (^bp)(int);
+  void (*rp)(int);
+  void (^bp1)();
+  double *dp;
+  void *vp = bp;
+
+  vp = bp;
+  f(1 ? dp : vp);
+  f(1 ? bp : vp);
+  bp != vp;
+  f(1 ? bp : bp1);		/* { dg-error "distinct pointer types" } */
+  bp > rp;			/* { dg-error "invalid operands" } */
+  bp > 0;			/* { dg-error "invalid operands" } */
+  bp > bp;			/* { dg-error "invalid operands" } */
+  bp > vp;			/* { dg-error "invalid operands" } */
+  f(1 ? bp : rp);		/* { dg-error "distinct pointer types" } */
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-exp.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-question-exp.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-exp.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-question-exp.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,19 @@
+/* APPLE LOCAL file radar 5957801 */
+/* Cannot convert void * to block pointer in c++ mode */
+/* { dg-options "-fblocks" } */
+/* { dg-do compile } */
+
+typedef int (^myblock)(void);
+void *_NSConcreteStackBlock;
+
+myblock foo(int i, myblock b) {
+  if (!i ? (void *)0 : b)
+    return (myblock)(i ? b : (void *)0);
+}
+
+int main () {
+  myblock b = ^{ return 1; };
+  if (foo (1, b))
+    return 0;
+  return 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readonly-diag.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-readonly-diag.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readonly-diag.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readonly-diag.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,13 @@
+/* APPLE LOCAL file radar 5805175 - blocks */
+/* Test that pre/post incr/decr of copied-in variable cuases proper diagnostic. */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+void foo() {
+    static int s_i = 10;
+    int local;
+    ^ { ++s_i; }; 
+    ^ { local--; }; /* { dg-error "decrement of read-only variable" } */
+    ++s_i;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgc.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-readweakgc.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgc.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgc.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,41 @@
+/* APPLE LOCAL file radar 5882266 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+int GlobalInt2 = 0;
+
+id objc_assign_weak(id value, id *location) {
+    GlobalInt = 1;
+    *location = value;
+    return value;
+}
+
+id objc_read_weak(id *location) {
+    GlobalInt2 = 1;
+    return *location;
+}
+
+
+void (^__weak Henry)(void);
+
+int main(char *argc, char *argv[]) {
+  // an object should not be retained within a stack Block
+  void (^local)(void);
+  __byref int i = 10;
+  Henry = ^ { ++i; };
+  local = Henry;
+  if (GlobalInt2 == 1) {
+    printf("%s: success\n", argv[0]);
+    exit(0);
+  } else {
+    printf("%s: problem with weak write-barrier assignment of stack block\n", argv[0]);
+  }
+  exit(1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgcivar.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-readweakgcivar.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgcivar.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-readweakgcivar.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,48 @@
+/* APPLE LOCAL file radar 5882266 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.5 -ObjC++ -fobjc-gc -framework Foundation" { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+void * _NSConcreteStackBlock;
+void _Block_byref_assign_copy(void * dst, void *src){}
+void _Block_byref_release(void*src){}
+
+
+int GlobalInt = 0;
+int GlobalInt2 = 0;
+
+id objc_assign_weak(id value, id *location) {
+    GlobalInt = 1;
+    *location = value;
+    return value;
+}
+
+id objc_read_weak(id *location) {
+    GlobalInt2 = 1;
+    return *location;
+}
+
+ at interface Foo : NSObject {
+ at public
+    void (^__weak ivar)(void);
+}
+ at end
+ at implementation Foo
+ at end
+
+
+int main(char *argc, char *argv[]) {
+  // an object should not be retained within a stack Block
+  __byref int i = 0;
+  void (^local)(void);
+  Foo *foo = [[Foo alloc] init];
+  foo->ivar = ^ { ++i; };
+  local = foo->ivar;
+  if (GlobalInt2 == 1) {
+    printf("%s: success\n", argv[0]);
+    exit(0);
+  } else {
+    printf("%s: problem with weak read of ivar\n", argv[0]);
+  }
+  exit(1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-return.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-return.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-return.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-return.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,47 @@
+/* APPLE LOCAL file radar 5732232 - blocks */
+/* { dg-do compile } */
+/* { dg-options "-fblocks" } */
+
+typedef void (^CL)(void);
+
+CL foo() {
+
+	short y;
+        short (^add1)(void) = ^{ return y+1; };  /* { dg-error "cannot convert" } */
+
+	CL X = ^{if (2)
+                   return;
+           	 return 1;   /* { dg-error "void block should not return a value" } */
+			     /* { dg-error "return-statement with a value" "" { target *-*-* } 14 } */
+	 	};
+
+	int (^Y) (void)  = ^{ if (3)
+	     	        return 1;
+	   	       else
+	     	        return;  /* { dg-error "non-void block should return a value" } */
+	             };
+
+	char *(^Z)(void) = ^{ if (3)
+             			return "";  /* { dg-error "cannot convert" } */
+           		      else
+             		       return (char*)0; /* { dg-error "incompatible type returning" } */ 
+         		    };	/* { dg-error "cannot convert" } */
+
+        double (^A)(void) = ^ { if (1)
+				 return (float)1.0;
+				else
+				  if (2)
+				    return (double)2.0;  /* { dg-error "incompatible type returning" } */
+				return 1;  /* { dg-error "incompatible type returning" } */
+			      }; /* { dg-error "cannot convert" } */
+        char *(^B)(void) =
+		^{ if (3)
+             	     return ""; /* { dg-error "cannot convert" } */
+           	   else
+             	    return 2; /* { dg-error "incompatible type returning" } */
+         	};	     /* { dg-error "cannot convert" } */
+
+        return ^{ return 1; };  /* { dg-error "cannot convert" } */
+
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-sync-compare-and-swap.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-sync-compare-and-swap.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-sync-compare-and-swap.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-sync-compare-and-swap.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file radar 6035389 */
+/* { dg-options "-Werror -fblocks" } */
+
+int print(const char *);
+
+int main()
+{
+  void (^b)(void);
+
+  __sync_bool_compare_and_swap(&b, (void*)0, ^{ print("hello\n"); });
+  return 0;
+};

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-parameter.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-unused-parameter.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-parameter.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-parameter.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file radar 5925784 */
+/* Don't issue warning with -Wunused-parameter on '_self' parameter. */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-parameter" } */
+
+int main()
+{
+	__byref int i = 1;
+	^ { i = 1; return i; }; 
+	return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-warn.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-unused-warn.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-warn.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-unused-warn.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,15 @@
+/* APPLE LOCAL file radar 5834569 */
+/* Do not issue unused variable warning on blocks. */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+int main() {
+  __byref int x = 10;
+  int y = 1;
+
+  int (^myBlock)(void) = ^{ return x+y; };
+
+  myBlock();
+
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/fold-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/fold-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/fold-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/fold-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,16 @@
+/* APPLE LOCAL folding of anon union 6120295 */
+/* { dg-do run } */
+
+struct foo { int a; };
+struct bar { int b; };
+
+int main(int argc, char* argv[]) {
+  union {
+    const foo *pfoo;
+    const bar *pbar;
+  };
+
+  // test that the two pointers occupy the same space on the stack
+  if ((void *)&pfoo != (void *)&pbar)
+    return 1;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/init-3.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/init-3.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/init-3.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/init-3.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,15 @@
+/* APPLE LOCAL file 6052773 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+struct pthread_once_t { };
+struct test {
+  pthread_once_t once;
+};
+
+int main(void) {
+  struct test foo = { 
+    once: PTHREAD_ONCE_INITIALIZER /* { dg-error "not declared in this scope" } */
+  };
+
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-1.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/shorten-1.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-1.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-1.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,11 @@
+/* APPLE LOCAL file 64bit shorten warning 6183168 */
+/* { dg-do compile } */
+/* { dg-options "-Wshorten-64-to-32" } */
+/* Radar 6183168 */
+
+int ioctl(unsigned long);
+
+void
+socket_nonblock() {
+  ioctl(8UL & 1);
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/shorten-2.C?rev=55723&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/shorten-2.C Wed Sep  3 15:44:59 2008
@@ -0,0 +1,9 @@
+/* APPLE LOCAL file 64bit shorten warning 5429810 */
+/* { dg-do compile } */
+/* { dg-options "-Wshorten-64-to-32" } */
+/* Radar 5429810 */
+
+typedef enum {
+  kConst1 = 1ull,
+  kConst2 = 2
+} MyEnum;





More information about the llvm-commits mailing list