* More dot-syntax and @synthesize testcases
@ 2010-11-08 0:14 Nicola Pero
2010-11-08 21:14 ` Mike Stump
0 siblings, 1 reply; 2+ messages in thread
From: Nicola Pero @ 2010-11-08 0:14 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 851 bytes --]
This patch adds a few more testcases for Objective-C 2.0 dot-syntax and @synthesize.
They all pass with my latest patches applied; but they cover some cases that I'd like
to be covered.
Ok to commit ?
Thanks
PS: The attached testcases.txt is not a diff; it rather includes all the testcases in the file.
Each of them starts at the '/* Contributed by ... */' line.
2010-11-07 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/property/dotsyntax-13.m: New.
* objc.dg/property/dotsyntax-14.m: New.
* objc.dg/property/dotsyntax-15.m: New.
* objc.dg/property/synthesize-7.m: New.
* obj-c++.dg/property/dotsyntax-13.mm: New.
* obj-c++.dg/property/dotsyntax-14.mm: New.
* obj-c++.dg/property/dotsyntax-15.mm: New.
* obj-c++.dg/property/synthesize-7.mm: New.
[-- Attachment #2: testcases.txt --]
[-- Type: text/plain, Size: 11656 bytes --]
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
/* Test dot-syntax with a local variable. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int a;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
- (int) count;
- (void) setCount: (int)count;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
- (int) count
{
return a;
}
- (void) setCount: (int)count
{
a = count;
}
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
int i;
for (i = 0; i < 10; i++)
{
object.count = i;
if (object.count != i)
abort ();
}
return 0;
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
/* Test dot-syntax with accessors to be looked up in protocol @properties. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
@property int countA;
@end
@protocol ProtocolB
@property int countB;
@end
@protocol ProtocolC
@property int countC;
@end
@interface MyRootClass
{
Class isa;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
@end
int function (MySubClass *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
}
int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function5 (id <ProtocolA, ProtocolB> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
/* Test dot-syntax with accessors to be looked up in protocols. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
- (int) countA;
- (void) setCountA: (int)aNumber;
@end
@protocol ProtocolB
- (int) countB;
- (void) setCountB: (int)aNumber;
@end
@protocol ProtocolC
- (int) countC;
- (void) setCountC: (int)aNumber;
@end
@interface MyRootClass
{
Class isa;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
@end
int function (MySubClass *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
}
int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function5 (id <ProtocolA, ProtocolB> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
/* Test @synthesize with protocols of protocols. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
@property int countA;
@end
@protocol ProtocolB <ProtocolA>
@property int countB;
@end
@protocol ProtocolC <ProtocolB>
@property int countC;
@end
@protocol ProtocolD
@property int countD;
@end
@interface MyRootClass <ProtocolC>
{
Class isa;
int countA;
int countB;
int countC;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
@synthesize countA;
@synthesize countB;
@synthesize countC;
@end
@interface MySubClass : MyRootClass <ProtocolD>
{
int countD;
}
@end
@implementation MySubClass
@synthesize countD;
@end
int main (void)
{
MySubClass *object = [[MySubClass alloc] init];
int i;
for (i = 0; i < 10; i++)
{
object.countA += i;
object.countB += i + 1;
object.countC += i + 2;
object.countD += i + 3;
}
if (object.countA != 45)
abort ();
if (object.countB != 55)
abort ();
if (object.countC != 65)
abort ();
if (object.countD != 75)
abort ();
return 0;
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
/* Test dot-syntax with a local variable. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int a;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
- (int) count;
- (void) setCount: (int)count;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
- (int) count
{
return a;
}
- (void) setCount: (int)count
{
a = count;
}
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
int i;
for (i = 0; i < 10; i++)
{
object.count = i;
if (object.count != i)
abort ();
}
return 0;
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
/* Test dot-syntax with accessors to be looked up in protocol @properties. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
@property int countA;
@end
@protocol ProtocolB
@property int countB;
@end
@protocol ProtocolC
@property int countC;
@end
@interface MyRootClass
{
Class isa;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
@end
int function (MySubClass *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
return object.countC; /* { dg-error "request for member .countC. in" } */
}
int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function5 (id <ProtocolA, ProtocolB> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
return object.countC; /* { dg-error "request for member .countC. in" } */
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
/* Test dot-syntax with accessors to be looked up in protocols. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
- (int) countA;
- (void) setCountA: (int)aNumber;
@end
@protocol ProtocolB
- (int) countB;
- (void) setCountB: (int)aNumber;
@end
@protocol ProtocolC
- (int) countC;
- (void) setCountC: (int)aNumber;
@end
@interface MyRootClass
{
Class isa;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@interface MySubClass <ProtocolA, ProtocolB, ProtocolC>
@end
int function (MySubClass *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
return object.countC; /* { dg-error "request for member .countC. in" } */
}
int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB;
return object.countC;
}
int function5 (id <ProtocolA, ProtocolB> object, int x)
{
object.countA = x;
object.countB = x;
object.countC = object.countB; /* { dg-error "request for member .countC. in" } */
return object.countC; /* { dg-error "request for member .countC. in" } */
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
/* Test @synthesize with protocols of protocols. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@protocol ProtocolA
@property int countA;
@end
@protocol ProtocolB <ProtocolA>
@property int countB;
@end
@protocol ProtocolC <ProtocolB>
@property int countC;
@end
@protocol ProtocolD
@property int countD;
@end
@interface MyRootClass <ProtocolC>
{
Class isa;
int countA;
int countB;
int countC;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
@synthesize countA;
@synthesize countB;
@synthesize countC;
@end
@interface MySubClass : MyRootClass <ProtocolD>
{
int countD;
}
@end
@implementation MySubClass
@synthesize countD;
@end
int main (void)
{
MySubClass *object = [[MySubClass alloc] init];
int i;
for (i = 0; i < 10; i++)
{
object.countA += i;
object.countB += i + 1;
object.countC += i + 2;
object.countD += i + 3;
}
if (object.countA != 45)
abort ();
if (object.countB != 55)
abort ();
if (object.countC != 65)
abort ();
if (object.countD != 75)
abort ();
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: More dot-syntax and @synthesize testcases
2010-11-08 0:14 More dot-syntax and @synthesize testcases Nicola Pero
@ 2010-11-08 21:14 ` Mike Stump
0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2010-11-08 21:14 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On Nov 7, 2010, at 3:43 PM, Nicola Pero wrote:
> This patch adds a few more testcases for Objective-C 2.0 dot-syntax and @synthesize.
> Ok to commit ?
Ok.
> PS: The attached testcases.txt is not a diff; it rather includes all the testcases in the file.
> Each of them starts at the '/* Contributed by ... */' line.
svn add file
svn diff .
is the preferred method... even for new files...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-08 21:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-08 0:14 More dot-syntax and @synthesize testcases Nicola Pero
2010-11-08 21:14 ` Mike Stump
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).