[llvm-commits] [llvm-gcc-4.2] r54497 - in /llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg: cfstring-nsstring-type.mm inline-func-access-category.mm objc-gc-static-init.mm property-getter-codegen.mm property-id-proto-getter.mm property-reference-1.mm property-reference-2.mm property-reference-3.mm sync-objc-exception.mm template-in-impl.mm utf16string-in-functemplate.mm

Bill Wendling isanbard at gmail.com
Thu Aug 7 17:51:11 PDT 2008


Author: void
Date: Thu Aug  7 19:51:11 2008
New Revision: 54497

URL: http://llvm.org/viewvc/llvm-project?rev=54497&view=rev
Log:
Sync up obj-c++.dg testsuites with Apple's GCC obj-c++.dg.

Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/cfstring-nsstring-type.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/inline-func-access-category.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-static-init.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-getter-codegen.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-id-proto-getter.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-1.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-2.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-3.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/sync-objc-exception.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/template-in-impl.mm
    llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/utf16string-in-functemplate.mm

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/cfstring-nsstring-type.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/cfstring-nsstring-type.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/cfstring-nsstring-type.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/cfstring-nsstring-type.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5982789 */
+/* Type of a CFString literal is NSString. This test case
+   should not issue any warning as "length" is a method 
+   in NSString class.
+*/
+/* { dg-options "-Wall -Werror" } */
+/* { dg-do compile } */
+
+#include <Foundation/Foundation.h>
+
+ at interface MyTestClassA : NSObject
+{
+}
+- (short) length;
+ at end
+
+ at implementation MyTestClassA
+- (short) length;
+{
+    return 1;
+}
+ at end
+
+
+int main (int argc, const char * argv[])
+{    
+    NSUInteger testLen = [@"teststring" length];
+    NSLog(@"teststring: %ld", (long)testLen);
+        
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/inline-func-access-category.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/inline-func-access-category.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/inline-func-access-category.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/inline-func-access-category.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,22 @@
+/* APPLE LOCAL file radar 5471096 */
+/* Test that an inlinable function in cateogry block has access to
+   protected/private member of its class though pointer to the class. */
+/* { dg-do compile } */
+
+ at interface B 
+  {
+    int intValue;
+  }
+ at end
+
+
+ at interface B()
+
+inline static int B_intValue(B *self)
+  { return self->intValue; }
+
+ at end
+
+ at implementation B
+
+ at end

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-static-init.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc-gc-static-init.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-static-init.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-static-init.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,47 @@
+/* APPLE LOCAL file radar 5733674 */
+/* Test that static GC'able objects are garbage collected by generating write barrier. 
+   Test should build and run. */
+/* { dg-options "-fobjc-gc -mmacosx-version-min=10.5 -framework Foundation" } */
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-require-effective-target objc_gc } */
+
+#import <Foundation/Foundation.h>
+
+ at interface Test : NSObject
+{
+}
+ at end
+ at implementation Test
+
+static NSString *createMacOSXVersionString()
+{
+    return [[NSString alloc] initWithString:[[NSDate date] description]];
+}
+
+- (void)getString
+{
+    static NSString *string = createMacOSXVersionString();
+    NSLog(@"string: %@", string);
+    NSLog(@"string: %p", string);
+}
+
+ at end
+
+
+
+int main (int argc, const char * argv[]) {
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+    
+    Test *testClass = [[Test alloc] init];
+    unsigned counter, max = 4;
+    for (counter = 0; counter < max; counter++) {
+        [testClass getString];
+        [[NSGarbageCollector defaultCollector] collectExhaustively];
+    }
+    [testClass release];
+    
+    // insert code here...
+    NSLog(@"Hello, World!");
+    [pool drain];
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-getter-codegen.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-getter-codegen.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-getter-codegen.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-getter-codegen.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,115 @@
+/* APPLE LOCAL file radar 5802025 */
+/* This test case used to ICE because we did not generate a getter call from
+   OBJC_PROPERTY_REFERENCE_EXPR in time to access the property getter value when
+   getter is retuning a class.
+*/
+/* { dg-options "-mmacosx-version-min=10.5 -framework Foundation" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-framework Foundation" { target arm*-*-darwin* } } */
+/* { dg-do run { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+#import <objc/objc-runtime.h>
+
+class Vector3D
+{
+	public:
+		float x, y, z;
+	
+	public:
+		Vector3D();
+		Vector3D(const Vector3D &inVector);
+		Vector3D(float initX, float initY, float initZ);
+		Vector3D &operator=(const Vector3D & rhs);
+		
+		NSString *description();
+};
+
+Vector3D::Vector3D()
+{
+	x = y = z = 0;
+}
+
+Vector3D::Vector3D(const Vector3D &inVector)
+{
+	x = inVector.x;
+	y = inVector.y;
+	z = inVector.z;
+}
+
+Vector3D::Vector3D(float initX, float initY, float initZ)
+{
+	x = initX;
+	y = initY;
+	z = initZ;
+}
+
+Vector3D &Vector3D::operator=(const Vector3D & rhs)
+{
+	x = rhs.x;
+	y = rhs.y;
+	z = rhs.z;
+	
+	return *this;
+}
+
+NSString *Vector3D::description()
+{
+	return [NSString stringWithFormat: @"(%f, %f, %f)", x, y, z];
+}
+
+ at interface Object3D : NSObject
+{
+	Vector3D position;
+}
+
+ at property (assign) Vector3D position;
+ at end
+
+static int count;
+
+ at implementation Object3D
+
+ at synthesize position;
+
+- (id) init
+{
+	self = [super init];
+	if(self)
+	{
+		position = Vector3D(0, 0, 0);
+	}
+	
+	return self;
+}
+
+- (void) setPosition: (Vector3D) inPosition
+{
+	position = inPosition;
+	NSLog(@"setPosition was called with the vector %@", inPosition.description());
+	++count;
+}
+ at end
+
+int main (int argc, const char * argv[]) 
+{
+	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+	Object3D *myObject = [[Object3D alloc] init];
+	
+	// Each of these looks like it should call the setPosition method.  However,
+	// if the Vector3D copy constructor is defined, this one won't.
+	myObject.position = Vector3D(1.0f, 1.0f, 1.0f);
+	NSLog(@"After assignment the position is: %@", myObject.position.description());
+
+	[myObject setPosition: Vector3D(2.0f, 2.0f, 2.0f)];
+	NSLog(@"After setPosition: the position is: %@", myObject.position.description());
+
+	typedef void (*SetPositionIMP)(id self, SEL _cmd, Vector3D position);
+	((SetPositionIMP)objc_msgSend)(myObject, @selector(setPosition:), Vector3D(3.0f, 3.0f, 3.0f));
+	NSLog(@"After objc_msgSend the position is: %@", myObject.position.description());
+
+	[pool release];
+        if (count != 3)
+	 abort();
+        return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-id-proto-getter.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-id-proto-getter.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-id-proto-getter.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-id-proto-getter.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,20 @@
+/* APPLE LOCAL file radar 5893391 */
+/* Test that property-style getter call syntax can be used on objects
+   of 'id' type qualified by protocols which implement the getter
+   method declared in that protocol. */
+/* { dg-options "-mmacosx-version-min=10.5 -framework Foundation -fobjc-gc" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-do run { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+
+#include <Foundation/Foundation.h>
+
+int main()
+{
+        id spam = [NSArray arrayWithObjects:@"Spam", @"spam", nil];
+        NSString *spamText= [ spam description ];
+        id<NSObject> eggs = [NSArray arrayWithObjects:@"Spam", @"spam", nil];
+        NSString *eggsText= eggs.description;
+        NSObject *bacon = [NSArray arrayWithObjects:@"Spam", @"spam", nil];
+        NSString *baconText= bacon.description;
+        NSLog(@"spam=%@, eggs=%@, bacon=%@", spamText, eggsText, baconText);
+	return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-1.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-reference-1.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-1.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-1.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,28 @@
+/* APPLE LOCAL file radar 6029624 */
+/* Test for const refrence property types. */
+/* { dg-options "-mmacosx-version-min=10.5" } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+struct MyStruct
+{
+        float x;
+        float y;
+        float z;
+};
+
+ at interface MyClass
+{
+        MyStruct foo;
+}
+
+ at property (assign, readwrite) const MyStruct& foo;
+ at property (assign, readwrite) const MyStruct& Myfoo;
+
+ at end
+
+ at implementation MyClass
+
+ at synthesize Myfoo = foo;
+ at synthesize foo;
+
+ at end

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-2.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-reference-2.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-2.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-2.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,25 @@
+/* APPLE LOCAL file radar 6029624 */
+/* Test for const refrence property types. */
+/* { dg-options "-m64 -mmacosx-version-min=10.5" } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+struct MyStruct
+{
+        float x;
+        float y;
+        float z;
+};
+
+ at interface MyClass
+
+ at property (assign, readwrite) const MyStruct& foo;
+ at property (assign, readwrite) const MyStruct& Myfoo;
+
+ at end
+
+ at implementation MyClass
+
+ at synthesize Myfoo;
+ at synthesize foo;
+
+ at end

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-3.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-reference-3.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-3.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-reference-3.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,51 @@
+/* APPLE LOCAL file radar 6029577 */
+/* Test for correct generation of getters which return reference typed ivars. */
+/* { dg-options "-framework Foundation -mmacosx-version-min=10.5" } */
+/* { dg-do run { target *-*-darwin* } } */
+
+#include <Foundation/Foundation.h>
+
+struct MyStruct
+{
+	int x;
+	int y;
+	int z;
+};
+
+ at interface MyClass : NSObject
+{
+	MyStruct _foo;
+}
+
+ at property (assign, readwrite) const MyStruct& foo;
+
+- (const MyStruct&) foo;
+- (void) setFoo:(const MyStruct&)inFoo;
+ at end
+
+ at implementation MyClass
+
+- (const MyStruct&) foo
+{
+	return _foo;
+}
+
+- (void) setFoo:(const MyStruct&)inFoo
+{
+	_foo = inFoo;
+}
+ at end
+
+int main()
+{
+	MyClass* myClass = [[MyClass alloc] init];
+		
+	MyStruct myStruct = (MyStruct){1, 2, 3};
+	myClass.foo = myStruct;
+
+	const MyStruct& currentMyStruct = myClass.foo;   
+        if (currentMyStruct.x != 1 || currentMyStruct.y != 2 || currentMyStruct.z != 3)
+	  abort();
+	return 0;
+}
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/sync-objc-exception.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/sync-objc-exception.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/sync-objc-exception.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/sync-objc-exception.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,27 @@
+/* APPLE LOCAL file radar 5982990 */
+/* This tests that local variables declared in @synchronized block
+   have are make volatile. Test should compile with no warning or
+   error.
+*/
+/* { dg-do compile { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fobjc-exceptions -Os -Wextra -Werror" } */
+/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */
+ 
+struct MyPoint { int x; };
+
+ at interface MyObject {}
++(void) doNothingWithPoint:(struct MyPoint)aPoint;
+ at end
+
+int main()
+{
+    id  pool = 0;
+	
+    @synchronized(pool)
+	{
+		struct MyPoint thePoint;
+		[MyObject doNothingWithPoint:thePoint];
+	}
+	
+    return 0;
+}

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/template-in-impl.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/template-in-impl.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/template-in-impl.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/template-in-impl.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,25 @@
+/* APPLE LOCAL file radar 5976344 */
+/* Test that class template can be properly parsed and handled inside
+   an @implementation. */
+
+/* { dg-do compile } */
+
+template <class T> struct TemplateDeclarationIsFineHere {};
+
+template <class T> struct Template2 {};
+
+ at interface Test @end
+
+ at implementation Test
+
+- (void) test {
+        Template2<int> youCanInstantiateTemplatesNoProblem();
+}
+
+template <class T> struct TemplateDeclarationIsNoGoodHere {};
+
+- (TemplateDeclarationIsNoGoodHere<int>*) Meth { return 0; }
+
+
+ at end
+

Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/utf16string-in-functemplate.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/utf16string-in-functemplate.mm?rev=54497&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/utf16string-in-functemplate.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/utf16string-in-functemplate.mm Thu Aug  7 19:51:11 2008
@@ -0,0 +1,13 @@
+/* APPLE LOCAL file radar 5887355 */
+/* Test correct generation of utf16-string in a function template. */
+/* { dg-options "-framework Cocoa" } */
+/* { dg-do run { target *-*-darwin* } } */
+
+#import <Cocoa/Cocoa.h>
+
+template <typename T> NSString* test (T i) { return @"æble"; }
+
+main () { 
+   NSLog (@"string: %@", test(42)); 
+   return 0;
+}





More information about the llvm-commits mailing list