[cfe-commits] r82094 - /cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m

Fariborz Jahanian fjahanian at apple.com
Wed Sep 16 16:49:05 PDT 2009


Author: fjahanian
Date: Wed Sep 16 18:49:04 2009
New Revision: 82094

URL: http://llvm.org/viewvc/llvm-project?rev=82094&view=rev
Log:
More test for objc gc's mixed write-barriers.


Added:
    cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m

Added: cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m?rev=82094&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc2-write-barrier-2.m Wed Sep 16 18:49:04 2009
@@ -0,0 +1,52 @@
+// RUN: clang-cc -fnext-runtime -fobjc-gc -fobjc-newgc-api -emit-llvm -o %t %s &&
+// RUN: grep -F '@objc_assign_global' %t  | count 7 &&
+// RUN: grep -F '@objc_assign_ivar' %t  | count 4 &&
+// RUN: grep -F '@objc_assign_strongCast' %t  | count 4 &&
+// RUN: true
+
+extern id **somefunc(void);
+extern id *somefunc2(void);
+
+
+// Globals
+
+id W, *X, **Y;
+
+void func(id a, id *b, id **c) {
+   static id w, *x, **y;
+   W = a;  /* { dg-warning "global\\/static variable assignment" } */
+   w = a;  /* { dg-warning "global\\/static variable assignment" } */
+   X = b;  /* { dg-warning "global\\/static variable assignment" } */
+   x = b;  /* { dg-warning "global\\/static variable assignment" } */
+   Y = c;  /* { dg-warning "global\\/static variable assignment" } */
+   y = c;  /* { dg-warning "global\\/static variable assignment" } */
+}
+
+// Instances
+
+ at interface something {
+    id w, *x, **y;
+}
+ at end
+
+ at implementation something
+- (void)amethod {
+    id badIdea = *somefunc2();
+    w = badIdea;   /* { dg-warning "instance variable assignment" } */
+    x = &badIdea;  /* { dg-warning "instance variable assignment" } */
+    y = &x;        /* { dg-warning "instance variable assignment" } */
+}
+ at end
+
+typedef struct {
+    int junk;
+    id  alfred;
+} AStruct;
+
+void funct2(AStruct *aptr) {
+    id **ppptr = somefunc();
+    aptr->alfred = 0;  /* { dg-warning "strong\\-cast assignment" } */
+    **ppptr = aptr->alfred;       /* { dg-warning "strong\\-cast assignment" } */
+    *ppptr = somefunc2();         /* { dg-warning "strong\\-cast assignment" } */
+}
+





More information about the cfe-commits mailing list