OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc
    from Rev 308 to Rev 309
    Reverse comparison

Rev 308 → Rev 309

/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/objc-nofilename-1.m
0,0 → 1,22
/* Test to make sure that file name does not appear in the binary. */
/* { dg-do compile { target *-*-darwin* } } */
 
#include <objc/objc.h>
 
@interface Foo { Class isa; } @end
@implementation Foo @end
 
@interface Bar : Foo { Class Barisa; } @end
 
@implementation Bar : Foo @end;
 
@interface FINAL : Bar { Class FINALisa; } @end
 
@implementation FINAL : Bar @end;
 
int main(int argc, char **argv)
{
return 0;
}
 
/* { dg-final { scan-assembler-not "objc-nofilename-1.m" } } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/desig-init-1.m
0,0 → 1,51
/* Test Objective-C capability for handling GNU/C99 designated initializers, and distinguishing them
from message sends. Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-std=gnu99" } */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 
 
#include "../objc-obj-c++-shared/Object1.h"
#include <stdio.h>
#include <stdlib.h>
 
@interface Cls : Object
+ (int) meth1;
+ (int) meth2;
+ (void) doTests;
@end
 
@implementation Cls
+ (int) meth1 { return 45; }
+ (int) meth2 { return 21; }
+ (void) doTests {
int arr[7] = {
0,
[Cls meth1],
[2 + 1] = 3,
[2 * 2 ... 5] = (size_t)[0 meth4], /* { dg-warning "invalid receiver type" } */
/* { dg-warning "no .\\-meth4. method found" "" { target *-*-* } 26 } */
[2] [Cls meth2],
/* Since invalid receivers are treated as 'id' for purposes of message
lookup, we _should_ find a meth2 to call below. */
[6] = (int)[0 meth2] /* { dg-warning "invalid receiver type" } */
};
 
if (arr[0] != 0 || arr[1] != 45 || arr[2] != 21 || arr[3] != 3)
abort ();
 
printf ("%s\n", [super name]);
printf ("%d %d %d %d %d %d\n", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
}
@end
 
int main(void) {
[Cls doTests];
return 0;
}
 
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */
 
#include "../objc-obj-c++-shared/Object1-implementation.h"
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-2.m
0,0 → 1,104
/* Test Objective-C method encodings. */
 
/* The _encoded_ parameter offsets for Objective-C methods are
computed inductively as follows:
- The first paramter (self) has offset 0;
- The k-th parameter (k > 1) has offset equal to the
sum of:
- the offset of the k-1-st paramter
- the (void *)-promoted size of the k-1-st parameter.
 
Note that the encoded offsets need not correspond
to the actual placement of parameters (relative to 'self')
on the stack! Your target's ABI may have very different
opinions on the matter. */
 
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 
#include "../objc-obj-c++-shared/Object1.h"
#include "../objc-obj-c++-shared/next-mapping.h"
 
#ifdef __NEXT_RUNTIME__
#define METHOD Method
#else
#include <objc/objc-api.h>
#define METHOD Method_t
#define method_get_types(M) (M)->method_types
#endif
 
extern int sscanf(const char *str, const char *format, ...);
extern void abort(void);
#define CHECK_IF(expr) if(!(expr)) abort()
 
@interface Foo: Object
typedef struct { float x, y; } XXPoint;
typedef struct { float width, height; } XXSize;
typedef struct _XXRect { XXPoint origin; XXSize size; } XXRect;
-(id)setRect:(XXRect)r withInt:(int)i;
-(void) char:(signed char)c float:(float)f double:(double)d long:(long)l;
@end
 
XXRect my_rect;
unsigned offs1, offs2, offs3, offs4, offs5, offs6, offs7;
 
@implementation Foo
-(id)setRect:(XXRect)r withInt:(int)i {
unsigned offs = sizeof(self);
CHECK_IF(offs == offs3);
offs += sizeof(_cmd);
CHECK_IF(offs == offs4);
offs += sizeof(r);
CHECK_IF(offs == offs5);
offs += sizeof(i);
CHECK_IF(offs == offs1);
return nil;
}
-(void) char:(signed char)c float:(float)f double:(double)d long:(long)l {
unsigned offs = sizeof(self);
CHECK_IF(offs == offs3);
offs += sizeof(_cmd);
CHECK_IF(offs == offs4);
offs += sizeof((int)c);
CHECK_IF(offs == offs5);
offs += sizeof(f);
CHECK_IF(offs == offs6);
offs += sizeof(d);
CHECK_IF(offs == offs7);
offs += sizeof(l);
CHECK_IF(offs == offs1);
}
@end
 
 
int main(void) {
Foo *foo = [[Foo alloc] init];
Class fooClass = objc_get_class("Foo");
METHOD meth;
const char *string;
 
meth = class_get_instance_method(fooClass, @selector(setRect:withInt:));
offs2 = 9999;
 
sscanf(method_get_types(meth), "@%u@%u:%u{_XXRect={?=ff}{?=ff}}%ui%u", &offs1, &offs2, &offs3,
&offs4, &offs5);
CHECK_IF(!offs2);
[foo setRect:my_rect withInt:123];
 
meth = class_get_instance_method(fooClass, @selector(char:float:double:long:));
offs2 = 9999;
if (sizeof (long) == 8)
string = "v%u@%u:%uc%uf%ud%uq%u";
else
string = "v%u@%u:%uc%uf%ud%ul%u";
sscanf(method_get_types(meth), string, &offs1, &offs2, &offs3,
&offs4, &offs5, &offs6, &offs7);
CHECK_IF(!offs2);
[foo char:'c' float:2.3 double:3.5 long:2345L];
 
return 0;
}
 
#include "../objc-obj-c++-shared/Object1-implementation.h"
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-6.m
0,0 → 1,22
/* Test for graceful encoding of const-qualified fields and parameters. */
/* Author: Ziemowit Laski <zlaski@apple.com> */
/* { dg-do compile } */
 
struct Cxx {
const struct Cxx *next;
};
 
@interface ObjC {
const struct Cxx *obj;
}
- (ObjC *)initWithCxx: (struct Cxx *const)c and: (const struct Cxx *)d;
@end
 
@implementation ObjC
- (ObjC *)initWithCxx: (struct Cxx *const)c and: (const struct Cxx *)d {
obj = d;
return self;
}
@end
 
/* { dg-final { scan-assembler "@\[0-9\]+@0:\[0-9\]+r\\^{Cxx=\\^r{Cxx}}\[0-9\]+\\^r{Cxx}" } } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-4.m
0,0 → 1,73
/* Test warnings for assignments and comparisons between ObjC and C types. */
/* Author: Nicola Pero <nicola@brainstorm.co.uk>. */
/* { dg-do compile } */
#include <objc/objc.h>
 
/* The NeXT runtime headers do not define NULL. */
#ifndef NULL
#define NULL ((void *)0)
#endif
 
@protocol MyProtocol
- (void) method;
@end
 
@interface MyClass
@end
 
int main()
{
id obj = nil;
id <MyProtocol> obj_p = nil;
MyClass *obj_c = nil;
Class obj_C = Nil;
int i = 0;
int *j = NULL;
 
/* These should all generate warnings. */
obj = i; /* { dg-warning "pointer from integer without a cast" } */
obj = j; /* { dg-warning "incompatible pointer type" } */
 
obj_p = i; /* { dg-warning "pointer from integer without a cast" } */
obj_p = j; /* { dg-warning "incompatible pointer type" } */
obj_c = i; /* { dg-warning "pointer from integer without a cast" } */
obj_c = j; /* { dg-warning "incompatible pointer type" } */
 
obj_C = i; /* { dg-warning "pointer from integer without a cast" } */
obj_C = j; /* { dg-warning "incompatible pointer type" } */
i = obj; /* { dg-warning "integer from pointer without a cast" } */
i = obj_p; /* { dg-warning "integer from pointer without a cast" } */
i = obj_c; /* { dg-warning "integer from pointer without a cast" } */
i = obj_C; /* { dg-warning "integer from pointer without a cast" } */
j = obj; /* { dg-warning "incompatible pointer type" } */
j = obj_p; /* { dg-warning "incompatible pointer type" } */
j = obj_c; /* { dg-warning "incompatible pointer type" } */
j = obj_C; /* { dg-warning "incompatible pointer type" } */
if (obj == i) ; /* { dg-warning "comparison between pointer and integer" } */
if (i == obj) ; /* { dg-warning "comparison between pointer and integer" } */
if (obj == j) ; /* { dg-warning "lacks a cast" } */
if (j == obj) ; /* { dg-warning "lacks a cast" } */
 
if (obj_c == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (i == obj_c) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (obj_c == j) ; /* { dg-warning "lacks a cast" } */
if (j == obj_c) ; /* { dg-warning "lacks a cast" } */
 
if (obj_p == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (i == obj_p) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (obj_p == j) ; /* { dg-warning "lacks a cast" } */
if (j == obj_p) ; /* { dg-warning "lacks a cast" } */
 
if (obj_C == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (i == obj_C) ; /*{ dg-warning "comparison between pointer and integer" }*/
if (obj_C == j) ; /* { dg-warning "lacks a cast" } */
if (j == obj_C) ; /* { dg-warning "lacks a cast" } */
 
return 0;
}
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dwarf-1.m
0,0 → 1,6
/* { dg-options "-gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "\"id.0\".*DW_AT_name" } } */
/* { dg-skip-if "No Dwarf" { { *-*-aix* alpha*-dec-osf* hppa*-*-hpux* } && { ! hppa*64*-*-* } } { "*" } { "" } } */
@interface foo
id x;
@end
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-6.m
0,0 → 1,25
/* { dg-do compile } */
/* { dg-options "-fobjc-exceptions" } */
 
#include "../objc-obj-c++-shared/Object1.h"
 
int main (int argc, const char * argv[]) {
Object * pool = [Object new];
int a;
 
if ( 1 ) {
@try {
a = 1;
}
@catch (Object *e) {
a = 2;
}
@finally {
a = 3;
}
}
[pool free];
return 0;
}
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-4.m
0,0 → 1,34
/* Bail out gracefully if attempting to derive from a class that has only been
forward-declared (via @class). Conversely, @compatibility_alias declarations
should be traversed to find the @interface. */
/* { dg-do compile } */
 
#include "../objc-obj-c++-shared/Object1.h"
 
@class MyWpModule;
 
@compatibility_alias MyObject Object;
@compatibility_alias FictitiousModule MyWpModule;
 
@protocol MySelTarget
- (id) meth1;
@end
 
@protocol Img
- (id) meth2;
@end
 
@interface FunnyModule: FictitiousModule <Img> /* { dg-error ".MyWpModule., superclass of .FunnyModule." } */
- (id) meth2;
@end
 
@interface MyProjWpModule : MyWpModule <MySelTarget, Img> /* { dg-error ".MyWpModule., superclass of .MyProjWpModule." } */ {
id i1, i2;
}
- (id) meth1;
- (id) meth2;
@end
 
@interface AnotherModule: MyObject <MySelTarget>
- (id) meth1;
@end
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pragma-1.m
0,0 → 1,7
/* { dg-do compile } */
/* ??? Is there a better pragma that is handled for all targets, not
handled by the preprocessor, that would be better for testing here? */
 
@interface a {}
#pragma mark --- Output ---
@end
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-8.m
0,0 → 1,24
/* { dg-do compile } */
/* Another gimplifier ICE... */
 
#include "../objc-obj-c++-shared/Object1.h"
 
@interface MyView: Object {
int _frame;
}
- (void)_finalize;
@end
 
@interface MyViewTemplate: MyView {
void *_className;
}
- (id)createRealObject;
@end
 
@implementation MyViewTemplate
- (id)createRealObject {
id realObj;
*(MyView *)realObj = *(MyView *)self;
return realObj;
}
@end
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-2.m
0,0 → 1,138
/* Check if casting 'self' or 'super' affects message lookup in the correct way. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
 
#include "../objc-obj-c++-shared/Object1.h"
#include "../objc-obj-c++-shared/next-mapping.h"
#include <stddef.h>
 
@protocol Func
+ (int) class_func0;
- (int) instance_func0;
@end
 
@interface Derived: Object
+ (int) class_func1;
+ (int) class_func2;
+ (int) class_func3;
+ (int) class_func4;
+ (int) class_func5;
+ (int) class_func6;
+ (int) class_func7;
- (int) instance_func1;
- (int) instance_func2;
- (int) instance_func3;
- (int) instance_func4;
- (int) instance_func5;
- (int) instance_func6;
- (int) instance_func7;
@end
 
@interface Derived (Categ)
+ (int) categ_class_func1;
+ (int) categ_class_func2;
- (int) categ_instance_func1;
- (int) categ_instance_func2;
@end
 
@implementation Derived
+ (int) class_func1
{
int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
return i + (size_t)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
}
+ (int) class_func2
{
int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
i += [(Class <Func>)self class_func0];
return i + [(Class <Func>)super class_func0];
}
+ (int) class_func3
{
return [(Object <Func> *)super class_func0];
}
+ (int) class_func4
{
return [(Derived <Func> *)super class_func0];
}
+ (int) class_func5
{
int i = (size_t)[Derived class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
return i + (size_t)[Object class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
}
+ (int) class_func6
{
return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
}
+ (int) class_func7
{
return [objc_get_class("Derived") class_func1];
}
- (int) instance_func1
{
int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
return i + (size_t)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
}
- (int) instance_func2
{
return [(id <Func>)super instance_func0];
}
- (int) instance_func3
{
return [(Object <Func> *)super instance_func0];
}
- (int) instance_func4
{
return [(Derived <Func> *)super instance_func0];
}
- (int) instance_func5
{
int i = (size_t)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
return i + (size_t)[Object instance_func1]; /* { dg-warning ".Object. may not respond to .\\+instance_func1." } */
}
- (int) instance_func6
{
return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
}
- (int) instance_func7
{
return [objc_get_class("Derived") class_func1];
}
@end
 
@implementation Derived (Categ)
+ (int) categ_class_func1
{
int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
i += [self class_func1];
i += [self categ_class_func2];
i += (size_t)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
return i + (size_t)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
}
+ (int) categ_class_func2
{
int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
i += [(Class <Func>)self class_func0];
return i + [(Class <Func>)super class_func0];
}
- (int) categ_instance_func1
{
int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
i += [(Derived <Func> *)self categ_instance_func2];
i += (size_t)[(Object <Func> *)self categ_instance_func2]; /* { dg-warning ".Object. may not respond to .\\-categ_instance_func2." } */
/* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } 124 } */
i += (size_t)[(id <Func>)self categ_instance_func2]; /* { dg-warning ".\\-categ_instance_func2. not found in protocol" } */
i += [(id)self categ_instance_func2];
return i + (size_t)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
}
- (int) categ_instance_func2
{
return [(id <Func>)super instance_func0];
}
@end
 
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/private-1.m
0,0 → 1,59
/* Test errors for accessing @private and @protected variables. */
/* Author: Nicola Pero <nicola@brainstorm.co.uk>. */
/* { dg-do compile } */
#include <objc/objc.h>
 
@interface MySuperClass
{
@private
int private;
 
@protected
int protected;
 
@public
int public;
}
- (void) test;
@end
 
@implementation MySuperClass
- (void) test
{
private = 12; /* Ok */
protected = 12; /* Ok */
public = 12; /* Ok */
}
@end
 
 
@interface MyClass : MySuperClass
@end
 
@implementation MyClass
- (void) test
{
/* Private variables simply don't exist in the subclass. */
private = 12;/* { dg-error "undeclared" } */
/* { dg-message "function it appears in" "" { target *-*-* } { 37 } } */
 
protected = 12; /* Ok */
public = 12; /* Ok */
}
@end
 
int main (void)
{
MyClass *m = nil;
if (m != nil)
{
int access;
 
access = m->private; /* { dg-warning "is @private" } */
access = m->protected; /* { dg-warning "is @protected" } */
access = m->public; /* Ok */
}
 
return 0;
}
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-stream-1.m
0,0 → 1,25
/* { dg-do run } */
/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
#include <objc/typedstream.h>
#include <stdio.h>
#include <stdlib.h>
 
int main (void)
{
FILE *f; TypedStream *ts;
struct T { int a, b; } x = { 1, 2 };
f = fopen ("foo", "w"); ts = objc_open_typed_stream (f, OBJC_WRITEONLY);
objc_write_type (ts, @encode(struct T), &x);
objc_close_typed_stream (ts); fclose (f);
f = fopen ("foo", "r"); ts = objc_open_typed_stream (f, OBJC_READONLY);
struct T y;
objc_read_type (ts, @encode(struct T), &y);
if (y.a != 1)
abort ();
if (y.b != 2)
abort ();
objc_close_typed_stream (ts); fclose (f);
remove ("foo");
return 0;
}
 
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/objc-fast-4.m
0,0 → 1,12
/* The code should call objc_msgSend directly, not through a pointer. */
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0" } */
/* Radar 4015820 */
 
#include "../objc-obj-c++-shared/Object1.h"
 
void foo(void) {
Object *o;
[o++ free];
}
/* { dg-final { scan-assembler-not "L_objc_msgSend\\\$non_lazy_ptr" } } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/no-extra-load.m
0,0 → 1,7
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 
#import <Foundation/Foundation.h>
main() { [NSObject new]; }
 
/* { dg-final { scan-assembler-not "L_objc_msgSend\\\$non_lazy_ptr" } } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-1.m
0,0 → 1,27
/* Test warning for non existing selectors. */
/* Contributed by Devang Patel <dpatel@apple.com>. */
/* { dg-options "-Wselector" } */
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 
typedef struct objc_object { struct objc_class *class_pointer; } *id;
typedef struct objc_selector *SEL;
 
@interface Foo
- (void) foo;
- (void) bar;
@end
 
@implementation Foo
- (void) bar
{
}
 
- (void) foo
{
SEL a,b,c;
a = @selector(b1ar); /* { dg-warning "creating selector for nonexistent method .b1ar." } */
b = @selector(bar);
}
@end
 
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-2.m
0,0 → 1,32
/* Test for lookup of class (factory) methods. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
 
@interface MyBase
- (void) rootInstanceMethod;
@end
 
@interface MyIntermediate: MyBase
@end
 
@interface MyDerived: MyIntermediate
- (void) instanceMethod;
+ (void) classMethod;
@end
 
@implementation MyDerived
- (void) instanceMethod {
}
 
+ (void) classMethod { /* If a class method is not found, the root */
[self rootInstanceMethod]; /* class is searched for an instance method */
[MyIntermediate rootInstanceMethod]; /* with the same name. */
 
[self instanceMethod]; /* { dg-warning ".MyDerived. may not respond to .\\+instanceMethod." } */
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 25 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 25 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 25 } */
[MyDerived instanceMethod]; /* { dg-warning ".MyDerived. may not respond to .\\+instanceMethod." } */
}
@end
 
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-6.m
0,0 → 1,32
/* Check that sending messages to variables of type 'Class' does not involve instance methods,
unless they reside in root classes. */
/* Author: Ziemowit Laski <zlaski@apple.com> */
/* { dg-do compile } */
/* { dg-options "-Wstrict-selector-match" } */
 
#include "../objc-obj-c++-shared/Protocol1.h"
 
@interface Base
- (unsigned)port;
@end
 
@interface Derived: Base
- (Object *)port;
+ (Protocol *)port;
- (id)starboard;
@end
 
void foo(void) {
Class receiver;
 
[receiver port]; /* { dg-warning "multiple methods named .\\+port. found" } */
/* { dg-message "using .\\-\\(unsigned( int)?\\)port." "" { target *-*-* } 10 } */
/* { dg-message "also found .\\+\\(Protocol \\*\\)port." "" { target *-*-* } 15 } */
 
[receiver starboard]; /* { dg-warning "no .\\+starboard. method found" } */
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 26 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 26 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 26 } */
 
[Class port]; /* { dg-error ".Class. is not an Objective\\-C class name or alias" } */
}
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stubify-2.m
0,0 → 1,33
/* All calls must be properly stubified, m32 only. */
/* Testcase extracted from TextEdit:Document.m. */
 
/* { dg-do compile { target powerpc*-*-darwin* } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-require-effective-target ilp32 } */
/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4" } */
 
typedef struct objc_object { } *id ;
int x = 41 ;
extern id objc_msgSend(id self, char * op, ...);
extern int bogonic (int, int, int) ;
@interface Document {}
- (Document *) window;
- (Document *) class;
- (Document *) close;
@end
@implementation Document
- (Document *) class { }
- (Document *) close { }
- (Document *) window { }
- (void)willEndCloseSheet:(void *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
[[self window] close];
((void (*)(id, char *, int))objc_msgSend)([self class], (char *)contextInfo, 1);
((void (*)(id, char *, int))bogonic)([self class], (char *)contextInfo, 1);
bogonic (3, 4, 5);
x++;
}
@end
 
/* Any symbol_ref of an un-stubified objc_msgSend is an error; look
for "objc_msgSend" in quotes, without the $stub suffix. */
/* { dg-final { scan-rtl-dump-not "symbol_ref.*\"objc_msgSend\"" "jump" } } */
/trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
0,0 → 1,25
/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
 
/* Test loading unclaimed categories - categories of a class defined
separately from the class itself. */
 
@interface TestClass
{
id isa;
}
- (int)D;
@end
 
@interface TestClass (A)
- (int)A;
@end
 
@interface TestClass (B)
- (int)B;
@end
 
@interface TestClass (C)
- (int)C;
@end
 
 
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1.m (revision 309) @@ -0,0 +1,77 @@ +/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#import "../../objc-obj-c++-shared/next-mapping.h" +#include +#ifndef __NEXT_RUNTIME__ +#include +#endif + +extern void abort (void); + +/* Test loading unclaimed categories - categories of a class defined + separately from the class itself. */ + + +/* unclaimed-category-1.m contains only the class definition but not + the categories. unclaimed-category-1a.m contains only the + categories of the class, but not the class itself. We want to + check that the runtime can load the class from one module (file) + and the categories from another module (file). */ + +#include "unclaimed-category-1.h" + +@implementation TestClass +- (int)D +{ + return 4; +} +#ifdef __NEXT_RUNTIME__ ++ initialize { return self; } +#endif +@end + + +int main (void) +{ + TestClass *test; + Class testClass; + + testClass = objc_get_class ("TestClass"); + if (testClass == Nil) + { + abort (); + } + + test = (TestClass *)(class_create_instance (testClass)); + if (test == nil) + { + abort (); + } + + if ([test A] != 1) + { + abort (); + } + + if ([test B] != 2) + { + abort (); + } + + if ([test C] != 3) + { + abort (); + } + + + if ([test D] != 4) + { + abort (); + } + + return 0; +} + +#import "../../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m (revision 309) @@ -0,0 +1,29 @@ +/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */ + +/* Test loading unclaimed categories - categories of a class defined + separately from the class itself. */ + +#include "unclaimed-category-1.h" + +@implementation TestClass (A) +- (int)A +{ + return 1; +} +@end + +@implementation TestClass (B) +- (int)B +{ + return 2; +} +@end + +@implementation TestClass (C) +- (int)C +{ + return 3; +} +@end + + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/special.exp =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/special.exp (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/special/special.exp (revision 309) @@ -0,0 +1,61 @@ +# GCC Objective-C testsuite that uses the `dg.exp' driver. +# Copyright (C) 1997, 2001, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Load support procs. +load_lib objc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "" +} + +# Initialize `dg'. +dg-init + +# +# unclaimed-category-1 test +# +# This test is special because we must compile two different modules, +# unclaimed-category-1a.m and unclaimed-category-1.m, then link +# together, then run the resulting executable. +# for all systems we point to the libobjc includes and use the -fgnu-runtime +set add_flags "additional_flags=-I${srcdir}/../../libobjc" +lappend add_flags "additional_flags=-fgnu-runtime" +set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ] +if ![string match "" $lines] then { + fail "unclaimed-category-1a.o" +} else { + dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-I${srcdir}/../../libobjc -fgnu-runtime" + file delete unclaimed-category-1a.o +} + +if [istarget "*-*-darwin*" ] { +set add_flags "" +lappend add_flags "additional_flags=-fnext-runtime" +set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ] +if ![string match "" $lines] then { + fail "unclaimed-category-1a.o" +} else { + dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-fnext-runtime" + file delete unclaimed-category-1a.o +} +} + +# All done. +dg-finish + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-1.m (revision 309) @@ -0,0 +1,51 @@ +/* Test for handling of function pointer ivars */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern int strcmp(const char *, const char *); +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +typedef float (*floatfunc)(float, float); + +@interface MyObject : Object +{ +@public + int (*ivar)(int, int, int); + floatfunc ffunc; +} +- init; +@end + +int foo(int a, int b, int c) { + return a + b + c; +} + +float bar(float a, float b) { + return a * b; +} + +@implementation MyObject +- init { + [super init]; + ivar = foo; + ffunc = bar; + return self; +} +@end + +int main () +{ + MyObject *obj = [[MyObject alloc] init]; + const char *enc = @encode(MyObject); + + CHECK_IF(obj->ivar(4, 5, 6) == 15); + CHECK_IF(obj->ffunc(34.0, 45.0) == 34.0 * 45.0); + CHECK_IF(!strcmp(enc, "{MyObject=#^?^?}")); + return(0); +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-3.m (revision 309) @@ -0,0 +1,53 @@ +/* Test the -fconstant-string-class=Foo option under the NeXT runtime. */ +/* Developed by Markus Hitter . */ +/* { dg-do run } */ +/* { dg-options "-fconstant-string-class=Foo" } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#import "../objc-obj-c++-shared/Object1.h" +#import "../objc-obj-c++-shared/next-mapping.h" +#include +#include +#include + +@interface Foo: Object { + char *cString; + unsigned int len; +} +- (char *)customString; +@end + +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +struct fudge_objc_class _FooClassReference; +#else +struct objc_class _FooClassReference; +#endif + +@implementation Foo : Object +- (char *)customString { + return cString; +} +@end + +int main () { + Foo *string = @"bla"; + Foo *string2 = @"bla"; + + if(string != string2) + abort(); + printf("Strings are being uniqued properly\n"); + + /* This memcpy has to be done before the first message is sent to a + constant string object. Can't be moved to +initialize since _that_ + is already a message. */ + + memcpy(&_FooClassReference, objc_get_class("Foo"), sizeof(_FooClassReference)); + if (strcmp ([string customString], "bla")) { + abort (); + } + + printf([@"This is a working constant string object\n" customString]); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-1.m (revision 309) @@ -0,0 +1,44 @@ +/* Test for situations in which protocol conformance information + may be lost, leading to superfluous warnings. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +/* One-line substitute for objc/objc.h */ +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +@protocol NSObject +- (int)someValue; +@end + +@interface NSObject +@end + +@protocol PlateMethods +- (void)someMethod; +@end + +@interface Foo { + NSObject *plate; + id plate1; + NSObject *plate2; +} +- (id ) getPlate; +- (id ) getPlate1; +- (int) getValue; +@end + +@implementation Foo +- (id ) getPlate { + return plate; /* { dg-bogus "does not implement" } */ +} +- (id ) getPlate1 { + return (id )plate1; /* { dg-bogus "does not conform" } */ +} +- (int) getValue { + int i = [plate1 someValue]; /* { dg-warning ".\\-someValue. not found in protocol\\(s\\)" } */ + + int j = [(id )plate1 someValue]; /* { dg-bogus "not found in protocol" } */ + int k = [(id)plate1 someValue]; /* { dg-bogus "not found in protocol" } */ + return i + j + k; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-1.m (revision 309) @@ -0,0 +1,65 @@ +/* Test for handling of struct-returning methods. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +struct astruct { + float a, b; +} globa = { 1.0, 2.0 }; + +struct bstruct { + float a, b, c, d, e, f; +} globb = { 1, 2, 3, 4, 5, 6 }; + +@interface foo : Object +- (struct astruct) stret; +- (struct bstruct) stretb; +@end + +@implementation foo : Object +- (struct astruct) stret { return globa; } +- (struct bstruct) stretb { return globb; } +@end + +@interface bar: foo +- (struct astruct) stret; +- (struct bstruct) stretb; +@end + +@implementation bar +- (struct astruct) stret { struct astruct a = [super stret]; a.b = 77; return a; } +- (struct bstruct) stretb { struct bstruct b = [super stretb]; b.e = 99; return b; } +@end + +int main(void) +{ + foo *obj = [foo new]; + bar *obj2 = [bar new]; + struct astruct loc, loc2; + struct bstruct locb, locb2; + + loc = [obj stret]; + CHECK_IF(loc.a == 1.0 && loc.b == 2.0); + + locb = [obj stretb]; + CHECK_IF(locb.f == 6 && locb.c == 3); + CHECK_IF(locb.e == 5 && locb.b == 2); + CHECK_IF(locb.d == 4 && locb.a == 1); + + loc2 = [obj2 stret]; + CHECK_IF(loc2.a == 1.0 && loc2.b == 77); + + locb2 = [obj2 stretb]; + CHECK_IF(locb2.f == 6 && locb2.c == 3); + CHECK_IF(locb2.e == 99 && locb2.b == 2); + CHECK_IF(locb2.d == 4 && locb2.a == 1); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-11.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-11.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-11.m (revision 309) @@ -0,0 +1,33 @@ +/* Ensure that we indeed cannot obtain the value of a message send + if the chosen method signature returns 'void'. There used to + exist a cheesy hack that allowed it. While at it, check that + the first lexically occurring method signature gets picked + when sending messages to 'id'. */ +/* Contributed by Ziemowit Laski */ +/* { dg-do compile } */ + +#include + +@interface Object1 +- (void)initWithData:(Object1 *)data; +@end + +@interface Object2 +- (id)initWithData:(Object1 *)data; +@end + +@interface Object3 +- (id)initWithData:(Object2 *)data; +@end + +void foo(void) { + id obj1, obj2 = 0; + obj2 = [obj1 initWithData: obj2]; + /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } 25 } */ + /* { dg-message "using .\\-\\(void\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } 12 } */ + /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } 16 } */ + /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object2 \\*\\)data." "" { target *-*-* } 20 } */ + + /* The following error is a consequence of picking the "wrong" method signature. */ + /* { dg-error "void value not ignored as it ought to be" "" { target *-*-* } 25 } */ +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-7.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-7.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-7.m (revision 309) @@ -0,0 +1,42 @@ +/* Test to make sure that the const objc strings are the same across scopes. */ +/* Developed by Andrew Pinski */ +/* { dg-options "-fconstant-string-class=Foo " } */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include +#include +#include + +@interface Foo: Object { + char *cString; + unsigned int len; +} +- (char *)customString; +@end + +#ifndef NEXT_OBJC_USE_NEW_INTERFACE +struct objc_class _FooClassReference; +#else +Class _FooClassReference; +#endif + +@implementation Foo : Object +- (char *)customString { + return cString; +} +@end + +int main () { + Foo *string = @"bla"; + { + Foo *string2 = @"bla"; + + if(string != string2) + abort(); + printf("Strings are being uniqued properly\n"); + } + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-5.m (revision 309) @@ -0,0 +1,22 @@ +/* Do not lose references to forward-declared protocols. */ +/* { dg-do compile } */ +@class MyBaseClass; +@class MyClassThatFails; +@protocol _MyProtocol; + +@interface MyClassThatFails +- (MyBaseClass<_MyProtocol> *) aMethod; +@end + +@interface MyBaseClass +@end + +@protocol _MyProtocol +@end + +@implementation MyClassThatFails +- (MyBaseClass<_MyProtocol> *) aMethod +{ + return 0; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-15.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-15.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-15.m (revision 309) @@ -0,0 +1,56 @@ +/* Test if prior method lookup at method @implementation time is not + overly aggressive, leading to methods being found in other classes. */ +/* Author: Ziemowit Laski . */ + +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@class NSString; + +@protocol NSMenuItem ++ (void)setUsesUserKeyEquivalents:(BOOL)flag; ++ (BOOL)usesUserKeyEquivalents; +@end + +@interface NSMenuItem : Object { + @private + id _menu; +} +@end + +@interface NSResponder : Object +{ + id _nextResponder; +} +@end + +@interface Object(NSMenuValidation) +- (BOOL)validateMenuItem:(id )menuItem; +@end + +@interface NSResponder (NSStandardKeyBindingMethods) +- (void)insertText:(id)insertString; +- (void)doCommandBySelector:(SEL)aSelector; +@end + +@interface NSView : NSResponder +{ + id _superview; + id _subviews; +} +@end + +@interface SKTGraphicView : NSView { + @private + float _gridSpacing; +} +@end + +@implementation SKTGraphicView +- (BOOL)validateMenuItem:(NSMenuItem *)item { + return (BOOL)1; +} +- (void)insertText:(NSString *)str { +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-19.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-19.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-19.m (revision 309) @@ -0,0 +1,17 @@ +/* The following should NOT generate "may not respond to" warnings, since a forward-declared + @class (instance) should be treated like a 'Class') ('id'). */ + +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@class NotKnown; + +void foo(NotKnown *n) { + [NotKnown new]; + [n nonexistent_method]; /* { dg-warning "no .\\-nonexistent_method. method found" } */ +} + +/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ +/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ +/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-1.m (revision 309) @@ -0,0 +1,30 @@ +/* Check if the '-fzero-link' flag correctly emits an objc_getClass() call. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-options "-fzero-link" } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object ++ (int) getValue; +@end + +@implementation Base ++ (int) getValue { return 1593; } +@end + +int main(void) { + int val = [Base getValue]; + CHECK_IF(val == 1593); + return 0; +} + +/* { dg-final { scan-assembler-not "_OBJC_CLASS_REFERENCES_0" } } */ +/* { dg-final { scan-assembler "objc_getClass" } } */ + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-10.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-10.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-10.m (revision 309) @@ -0,0 +1,33 @@ +/* Test if ObjC constant string layout is checked properly, regardless of how + constant string classes get derived. */ +/* Contributed by Ziemowit Laski */ + +/* { dg-do compile { target { *-*-darwin* } } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface NSString: Object +@end + +@interface NSSimpleCString : NSString { +@protected + char *bytes; + unsigned int numBytes; +} +@end + +@interface NSConstantString : NSSimpleCString +@end + +#ifndef NEXT_OBJC_USE_NEW_INTERFACE +extern struct objc_class _NSConstantStringClassReference; +#else +extern Class _NSConstantStringClassReference; +#endif + +const NSConstantString *appKey = @"MyApp"; + +/* { dg-final { scan-assembler ".section __OBJC, __cstring_object" } } */ +/* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler ".quad\t__NSConstantStringClassReference\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-3.m (revision 309) @@ -0,0 +1,14 @@ +/* Sanity check for GNU-runtime regardless of runtime used on target system. */ + +/* { dg-do run } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +#include +#include +#include + +int main(int argc, void **args) +{ + [Object new]; + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sync-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sync-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sync-1.m (revision 309) @@ -0,0 +1,12 @@ +/* Make sure that @synchronized parses. */ +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +void foo(id sem) +{ + @synchronized (sem) { + return; + } +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/layout-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/layout-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/layout-1.m (revision 309) @@ -0,0 +1,15 @@ +/* Ensure that we do not get bizarre warnings referring to + __attribute__((packed)) or some such. */ +/* { dg-do compile } */ +/* { dg-options "-Wpadded -Wpacked" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Derived1: Object +{ } +@end + +@interface Derived2: Object +- (id) foo; +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/category-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/category-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/category-1.m (revision 309) @@ -0,0 +1,51 @@ +/* Test class methods inside categories. */ +/* Author: Ziemowit Laski . */ + +/* { dg-do run } */ +/* { dg-xfail-run-if "need OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +extern int strcmp(const char *s1, const char *s2); +extern void abort(void); + +#ifdef __NEXT_RUNTIME__ +#define SUPERCLASS superclass +#else +#define SUPERCLASS superClass +#endif + +#define CHECK_IF(expr) if(!(expr)) abort() + +@interface MyObject: Object ++ (Class)whatever1; +@end + +@implementation MyObject ++ (Class)whatever1 { return [super SUPERCLASS]; } +@end + +@interface MyObject (ThisWontCompile) ++(Class)whatever2; +@end + +@implementation MyObject (ThisWontCompile) ++(Class)whatever2 { return [super SUPERCLASS]; } +@end + +int main (int argc, const char * argv[]) +{ + Class w1 = [MyObject whatever1]; + Class w2 = [MyObject whatever2]; + +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + CHECK_IF(!strcmp( object_getClassName( w1 ), "Object")); + CHECK_IF(!strcmp( object_getClassName( w2 ), "Object")); +#else + CHECK_IF(!strcmp(w1->name, "Object")); + CHECK_IF(!strcmp(w2->name, "Object")); +#endif + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/compat-common.h =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/compat-common.h (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/compat-common.h (revision 309) @@ -0,0 +1,43 @@ +/* Several of the binary compatibility tests use these macros to + allow debugging the test or tracking down a failure by getting an + indication of whether each individual check passed or failed. + When DBG is defined, each check is shown by a dot (pass) or 'F' + (fail) rather than aborting as soon as a failure is detected. */ + +#ifdef DBG +#include +#define DEBUG_INIT setbuf (stdout, NULL); +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#define DEBUG_FAIL putc ('F', stdout); fails++ +#define DEBUG_CHECK { DEBUG_FAIL; } else { DEBUG_DOT; } +#define DEBUG_FINI if (fails) DEBUG_FPUTS ("failed\n"); \ + else DEBUG_FPUTS ("passed\n"); +#else +#define DEBUG_INIT +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#define DEBUG_FAIL abort () +#define DEBUG_CHECK abort (); +#define DEBUG_FINI +#endif + +#ifdef __GNUC__ +#define CINT(x, y) (x + y * __extension__ 1i) +#define CDBL(x, y) (x + y * __extension__ 1i) +#else +#ifdef __SUNPRO_C +/* ??? Complex support without . */ +#else +#include +#endif +#ifndef SKIP_COMPLEX_INT +#define CINT(x, y) ((_Complex int) (x + y * _Complex_I)) +#endif +#define CDBL(x, y) (x + y * _Complex_I) +#endif + +extern void abort (void); +extern int fails;
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/compat-common.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1_test.h =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1_test.h (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1_test.h (revision 309) @@ -0,0 +1,9 @@ +#include "struct-layout-1.h" + +#define TX(n, type, attrs, fields, ops) \ +type S##n { fields } attrs; \ +void test##n (void) \ +{ \ + if (objc_sizeof_type (@encoding (type S##n)) != sizeof(type S##n)) \ + fails ++; \ +}
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1_test.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1.h =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1.h (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1.h (revision 309) @@ -0,0 +1,704 @@ +#include +#include +#include +#include +#include +#include +#include "compat-common.h" + +#ifndef SKIP_ATTRIBUTE +# include "vector-defs.h" +#else +typedef int qi; +typedef int hi; +typedef int si; +typedef int di; +typedef float sf; +typedef float df; +typedef int v8qi; +typedef int v16qi; +typedef int v2hi; +typedef int v4hi; +typedef int v8hi; +typedef int v2si; +typedef int v4si; +typedef int v1di; +typedef int v2di; +typedef int v2sf; +typedef int v4sf; +typedef int v16sf; +typedef int v2df; +typedef int u8qi; +typedef int u16qi; +typedef int u2hi; +typedef int u4hi; +typedef int u8hi; +typedef int u2si; +typedef int u4si; +typedef int u1di; +typedef int u2di; +typedef int u2sf; +typedef int u4sf; +typedef int u16sf; +typedef int u2df; +#endif +#if (defined __i386__ || defined __x86_64__) && !defined SKIP_ATTRIBUTE +# ifdef __MMX__ +# include +# else +typedef int __m64; +# endif +# ifdef __SSE__ +# include +# else +typedef int __m128; +# endif +#else +typedef int __m64; +typedef int __m128; +#endif + +#define FLDS_MAX 32 +extern struct Info +{ + int nfields, nbitfields; + void *sp, *a0p, *a3p; + void *flds[FLDS_MAX]; + size_t sz, sizes[FLDS_MAX]; + size_t als, ala0, ala3, aligns[FLDS_MAX]; +} info; + +extern int intarray[256]; +extern int fn0 (void), fn1 (void), fn2 (void), fn3 (void), fn4 (void); +extern int fn5 (void), fn6 (void), fn7 (void), fn8 (void), fn9 (void); + +#ifdef DBG +#define FAIL(n, m) printf ("fail %d.%d\n", n, m), ++fails +#else +#define FAIL(n, m) ++fails +#endif + +#ifdef SKIP_ATTRIBUTE +# define __attribute__(x) +#endif +#define atal __attribute__((aligned)) +#define atpa __attribute__((packed)) +#define atalpa __attribute__((aligned, packed)) +#define atpaal __attribute__((packed, aligned)) +#define atal1 __attribute__((aligned (1))) +#define atal2 __attribute__((aligned (2))) +#define atal4 __attribute__((aligned (4))) +#define atal8 __attribute__((aligned (8))) +#define atal16 __attribute__((aligned (16))) +#define atal1pa __attribute__((aligned (1), packed)) +#define atal2pa __attribute__((aligned (2), packed)) +#define atal4pa __attribute__((aligned (4), packed)) +#define atal8pa __attribute__((aligned (8), packed)) +#define atal16pa __attribute__((aligned (16), packed)) +#define atpaal1 __attribute__((packed, aligned (1))) +#define atpaal2 __attribute__((packed, aligned (2))) +#define atpaal4 __attribute__((packed, aligned (4))) +#define atpaal8 __attribute__((packed, aligned (8))) +#define atpaal16 __attribute__((packed, aligned (16))) + +#if UCHAR_MAX == 255 && USHORT_MAX == 65535 && UINT_MAX == 4294967295U \ + && ULLONG_MAX == 18446744073709551615ULL +/* For ILP32 and LP64 targets, assume float is at least 32-bit + and double plus long double at least 64-bit. */ +# define atalx1 atal1 +# define atalx2 atal2 +# define atalx4 atal4 +# define atalx8 atal8 +# define atalx16 atal16 +# define atalx1pa atal1pa +# define atalx2pa atal2pa +# define atalx4pa atal4pa +# define atalx8pa atal8pa +# define atalx16pa atal16pa +# define atpaalx1 atpaal1 +# define atpaalx2 atpaal2 +# define atpaalx4 atpaal4 +# define atpaalx8 atpaal8 +# define atpaalx16 atpaal16 +# if ULONG_MAX > 4294967295UL +# define ataly8 atal8 +# define ataly8pa atal8pa +# define atpaaly8 atpaal8 +# define ataly16 atal16 +# define ataly16pa atal16pa +# define atpaaly16 atpaal16 +# else +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +# endif +#else +# define atalx1 +# define atalx2 +# define atalx4 +# define atalx8 +# define atalx16 +# define atalx1pa +# define atalx2pa +# define atalx4pa +# define atalx8pa +# define atalx16pa +# define atpaalx1 +# define atpaalx2 +# define atpaalx4 +# define atpaalx8 +# define atpaalx16 +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +#endif + +#define atQI __attribute__((mode (QI))) +#define atHI __attribute__((mode (HI))) +#define atSI __attribute__((mode (SI))) +#define atDI __attribute__((mode (DI))) + +enum E0 { e0_0 }; +enum E1 { e1_0, e1_1 }; +enum E2 { e2_m3 = -3, e2_m2, e2_m1, e2_0, e2_1, e2_2, e2_3 }; +enum E3 { e3_m127 = -127, e3_m126, e3_m125, e3_0 = 0, e3_125 = 125, e3_126, e3_127 }; +enum E4 { e4_0, e4_1, e4_2, e4_3, e4_253 = 253, e4_254, e4_255 }; +enum E5 { e5_m32767 = -32767, e5_m32766, e5_m32765, e5_0 = 0, e5_32765 = 32765, e5_32766, e5_32767 }; +enum E6 { e6_0, e6_1, e6_2, e6_3, e6_65533 = 65533, e6_65534, e6_65535 }; +enum E7 { e7_m2147483647 = -2147483647, e7_m2147483646, e7_m2147483645, + e7_0, e7_2147483645 = 2147483645, e7_2147483646, e7_2147483647 }; +enum E8 { e8_0, e8_1, e8_2, e8_3, e8_4294967293 = 4294967293U, e8_4294967294, e8_4294967295 }; +enum E9 { e9_m1099511627775 = -1099511627775LL, e9_m1099511627774, e9_m1099511627773, + e9_0, e9_1099511627773 = 1099511627773LL, e9_1099511627774, e9_1099511627775 }; + +typedef char Tchar; +typedef signed char Tschar; +typedef unsigned char Tuchar; +typedef short int Tshort; +typedef unsigned short int Tushort; +typedef int Tint; +typedef unsigned int Tuint; +typedef long int Tlong; +typedef unsigned long int Tulong; +typedef long long int Tllong; +typedef unsigned long long int Tullong; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tcchar; +typedef _Complex signed char Tcschar; +typedef _Complex unsigned char Tcuchar; +typedef _Complex short int Tcshort; +typedef _Complex unsigned short int Tcushort; +typedef _Complex int Tcint; +typedef _Complex unsigned int Tcuint; +typedef _Complex long int Tclong; +typedef _Complex unsigned long int Tculong; +typedef _Complex long long int Tcllong; +typedef _Complex unsigned long long int Tcullong; +#endif +typedef float Tfloat; +typedef double Tdouble; +typedef long double Tldouble; +typedef _Complex float Tcfloat; +typedef _Complex double Tcdouble; +typedef _Complex long double Tcldouble; +typedef bool Tbool; +typedef enum E0 TE0; +typedef enum E1 TE1; +typedef enum E2 TE2; +typedef enum E3 TE3; +typedef enum E4 TE4; +typedef enum E5 TE5; +typedef enum E6 TE6; +typedef enum E7 TE7; +typedef enum E8 TE8; +typedef enum E9 TE9; +typedef void *Tptr; +typedef char *Tcptr; +typedef int *Tiptr; +typedef char Talchar atal; +typedef signed char Talschar atal; +typedef unsigned char Taluchar atal; +typedef short int Talshort atal; +typedef unsigned short int Talushort atal; +typedef int Talint atal; +typedef unsigned int Taluint atal; +typedef long int Tallong atal; +typedef unsigned long int Talulong atal; +typedef long long int Talllong atal; +typedef unsigned long long int Talullong atal; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talcchar atal; +typedef _Complex signed char Talcschar atal; +typedef _Complex unsigned char Talcuchar atal; +typedef _Complex short int Talcshort atal; +typedef _Complex unsigned short int Talcushort atal; +typedef _Complex int Talcint atal; +typedef _Complex unsigned int Talcuint atal; +typedef _Complex long int Talclong atal; +typedef _Complex unsigned long int Talculong atal; +typedef _Complex long long int Talcllong atal; +typedef _Complex unsigned long long int Talcullong atal; +#endif +typedef float Talfloat atal; +typedef double Taldouble atal; +typedef long double Talldouble atal; +typedef _Complex float Talcfloat atal; +typedef _Complex double Talcdouble atal; +typedef _Complex long double Talcldouble atal; +typedef bool Talbool atal; +typedef enum E0 TalE0 atal; +typedef enum E1 TalE1 atal; +typedef enum E2 TalE2 atal; +typedef enum E3 TalE3 atal; +typedef enum E4 TalE4 atal; +typedef enum E5 TalE5 atal; +typedef enum E6 TalE6 atal; +typedef enum E7 TalE7 atal; +typedef enum E8 TalE8 atal; +typedef enum E9 TalE9 atal; +typedef void *Talptr atal; +typedef char *Talcptr atal; +typedef int *Taliptr atal; +typedef char Tal1char atal1; +typedef signed char Tal1schar atal1; +typedef unsigned char Tal1uchar atal1; +typedef short int Tal1short atal1; +typedef unsigned short int Tal1ushort atal1; +typedef int Tal1int atal1; +typedef unsigned int Tal1uint atal1; +typedef long int Tal1long atal1; +typedef unsigned long int Tal1ulong atal1; +typedef long long int Tal1llong atal1; +typedef unsigned long long int Tal1ullong atal1; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal1cchar atal1; +typedef _Complex signed char Tal1cschar atal1; +typedef _Complex unsigned char Tal1cuchar atal1; +typedef _Complex short int Tal1cshort atal1; +typedef _Complex unsigned short int Tal1cushort atal1; +typedef _Complex int Tal1cint atal1; +typedef _Complex unsigned int Tal1cuint atal1; +typedef _Complex long int Tal1clong atal1; +typedef _Complex unsigned long int Tal1culong atal1; +typedef _Complex long long int Tal1cllong atal1; +typedef _Complex unsigned long long int Tal1cullong atal1; +#endif +typedef float Tal1float atal1; +typedef double Tal1double atal1; +typedef long double Tal1ldouble atal1; +typedef _Complex float Tal1cfloat atal1; +typedef _Complex double Tal1cdouble atal1; +typedef _Complex long double Tal1cldouble atal1; +typedef bool Tal1bool atal1; +typedef enum E0 Tal1E0 atal1; +typedef enum E1 Tal1E1 atal1; +typedef enum E2 Tal1E2 atal1; +typedef enum E3 Tal1E3 atal1; +typedef enum E4 Tal1E4 atal1; +typedef enum E5 Tal1E5 atal1; +typedef enum E6 Tal1E6 atal1; +typedef enum E7 Tal1E7 atal1; +typedef enum E8 Tal1E8 atal1; +typedef enum E9 Tal1E9 atal1; +typedef void *Tal1ptr atal1; +typedef char *Tal1cptr atal1; +typedef int *Tal1iptr atal1; +typedef char Tal2char atal2; +typedef signed char Tal2schar atal2; +typedef unsigned char Tal2uchar atal2; +typedef short int Tal2short atal2; +typedef unsigned short int Tal2ushort atal2; +typedef int Tal2int atal2; +typedef unsigned int Tal2uint atal2; +typedef long int Tal2long atal2; +typedef unsigned long int Tal2ulong atal2; +typedef long long int Tal2llong atal2; +typedef unsigned long long int Tal2ullong atal2; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal2cchar atal2; +typedef _Complex signed char Tal2cschar atal2; +typedef _Complex unsigned char Tal2cuchar atal2; +typedef _Complex short int Tal2cshort atal2; +typedef _Complex unsigned short int Tal2cushort atal2; +typedef _Complex int Tal2cint atal2; +typedef _Complex unsigned int Tal2cuint atal2; +typedef _Complex long int Tal2clong atal2; +typedef _Complex unsigned long int Tal2culong atal2; +typedef _Complex long long int Tal2cllong atal2; +typedef _Complex unsigned long long int Tal2cullong atal2; +#endif +typedef float Tal2float atal2; +typedef double Tal2double atal2; +typedef long double Tal2ldouble atal2; +typedef _Complex float Tal2cfloat atal2; +typedef _Complex double Tal2cdouble atal2; +typedef _Complex long double Tal2cldouble atal2; +typedef bool Tal2bool atal2; +typedef enum E0 Tal2E0 atal2; +typedef enum E1 Tal2E1 atal2; +typedef enum E2 Tal2E2 atal2; +typedef enum E3 Tal2E3 atal2; +typedef enum E4 Tal2E4 atal2; +typedef enum E5 Tal2E5 atal2; +typedef enum E6 Tal2E6 atal2; +typedef enum E7 Tal2E7 atal2; +typedef enum E8 Tal2E8 atal2; +typedef enum E9 Tal2E9 atal2; +typedef void *Tal2ptr atal2; +typedef char *Tal2cptr atal2; +typedef int *Tal2iptr atal2; +typedef char Tal4char atal4; +typedef signed char Tal4schar atal4; +typedef unsigned char Tal4uchar atal4; +typedef short int Tal4short atal4; +typedef unsigned short int Tal4ushort atal4; +typedef int Tal4int atal4; +typedef unsigned int Tal4uint atal4; +typedef long int Tal4long atal4; +typedef unsigned long int Tal4ulong atal4; +typedef long long int Tal4llong atal4; +typedef unsigned long long int Tal4ullong atal4; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal4cchar atal4; +typedef _Complex signed char Tal4cschar atal4; +typedef _Complex unsigned char Tal4cuchar atal4; +typedef _Complex short int Tal4cshort atal4; +typedef _Complex unsigned short int Tal4cushort atal4; +typedef _Complex int Tal4cint atal4; +typedef _Complex unsigned int Tal4cuint atal4; +typedef _Complex long int Tal4clong atal4; +typedef _Complex unsigned long int Tal4culong atal4; +typedef _Complex long long int Tal4cllong atal4; +typedef _Complex unsigned long long int Tal4cullong atal4; +#endif +typedef float Tal4float atal4; +typedef double Tal4double atal4; +typedef long double Tal4ldouble atal4; +typedef _Complex float Tal4cfloat atal4; +typedef _Complex double Tal4cdouble atal4; +typedef _Complex long double Tal4cldouble atal4; +typedef bool Tal4bool atal4; +typedef enum E0 Tal4E0 atal4; +typedef enum E1 Tal4E1 atal4; +typedef enum E2 Tal4E2 atal4; +typedef enum E3 Tal4E3 atal4; +typedef enum E4 Tal4E4 atal4; +typedef enum E5 Tal4E5 atal4; +typedef enum E6 Tal4E6 atal4; +typedef enum E7 Tal4E7 atal4; +typedef enum E8 Tal4E8 atal4; +typedef enum E9 Tal4E9 atal4; +typedef void *Tal4ptr atal4; +typedef char *Tal4cptr atal4; +typedef int *Tal4iptr atal4; +typedef char Tal8char atal8; +typedef signed char Tal8schar atal8; +typedef unsigned char Tal8uchar atal8; +typedef short int Tal8short atal8; +typedef unsigned short int Tal8ushort atal8; +typedef int Tal8int atal8; +typedef unsigned int Tal8uint atal8; +typedef long int Tal8long atal8; +typedef unsigned long int Tal8ulong atal8; +typedef long long int Tal8llong atal8; +typedef unsigned long long int Tal8ullong atal8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal8cchar atal8; +typedef _Complex signed char Tal8cschar atal8; +typedef _Complex unsigned char Tal8cuchar atal8; +typedef _Complex short int Tal8cshort atal8; +typedef _Complex unsigned short int Tal8cushort atal8; +typedef _Complex int Tal8cint atal8; +typedef _Complex unsigned int Tal8cuint atal8; +typedef _Complex long int Tal8clong atal8; +typedef _Complex unsigned long int Tal8culong atal8; +typedef _Complex long long int Tal8cllong atal8; +typedef _Complex unsigned long long int Tal8cullong atal8; +#endif +typedef float Tal8float atal8; +typedef double Tal8double atal8; +typedef long double Tal8ldouble atal8; +typedef _Complex float Tal8cfloat atal8; +typedef _Complex double Tal8cdouble atal8; +typedef _Complex long double Tal8cldouble atal8; +typedef bool Tal8bool atal8; +typedef enum E0 Tal8E0 atal8; +typedef enum E1 Tal8E1 atal8; +typedef enum E2 Tal8E2 atal8; +typedef enum E3 Tal8E3 atal8; +typedef enum E4 Tal8E4 atal8; +typedef enum E5 Tal8E5 atal8; +typedef enum E6 Tal8E6 atal8; +typedef enum E7 Tal8E7 atal8; +typedef enum E8 Tal8E8 atal8; +typedef enum E9 Tal8E9 atal8; +typedef void *Tal8ptr atal8; +typedef char *Tal8cptr atal8; +typedef int *Tal8iptr atal8; +typedef char Tal16char atal16; +typedef signed char Tal16schar atal16; +typedef unsigned char Tal16uchar atal16; +typedef short int Tal16short atal16; +typedef unsigned short int Tal16ushort atal16; +typedef int Tal16int atal16; +typedef unsigned int Tal16uint atal16; +typedef long int Tal16long atal16; +typedef unsigned long int Tal16ulong atal16; +typedef long long int Tal16llong atal16; +typedef unsigned long long int Tal16ullong atal16; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal16cchar atal16; +typedef _Complex signed char Tal16cschar atal16; +typedef _Complex unsigned char Tal16cuchar atal16; +typedef _Complex short int Tal16cshort atal16; +typedef _Complex unsigned short int Tal16cushort atal16; +typedef _Complex int Tal16cint atal16; +typedef _Complex unsigned int Tal16cuint atal16; +typedef _Complex long int Tal16clong atal16; +typedef _Complex unsigned long int Tal16culong atal16; +typedef _Complex long long int Tal16cllong atal16; +typedef _Complex unsigned long long int Tal16cullong atal16; +#endif +typedef float Tal16float atal16; +typedef double Tal16double atal16; +typedef long double Tal16ldouble atal16; +typedef _Complex float Tal16cfloat atal16; +typedef _Complex double Tal16cdouble atal16; +typedef _Complex long double Tal16cldouble atal16; +typedef bool Tal16bool atal16; +typedef enum E0 Tal16E0 atal16; +typedef enum E1 Tal16E1 atal16; +typedef enum E2 Tal16E2 atal16; +typedef enum E3 Tal16E3 atal16; +typedef enum E4 Tal16E4 atal16; +typedef enum E5 Tal16E5 atal16; +typedef enum E6 Tal16E6 atal16; +typedef enum E7 Tal16E7 atal16; +typedef enum E8 Tal16E8 atal16; +typedef enum E9 Tal16E9 atal16; +typedef void *Tal16ptr atal16; +typedef char *Tal16cptr atal16; +typedef int *Tal16iptr atal16; +typedef char Talx1char atalx1; +typedef signed char Talx1schar atalx1; +typedef unsigned char Talx1uchar atalx1; +typedef short int Talx1short atalx1; +typedef unsigned short int Talx1ushort atalx1; +typedef int Talx1int atalx1; +typedef unsigned int Talx1uint atalx1; +typedef long int Talx1long atalx1; +typedef unsigned long int Talx1ulong atalx1; +typedef long long int Talx1llong atalx1; +typedef unsigned long long int Talx1ullong atalx1; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talx1cchar atalx1; +typedef _Complex signed char Talx1cschar atalx1; +typedef _Complex unsigned char Talx1cuchar atalx1; +typedef _Complex short int Talx1cshort atalx1; +typedef _Complex unsigned short int Talx1cushort atalx1; +typedef _Complex int Talx1cint atalx1; +typedef _Complex unsigned int Talx1cuint atalx1; +typedef _Complex long int Talx1clong atalx1; +typedef _Complex unsigned long int Talx1culong atalx1; +typedef _Complex long long int Talx1cllong atalx1; +typedef _Complex unsigned long long int Talx1cullong atalx1; +#endif +typedef float Talx1float atalx1; +typedef double Talx1double atalx1; +typedef long double Talx1ldouble atalx1; +typedef _Complex float Talx1cfloat atalx1; +typedef _Complex double Talx1cdouble atalx1; +typedef _Complex long double Talx1cldouble atalx1; +typedef bool Talx1bool atalx1; +typedef enum E0 Talx1E0 atalx1; +typedef enum E1 Talx1E1 atalx1; +typedef enum E2 Talx1E2 atalx1; +typedef enum E3 Talx1E3 atalx1; +typedef enum E4 Talx1E4 atalx1; +typedef enum E5 Talx1E5 atalx1; +typedef enum E6 Talx1E6 atalx1; +typedef enum E7 Talx1E7 atalx1; +typedef enum E8 Talx1E8 atalx1; +typedef enum E9 Talx1E9 atalx1; +typedef void *Talx1ptr atalx1; +typedef char *Talx1cptr atalx1; +typedef int *Talx1iptr atalx1; +typedef short int Talx2short atalx2; +typedef unsigned short int Talx2ushort atalx2; +typedef int Talx2int atalx2; +typedef unsigned int Talx2uint atalx2; +typedef long int Talx2long atalx2; +typedef unsigned long int Talx2ulong atalx2; +typedef long long int Talx2llong atalx2; +typedef unsigned long long int Talx2ullong atalx2; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talx2cchar atalx2; +typedef _Complex signed char Talx2cschar atalx2; +typedef _Complex unsigned char Talx2cuchar atalx2; +typedef _Complex short int Talx2cshort atalx2; +typedef _Complex unsigned short int Talx2cushort atalx2; +typedef _Complex int Talx2cint atalx2; +typedef _Complex unsigned int Talx2cuint atalx2; +typedef _Complex long int Talx2clong atalx2; +typedef _Complex unsigned long int Talx2culong atalx2; +typedef _Complex long long int Talx2cllong atalx2; +typedef _Complex unsigned long long int Talx2cullong atalx2; +#endif +typedef float Talx2float atalx2; +typedef double Talx2double atalx2; +typedef long double Talx2ldouble atalx2; +typedef _Complex float Talx2cfloat atalx2; +typedef _Complex double Talx2cdouble atalx2; +typedef _Complex long double Talx2cldouble atalx2; +typedef enum E0 Talx2E0 atalx2; +typedef enum E1 Talx2E1 atalx2; +typedef enum E2 Talx2E2 atalx2; +typedef enum E3 Talx2E3 atalx2; +typedef enum E4 Talx2E4 atalx2; +typedef enum E5 Talx2E5 atalx2; +typedef enum E6 Talx2E6 atalx2; +typedef enum E7 Talx2E7 atalx2; +typedef enum E8 Talx2E8 atalx2; +typedef enum E9 Talx2E9 atalx2; +typedef void *Talx2ptr atalx2; +typedef char *Talx2cptr atalx2; +typedef int *Talx2iptr atalx2; +typedef int Talx4int atalx4; +typedef unsigned int Talx4uint atalx4; +typedef long int Talx4long atalx4; +typedef unsigned long int Talx4ulong atalx4; +typedef long long int Talx4llong atalx4; +typedef unsigned long long int Talx4ullong atalx4; +#ifndef SKIP_COMPLEX_INT +typedef _Complex short int Talx4cshort atalx4; +typedef _Complex unsigned short int Talx4cushort atalx4; +typedef _Complex int Talx4cint atalx4; +typedef _Complex unsigned int Talx4cuint atalx4; +typedef _Complex long int Talx4clong atalx4; +typedef _Complex unsigned long int Talx4culong atalx4; +typedef _Complex long long int Talx4cllong atalx4; +typedef _Complex unsigned long long int Talx4cullong atalx4; +#endif +typedef float Talx4float atalx4; +typedef double Talx4double atalx4; +typedef long double Talx4ldouble atalx4; +typedef _Complex float Talx4cfloat atalx4; +typedef _Complex double Talx4cdouble atalx4; +typedef _Complex long double Talx4cldouble atalx4; +typedef enum E0 Talx4E0 atalx4; +typedef enum E1 Talx4E1 atalx4; +typedef enum E2 Talx4E2 atalx4; +typedef enum E3 Talx4E3 atalx4; +typedef enum E4 Talx4E4 atalx4; +typedef enum E5 Talx4E5 atalx4; +typedef enum E6 Talx4E6 atalx4; +typedef enum E7 Talx4E7 atalx4; +typedef enum E8 Talx4E8 atalx4; +typedef enum E9 Talx4E9 atalx4; +typedef void *Talx4ptr atalx4; +typedef char *Talx4cptr atalx4; +typedef int *Talx4iptr atalx4; +typedef long int Taly8long ataly8; +typedef unsigned long int Taly8ulong ataly8; +typedef long long int Talx8llong atalx8; +typedef unsigned long long int Talx8ullong atalx8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex int Talx8cint atalx8; +typedef _Complex unsigned int Talx8cuint atalx8; +typedef _Complex long int Talx8clong atalx8; +typedef _Complex unsigned long int Talx8culong atalx8; +typedef _Complex long long int Talx8cllong atalx8; +typedef _Complex unsigned long long int Talx8cullong atalx8; +#endif +typedef double Talx8double atalx8; +typedef long double Talx8ldouble atalx8; +typedef _Complex float Talx8cfloat atalx8; +typedef _Complex double Talx8cdouble atalx8; +typedef _Complex long double Talx8cldouble atalx8; +typedef void *Taly8ptr ataly8; +typedef char *Taly8cptr ataly8; +typedef int *Taly8iptr ataly8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex long int Taly16clong ataly16; +typedef _Complex unsigned long int Taly16culong ataly16; +typedef _Complex long long int Talx16cllong atalx16; +typedef _Complex unsigned long long int Talx16cullong atalx16; +#endif +typedef _Complex double Talx16cdouble atalx16; +typedef _Complex long double Talx16cldouble atalx16; +typedef int (*Tfnptr) (void); + +/* Bitfield macros. In C, it is invalid to use numbers larger + than type's bitsize, but we don't know the size when generating + the testcases. */ +#define BN8(n) ((((n) - 1) & 7) + 1) +#define BN16(n) ((((n) - 1) & 15) + 1) +#define BN32(n) ((((n) - 1) & 31) + 1) +#define BN64(n) ((((n) - 1) & 63) + 1) +#define BCN(n) BN8 (n) +#if USHRT_MAX == 255 +# define BSN(n) BN8 (n) +#elif USHRT_MAX == 65535 +# define BSN(n) BN16 (n) +#elif USHRT_MAX == 4294967295U +# define BSN(n) BN32 (n) +#elif USHRT_MAX == 18446744073709551615ULL +# define BSN(n) BN64 (n) +#endif +#if UINT_MAX == 255 +# define BIN(n) BN8 (n) +#elif UINT_MAX == 65535 +# define BIN(n) BN16 (n) +#elif UINT_MAX == 4294967295U +# define BIN(n) BN32 (n) +#elif UINT_MAX == 18446744073709551615ULL +# define BIN(n) BN64 (n) +#endif +#if ULONG_MAX == 255 +# define BLN(n) BN8 (n) +#elif ULONG_MAX == 65535 +# define BLN(n) BN16 (n) +#elif ULONG_MAX == 4294967295U +# define BLN(n) BN32 (n) +#elif ULONG_MAX == 18446744073709551615ULL +# define BLN(n) BN64 (n) +#endif +#if ULONG_MAX == 255 +# define BLN(n) BN8 (n) +#elif ULONG_MAX == 65535 +# define BLN(n) BN16 (n) +#elif ULONG_MAX == 4294967295U +# define BLN(n) BN32 (n) +#elif ULONG_MAX == 18446744073709551615ULL +# define BLN(n) BN64 (n) +#endif +#if !defined ULLONG_MAX && defined __LONG_LONG_MAX__ +# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) +#endif +#if ULLONG_MAX == 255 +# define BQN(n) BN8 (n) +#elif ULLONG_MAX == 65535 +# define BQN(n) BN16 (n) +#elif ULLONG_MAX == 4294967295U +# define BQN(n) BN32 (n) +#elif ULLONG_MAX == 18446744073709551615ULL +# define BQN(n) BN64 (n) +#endif + +#define T(n, fields, ops) TX(n, struct, , fields, ({ ops });) +#define U(n, fields, ops) TX(n, union, , fields, ({ ops });) +#ifdef SKIP_COMPLEX_INT +#define TXCI(n, type, attrs, fields, ops) +#define TCI(n, fields, ops) +#define UCI(n, fields, ops) +#else +#define TXCI(n, type, attrs, fields, ops) TX(n, type, attrs, fields, ({ ops });) +#define TCI(n, fields, ops) TX(n, struct, , fields, ({ ops });) +#define UCI(n, fields, ops) TX(n, union, , fields, ({ ops });) +#endif
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-1.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/vector-defs.h =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/vector-defs.h (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/vector-defs.h (revision 309) @@ -0,0 +1,72 @@ +/* This includes all of the vector modes that are recognized by + c_common_type_for_mode. */ + +typedef int __attribute__((mode(QI))) qi; +typedef int __attribute__((mode(HI))) hi; +typedef int __attribute__((mode(SI))) si; +typedef int __attribute__((mode(DI))) di; +typedef float __attribute__((mode(SF))) sf; +typedef float __attribute__((mode(DF))) df; + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 5) + +typedef qi __attribute__((vector_size (8))) v8qi; +typedef qi __attribute__((vector_size (16))) v16qi; + +typedef hi __attribute__((vector_size (4))) v2hi; +typedef hi __attribute__((vector_size (8))) v4hi; +typedef hi __attribute__((vector_size (16))) v8hi; + +typedef si __attribute__((vector_size (8))) v2si; +typedef si __attribute__((vector_size (16))) v4si; + +typedef di __attribute__((vector_size (8))) v1di; +typedef di __attribute__((vector_size (16))) v2di; + +typedef sf __attribute__((vector_size (8))) v2sf; +typedef sf __attribute__((vector_size (16))) v4sf; +typedef sf __attribute__((vector_size (64))) v16sf; + +typedef df __attribute__((vector_size (16))) v2df; + +#else + +typedef int __attribute__((mode(V8QI))) v8qi; +typedef int __attribute__((mode(V16QI))) v16qi; + +typedef int __attribute__((mode(V2HI))) v2hi; +typedef int __attribute__((mode(V4HI))) v4hi; +typedef int __attribute__((mode(V8HI))) v8hi; + +typedef int __attribute__((mode(V2SI))) v2si; +typedef int __attribute__((mode(V4SI))) v4si; + +typedef int __attribute__((mode(V1DI))) v1di; +typedef int __attribute__((mode(V2DI))) v2di; + +typedef float __attribute__((mode(V2SF))) v2sf; +typedef float __attribute__((mode(V4SF))) v4sf; +typedef float __attribute__((mode(V16SF))) v16sf; + +typedef float __attribute__((mode(V2DF))) v2df; + +#endif + +typedef union U8QI { v8qi v; qi a[8]; } u8qi; +typedef union U16QI { v16qi v; qi a[16]; } u16qi; + +typedef union U2HI { v2hi v; hi a[2]; } u2hi; +typedef union U4HI { v4hi v; hi a[4]; } u4hi; +typedef union U8HI { v8hi v; hi a[8]; } u8hi; + +typedef union U2SI { v2si v; si a[2]; } u2si; +typedef union U4SI { v4si v; si a[4]; } u4si; + +typedef union U1DI { v1di v; di a[1]; } u1di; +typedef union U2DI { v2di v; di a[2]; } u2di; + +typedef union U2SF { v2sf v; sf a[2]; } u2sf; +typedef union U4SF { v4sf v; sf a[4]; } u4sf; +typedef union U16SF { v16sf v; sf a[16]; } u16sf; + +typedef union U2DF { v2df v; df a[2]; } u2df;
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/vector-defs.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/gnu-encoding.exp =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/gnu-encoding.exp (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/gnu-encoding.exp (revision 309) @@ -0,0 +1,77 @@ +# GCC Objective-C testsuite that uses the `dg.exp' driver. +# Copyright (C) 1997, 2001, 2007, 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Load support procs. +load_lib objc-dg.exp +load_lib target-libpath.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "-fgnu-runtime" +} + +# Initialize `dg'. +dg-init + +# +# gnu-encoding tests +# +set tstobjdir "$tmpdir/objc.dg-struct-layout-encoding-1" +set generator "$tmpdir/objc.dg-struct-layout-encoding-1_generate" + +set generator_src "$srcdir/$subdir/struct-layout-encoding-1_generate.c" +set generator_src "$generator_src $srcdir/$subdir/generate-random.c" +set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c" +set generator_cmd "-o $generator $generator_src" +# Temporarily switch to the environment of the host compiler. +restore_ld_library_path_env_vars +set status [remote_exec build "$HOSTCC $HOSTCFLAGS $generator_cmd"] +set status [lindex $status 0] +set_ld_library_path_env_vars +if { $status == 0 } then { + file delete -force $tstobjdir + file mkdir $tstobjdir + set generator_args "-s $srcdir/$subdir -d $tstobjdir" +# set generator_args "$generator_args -n 15000" + set status [remote_exec host "$generator $generator_args"] + set status [lindex $status 0] + if { $status == 0 } then { + foreach src [lsort [find $tstobjdir *_main.m]] { + # If we're only testing specific files and this isn't one + # of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + dg-runtest $src "" $DEFAULT_CFLAGS + } + } else { + warning "Could not execute objc.dg/gnu-encoding/struct-layout-encoding-1 generator" + } +} else { + warning "Could not compile objc.dg/gnu-encoding/struct-layout-encoding-1 generator" +} + + + + + + +# All done. +dg-finish + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.c =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.c (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.c (revision 309) @@ -0,0 +1,265 @@ +/* Copyright (C) 1995, 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + * Rewritten to use reentrant functions by Ulrich Drepper, 1995. + */ + +/* + Copyright (C) 1983 Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE.*/ + +#include +#include +#include "generate-random.h" + + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initialized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least this many + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + + +/* Initially, everything is set up as if from: + initstate(1, randtbl, 128); + Note that this initialization takes advantage of the fact that srandom + advances the front and rear pointers 10*rand_deg times, and hence the + rear pointer which starts at 0 will also end up at zero; thus the zeroth + element of the state information, which contains info about the current + position of the rear pointer is just + (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ + +static int randtbl[DEG_3 + 1] = + { + TYPE_3, + + -1726662223, 379960547, 1735697613, 1040273694, 1313901226, + 1627687941, -179304937, -2073333483, 1780058412, -1989503057, + -615974602, 344556628, 939512070, -1249116260, 1507946756, + -812545463, 154635395, 1388815473, -1926676823, 525320961, + -1009028674, 968117788, -123449607, 1284210865, 435012392, + -2017506339, -911064859, -370259173, 1132637927, 1398500161, + -205601318, + }; + + +static struct generate_random_data unsafe_state = + { +/* FPTR and RPTR are two pointers into the state info, a front and a rear + pointer. These two pointers are always rand_sep places aparts, as they + cycle through the state information. (Yes, this does mean we could get + away with just one pointer, but the code for random is more efficient + this way). The pointers are left positioned as they would be from the call: + initstate(1, randtbl, 128); + (The position of the rear pointer, rptr, is really 0 (as explained above + in the initialization of randtbl) because the state table pointer is set + to point to randtbl[1] (as explained below).) */ + + &randtbl[SEP_3 + 1], /* fptr */ + &randtbl[1], /* rptr */ + +/* The following things are the pointer to the state information table, + the type of the current generator, the degree of the current polynomial + being used, and the separation between the two pointers. + Note that for efficiency of random, we remember the first location of + the state information, not the zeroth. Hence it is valid to access + state[-1], which is used to store the type of the R.N.G. + Also, we remember the last location, since this is more efficient than + indexing every time to find the address of the last element to see if + the front and rear pointers have wrapped. */ + + &randtbl[1], /* state */ + + TYPE_3, /* rand_type */ + DEG_3, /* rand_deg */ + SEP_3, /* rand_sep */ + + &randtbl[sizeof (randtbl) / sizeof (randtbl[0])] /* end_ptr */ +}; + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +void +generate_srandom (unsigned int x) +{ + (void) generate_srandom_r (x, &unsafe_state); +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +char * +generate_initstate (unsigned int seed, char *arg_state, size_t n) +{ + int *ostate; + + ostate = &unsafe_state.state[-1]; + generate_initstate_r (seed, arg_state, n, &unsafe_state); + return (char *) ostate; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ +char * +generate_setstate (char *arg_state) +{ + int *ostate; + + ostate = &unsafe_state.state[-1]; + if (generate_setstate_r (arg_state, &unsafe_state) < 0) + ostate = NULL; + return (char *) ostate; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all the other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +long int +generate_random (void) +{ + int retval; + (void) generate_random_r (&unsafe_state, &retval); + return retval; +}
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random_r.c =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random_r.c (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random_r.c (revision 309) @@ -0,0 +1,385 @@ +/* + Copyright (C) 1995, 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +/* + Copyright (C) 1983 Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE.*/ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + * Rewritten to be reentrant by Ulrich Drepper, 1995 + */ + +#include +#include +#include "generate-random.h" + + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initialized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least this many + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + +struct random_poly_info +{ + int seps[MAX_TYPES]; + int degrees[MAX_TYPES]; +}; + +static const struct random_poly_info random_poly_info = +{ + { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }, + { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 } +}; + + + + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +int +generate_srandom_r (unsigned int seed, struct generate_random_data *buf) +{ + int type; + int *state; + long int i; + long int word; + int *dst; + int kc; + + if (buf == NULL) + goto fail; + type = buf->rand_type; + if ((unsigned int) type >= MAX_TYPES) + goto fail; + + state = buf->state; + /* We must make sure the seed is not 0. Take arbitrarily 1 in this case. */ + if (seed == 0) + seed = 1; + state[0] = seed; + if (type == TYPE_0) + goto done; + + dst = state; + word = seed; + kc = buf->rand_deg; + for (i = 1; i < kc; ++i) + { + /* This does: + state[i] = (16807 * state[i - 1]) % 2147483647; + but avoids overflowing 31 bits. */ + long int hi = word / 127773; + long int lo = word % 127773; + word = 16807 * lo - 2836 * hi; + if (word < 0) + word += 2147483647; + *++dst = word; + } + + buf->fptr = &state[buf->rand_sep]; + buf->rptr = &state[0]; + kc *= 10; + while (--kc >= 0) + { + int discard; + (void) generate_random_r (buf, &discard); + } + + done: + return 0; + + fail: + return -1; +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +int +generate_initstate_r (unsigned int seed, char *arg_state, size_t n, + struct generate_random_data *buf) +{ + int type; + int degree; + int separation; + int *state; + + if (buf == NULL) + goto fail; + + if (n >= BREAK_3) + type = n < BREAK_4 ? TYPE_3 : TYPE_4; + else if (n < BREAK_1) + { + if (n < BREAK_0) + { + goto fail; + } + type = TYPE_0; + } + else + type = n < BREAK_2 ? TYPE_1 : TYPE_2; + + degree = random_poly_info.degrees[type]; + separation = random_poly_info.seps[type]; + + buf->rand_type = type; + buf->rand_sep = separation; + buf->rand_deg = degree; + state = &((int *) arg_state)[1]; /* First location. */ + /* Must set END_PTR before srandom. */ + buf->end_ptr = &state[degree]; + + buf->state = state; + + generate_srandom_r (seed, buf); + + state[-1] = TYPE_0; + if (type != TYPE_0) + state[-1] = (buf->rptr - state) * MAX_TYPES + type; + + return 0; + + fail: + return -1; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ +int +generate_setstate_r (char *arg_state, struct generate_random_data *buf) +{ + int *new_state = 1 + (int *) arg_state; + int type; + int old_type; + int *old_state; + int degree; + int separation; + + if (arg_state == NULL || buf == NULL) + goto fail; + + old_type = buf->rand_type; + old_state = buf->state; + if (old_type == TYPE_0) + old_state[-1] = TYPE_0; + else + old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type; + + type = new_state[-1] % MAX_TYPES; + if (type < TYPE_0 || type > TYPE_4) + goto fail; + + buf->rand_deg = degree = random_poly_info.degrees[type]; + buf->rand_sep = separation = random_poly_info.seps[type]; + buf->rand_type = type; + + if (type != TYPE_0) + { + int rear = new_state[-1] / MAX_TYPES; + buf->rptr = &new_state[rear]; + buf->fptr = &new_state[(rear + separation) % degree]; + } + buf->state = new_state; + /* Set end_ptr too. */ + buf->end_ptr = &new_state[degree]; + + return 0; + + fail: + return -1; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all the other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +int +generate_random_r (struct generate_random_data *buf, int *result) +{ + int *state; + + if (buf == NULL || result == NULL) + goto fail; + + state = buf->state; + + if (buf->rand_type == TYPE_0) + { + int val = state[0]; + val = ((state[0] * 1103515245) + 12345) & 0x7fffffff; + state[0] = val; + *result = val; + } + else + { + int *fptr = buf->fptr; + int *rptr = buf->rptr; + int *end_ptr = buf->end_ptr; + int val; + + val = *fptr += *rptr; + /* Chucking least random bit. */ + *result = (val >> 1) & 0x7fffffff; + ++fptr; + if (fptr >= end_ptr) + { + fptr = state; + ++rptr; + } + else + { + ++rptr; + if (rptr >= end_ptr) + rptr = state; + } + buf->fptr = fptr; + buf->rptr = rptr; + } + return 0; + + fail: + return -1; +}
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random_r.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c (revision 309) @@ -0,0 +1,1374 @@ +/* Structure layout test generator. + Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. + Contributed by Jakub Jelinek . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +/* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */ + +/* N.B. -- This program cannot use libiberty as that will not work + when testing an installed compiler. */ +#include +#include +#include +#include +#include +/* We use our own pseudo-random number generator, so that it gives the same + values on all hosts. */ +#include "generate-random.h" + +#if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL +# error Need 64-bit long long +#endif + +typedef unsigned int hashval_t; + +enum TYPE +{ + TYPE_INT, + TYPE_UINT, + TYPE_CINT, + TYPE_CUINT, + TYPE_FLOAT, + TYPE_CFLOAT, + TYPE_SENUM, + TYPE_UENUM, + TYPE_PTR, + TYPE_FNPTR, + TYPE_OTHER +}; + +struct types +{ + const char *name; + enum TYPE type; + unsigned long long int maxval; + char bitfld; +}; + +struct types base_types[] = { +/* As we don't know whether char will be signed or not, just limit ourselves + to unsigned values less than maximum signed char value. */ +{ "char", TYPE_UINT, 127, 'C' }, +{ "signed char", TYPE_INT, 127, 'C' }, +{ "unsigned char", TYPE_UINT, 255, 'C' }, +{ "short int", TYPE_INT, 32767, 'S' }, +{ "unsigned short int", TYPE_UINT, 65535, 'S' }, +{ "int", TYPE_INT, 2147483647, 'I' }, +{ "unsigned int", TYPE_UINT, 4294967295U, 'I' }, +{ "long int", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "unsigned long int", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "long long int", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "unsigned long long int", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "bool", TYPE_UINT, 1, 'B' }, +{ "void *", TYPE_PTR, 0, 0 }, +{ "char *", TYPE_PTR, 0, 0 }, +{ "int *", TYPE_PTR, 0, 0 }, +{ "float", TYPE_FLOAT, 0, 0 }, +{ "double", TYPE_FLOAT, 0, 0 }, +/*{ "long double", TYPE_FLOAT, 0, 0 },*/ +/* Disabled as double and long double + are encoded thee same, currently */ +#define NTYPES1 16 +#if 0 +/* enums are disabled for now as it seems like their encoding is broken, we should + just encode them using their underlaying type but we don't. */ +{ "enum E0", TYPE_UENUM, 0, ' ' }, +{ "enum E1", TYPE_UENUM, 1, ' ' }, +{ "enum E2", TYPE_SENUM, 3, ' ' }, +{ "enum E3", TYPE_SENUM, 127, ' ' }, +{ "enum E4", TYPE_UENUM, 255, ' ' }, +{ "enum E5", TYPE_SENUM, 32767, ' ' }, +{ "enum E6", TYPE_UENUM, 65535, ' ' }, +{ "enum E7", TYPE_SENUM, 2147483647, ' ' }, +{ "enum E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "enum E9", TYPE_SENUM, 1099511627775LL, ' ' }, +#endif +#define NTYPES2 (sizeof (base_types) / sizeof (base_types[0])) +}; +struct types complex_types[] = { +{ "_Complex char", TYPE_CUINT, 127, 0 }, +{ "_Complex signed char", TYPE_CINT, 127, 0 }, +{ "_Complex unsigned char", TYPE_CUINT, 255, 0 }, +{ "_Complex short int", TYPE_CINT, 32767, 0 }, +{ "_Complex unsigned short int", TYPE_CUINT, 65535, 0 }, +{ "_Complex int", TYPE_CINT, 2147483647, 0 }, +{ "_Complex unsigned int", TYPE_CUINT, 4294967295U, 0 }, +{ "_Complex long int", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "_Complex unsigned long int", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "_Complex long long int", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "_Complex unsigned long long int", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "_Complex float", TYPE_CFLOAT, 0, 0 }, +{ "_Complex double", TYPE_CFLOAT, 0, 0 }, +/*{ "_Complex long double", TYPE_CFLOAT, 0, 0 }, */ +/* Disable until long doubles are encoded correctly. */ +#define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0])) +}; +struct types vector_types[] = { +/* vector-defs.h typedefs */ +{ "v8qi", TYPE_OTHER, 0, 0 }, +{ "v16qi", TYPE_OTHER, 0, 0 }, +{ "v2hi", TYPE_OTHER, 0, 0 }, +{ "v4hi", TYPE_OTHER, 0, 0 }, +{ "v8hi", TYPE_OTHER, 0, 0 }, +{ "v2si", TYPE_OTHER, 0, 0 }, +{ "v4si", TYPE_OTHER, 0, 0 }, +{ "v1di", TYPE_OTHER, 0, 0 }, +{ "v2di", TYPE_OTHER, 0, 0 }, +{ "v2sf", TYPE_OTHER, 0, 0 }, +{ "v4sf", TYPE_OTHER, 0, 0 }, +{ "v16sf", TYPE_OTHER, 0, 0 }, +{ "v2df", TYPE_OTHER, 0, 0 }, +{ "u8qi", TYPE_OTHER, 0, 0 }, +{ "u16qi", TYPE_OTHER, 0, 0 }, +{ "u2hi", TYPE_OTHER, 0, 0 }, +{ "u4hi", TYPE_OTHER, 0, 0 }, +{ "u8hi", TYPE_OTHER, 0, 0 }, +{ "u2si", TYPE_OTHER, 0, 0 }, +{ "u4si", TYPE_OTHER, 0, 0 }, +{ "u1di", TYPE_OTHER, 0, 0 }, +{ "u2di", TYPE_OTHER, 0, 0 }, +{ "u2sf", TYPE_OTHER, 0, 0 }, +{ "u4sf", TYPE_OTHER, 0, 0 }, +{ "u16sf", TYPE_OTHER, 0, 0 }, +{ "u2df", TYPE_OTHER, 0, 0 }, +{ "__m64", TYPE_OTHER, 0, 0 }, +{ "__m128", TYPE_OTHER, 0, 0 } +#define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0])) +}; + +struct types bitfld_types[NTYPES2]; +int n_bitfld_types; + +enum ETYPE +{ + ETYPE_TYPE, + ETYPE_ARRAY, + ETYPE_BITFLD, + ETYPE_STRUCT, + ETYPE_UNION, + ETYPE_STRUCT_ARRAY, + ETYPE_UNION_ARRAY +}; + +struct entry +{ +#ifdef __GNUC__ + enum ETYPE etype : 8; +#else + unsigned char etype; +#endif + unsigned short len; + unsigned char arr_len; + struct types *type; + const char *attrib; + /* Used to chain together entries in the hash table. */ + struct entry *next; +}; + +/* A prime number giving the number of slots in the hash table. */ +#define HASH_SIZE 32749 +static struct entry *hash_table[HASH_SIZE]; + +static int idx, limidx, output_one; +static const char *destdir; +static const char *srcdir; +FILE *outfile; + +void +switchfiles (int fields) +{ + static int filecnt; + static char *destbuf, *destptr; + ++filecnt; + if (outfile) + fclose (outfile); + if (output_one) + { + outfile = stdout; + return; + } + if (destbuf == NULL) + { + size_t len = strlen (destdir); + destbuf = malloc (len + 20); + if (!destbuf) + abort (); + memcpy (destbuf, destdir, len); + if (!len || destbuf[len - 1] != '/') + destbuf[len++] = '/'; + destptr = destbuf + len; + } + sprintf (destptr, "t%03d_main.m", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + { + fail: + fputs ("failed to create test files\n", stderr); + exit (1); + } + /* FIXME: these tests should not be xfailed on PowerPC darwin or aix + but they are because libobjc uses GCC's headers for trying to find + the struct layout but it gets it wrong. */ + if (filecnt == 2 + || filecnt == 3 + || filecnt == 4 + || filecnt == 6 + || filecnt == 7 + || filecnt == 8 + || filecnt == 11 + || filecnt == 12 + || filecnt == 15 + || filecnt == 22) + { + fprintf (outfile, "\ +/* { dg-do run { xfail powerpc*-*-darwin* powerpc*-*-aix* } } */\n\ +/* { dg-options \"-w -I%s -fgnu-runtime\" } */\n", srcdir); + } + /* FIXME: these should not be xfailed but they are because + of bugs in libobjc and the objc front-end. 25 is because + vectors are not encoded. The rest are because or zero sized + arrays are encoded as pointers. */ + else if (filecnt >= 25) + { + fprintf (outfile, "\ +/* { dg-do run { xfail *-*-* } } */\n\ +/* { dg-options \"-w -I%s -fgnu-runtime\" } */\n", srcdir); + } + else + { + fprintf (outfile, "\ +/* { dg-do run } */\n\ +/* { dg-options \"-w -I%s -fgnu-runtime\" } */\n", srcdir); + } + fprintf(outfile, "#include \n\ +#include \"struct-layout-1.h\"\n\ +\n\ +int fails; \n\ +#define TX(n, type, attrs, fields, ops) \\\n\ +type S##n { fields } attrs; \\\n\ +void test##n (void) \\\n\ +{ \\\n\ + char *encoding = @encode (type S##n); \\\n\ + if (objc_sizeof_type (encoding) != sizeof(type S##n)) \\\n\ + { \\\n\ + fails ++; \\\n\ + printf(#type \" { \" #fields \"} size is %%u, but is calulated as %%u\\n\", \\\n\ + sizeof(type S##n), objc_sizeof_type (encoding)); \\\n\ + } \\\n\ + if (objc_alignof_type (encoding) != __alignof__ (type S##n)) \\\n\ + { \\\n\ + fails ++; \\\n\ + printf(#type \" { \" #fields \"} align is %%u, but is calulated as %%u\\n\", \\\n\ + __alignof__ (type S##n), objc_alignof_type (encoding)); \\\n\ + } \\\n\ +}\n\ +#include \"t%03d_test.h\"\n\ +#undef TX\n\ +\n\ +int main (void)\n\ +{\n\ +#define TX(n, type, attrs, fields, ops) test##n ();\n\ +#include \"t%03d_test.h\"\n\ +#undef TX\n\ + if (fails)\n\ + {\n\ + fflush (stdout);\n\ + abort ();\n\ + }\n\ + exit (0);\n\ +}\n", filecnt, filecnt); + fclose (outfile); + sprintf (destptr, "t%03d_test.h", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + goto fail; + if (fields <= 2) + limidx = idx + 300; + else if (fields <= 4) + limidx = idx + 200; + else if (fields <= 6) + limidx = idx + 100; + else + limidx = idx + 50; +} + +unsigned long long int +getrandll (void) +{ + unsigned long long int ret; + ret = generate_random () & 0xffffff; + ret |= (generate_random () & 0xffffffLL) << 24; + ret |= ((unsigned long long int) generate_random ()) << 48; + return ret; +} + +int +subfield (struct entry *e, char *letter) +{ + int i, type; + char buf[20]; + const char *p; + switch (e[0].etype) + { + case ETYPE_STRUCT: + case ETYPE_UNION: + case ETYPE_STRUCT_ARRAY: + case ETYPE_UNION_ARRAY: + type = e[0].attrib ? 1 + (generate_random () & 3) : 0; + if (e[0].etype == ETYPE_STRUCT || e[0].etype == ETYPE_STRUCT_ARRAY) + p = "struct"; + else + p = "union"; + if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY) + { + if (e[0].arr_len == 255) + snprintf (buf, 20, "%c[]", *letter); + else + snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len); + } + else + { + buf[0] = *letter; + buf[1] = '\0'; + } + ++*letter; + switch (type) + { + case 0: + case 3: + case 4: + fprintf (outfile, "%s{", p); + break; + case 1: + fprintf (outfile, "%s %s{", e[0].attrib, p); + break; + case 2: + fprintf (outfile, "%s %s{", p, e[0].attrib); + break; + } + + for (i = 1; i <= e[0].len; ) + i += subfield (e + i, letter); + + switch (type) + { + case 0: + case 1: + case 2: + fprintf (outfile, "}%s;", buf); + break; + case 3: + fprintf (outfile, "}%s %s;", e[0].attrib, buf); + break; + case 4: + fprintf (outfile, "}%s %s;", buf, e[0].attrib); + break; + } + return 1 + e[0].len; + case ETYPE_TYPE: + case ETYPE_ARRAY: + if (e[0].etype == ETYPE_ARRAY) + { + if (e[0].arr_len == 255) + snprintf (buf, 20, "%c[]", *letter); + else + snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len); + } + else + { + buf[0] = *letter; + buf[1] = '\0'; + } + ++*letter; + if (e[0].attrib) + switch (generate_random () % 3) + { + case 0: + fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name, buf); + break; + case 1: + fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib, buf); + break; + case 2: + fprintf (outfile, "%s %s %s;", e[0].type->name, buf, e[0].attrib); + break; + } + else + fprintf (outfile, "%s %s;", e[0].type->name, buf); + return 1; + case ETYPE_BITFLD: + if (e[0].len == 0) + { + if (e[0].attrib) + switch (generate_random () % 3) + { + case 0: + fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name); + break; + case 1: + fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib); + break; + case 2: + fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib); + break; + } + else + fprintf (outfile, "%s:0;", e[0].type->name); + ++*letter; + return 1; + } + switch (e[0].type->bitfld) + { + case 'C': + case 'S': + case 'I': + case 'L': + case 'Q': + snprintf (buf, 20, "B%cN(%d)", e[0].type->bitfld, e[0].len); + break; + case 'B': + case ' ': + snprintf (buf, 20, "%d", e[0].len); + break; + default: + abort (); + } + if (e[0].attrib) + switch (generate_random () % 3) + { + case 0: + fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name, + *letter, buf); + break; + case 1: + fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib, + *letter, buf); + break; + case 2: + fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter, + buf, e[0].attrib); + break; + } + else + fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf); + ++*letter; + return 1; + default: + abort (); + } +} + +char namebuf[1024]; + +void +output_FNB (char mode, struct entry *e) +{ + unsigned long long int l1, l2, m; + int signs = 0; + const char *p, *q; + + if (e->type->type == TYPE_OTHER) + { + if (mode == 'B') + abort (); + fprintf (outfile, "N(%d,%s)", idx, namebuf); + return; + } + fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf); + l1 = getrandll (); + l2 = getrandll (); + switch (e->type->type) + { + case TYPE_INT: + signs = generate_random () & 3; + m = e->type->maxval; + if (mode == 'B') + m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1; + l1 &= m; + l2 &= m; + fprintf (outfile, "%s%llu%s,%s%llu%s", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + break; + case TYPE_UINT: + m = e->type->maxval; + if (mode == 'B') + m &= (1ULL << e->len) - 1; + l1 &= m; + l2 &= m; + fprintf (outfile, "%lluU%s,%lluU%s", l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + break; + case TYPE_FLOAT: + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "", + ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64); + break; + case TYPE_CINT: + signs = generate_random () & 3; + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, "CINT(%s%llu%s,%s%llu%s),", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + signs = generate_random () & 3; + l1 = getrandll (); + l2 = getrandll (); + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, "CINT(%s%llu%s,%s%llu%s)", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + break; + case TYPE_CUINT: + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, "CINT(%lluU%s,%lluU%s),", + l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + l1 = getrandll (); + l2 = getrandll (); + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, "CINT(%lluU%s,%lluU%s)", + l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + break; + case TYPE_CFLOAT: + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "CDBL(%s%f,%s%f),", + (signs & 1) ? "-" : "", ((double) l1) / 64, + (signs & 2) ? "-" : "", ((double) l2) / 64); + l1 = getrandll (); + l2 = getrandll (); + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "CDBL(%s%f,%s%f)", + (signs & 1) ? "-" : "", ((double) l1) / 64, + (signs & 2) ? "-" : "", ((double) l2) / 64); + break; + case TYPE_UENUM: + if (e->type->maxval == 0) + fputs ("e0_0,e0_0", outfile); + else if (e->type->maxval == 1) + fprintf (outfile, "e1_%lld,e1_%lld", l1 & 1, l2 & 1); + else + { + p = strchr (e->type->name, '\0'); + while (--p >= e->type->name && *p >= '0' && *p <= '9'); + p++; + l1 %= 7; + l2 %= 7; + if (l1 > 3) + l1 += e->type->maxval - 6; + if (l2 > 3) + l2 += e->type->maxval - 6; + fprintf (outfile, "e%s_%lld,e%s_%lld", p, l1, p, l2); + } + break; + case TYPE_SENUM: + p = strchr (e->type->name, '\0'); + while (--p >= e->type->name && *p >= '0' && *p <= '9'); + p++; + l1 %= 7; + l2 %= 7; + fprintf (outfile, "e%s_%s%lld,e%s_%s%lld", + p, l1 < 3 ? "m" : "", + l1 == 3 ? 0LL : e->type->maxval - (l1 & 3), + p, l2 < 3 ? "m" : "", + l2 == 3 ? 0LL : e->type->maxval - (l2 & 3)); + break; + case TYPE_PTR: + l1 %= 256; + l2 %= 256; + fprintf (outfile, "(%s)&intarray[%lld],(%s)&intarray[%lld]", + e->type->name, l1, e->type->name, l2); + break; + case TYPE_FNPTR: + l1 %= 10; + l2 %= 10; + fprintf (outfile, "fn%lld,fn%lld", l1, l2); + break; + default: + abort (); + } + fputs (")", outfile); +} + +int +subvalues (struct entry *e, char *p, char *letter) +{ + int i, j; + char *q; + if (p >= namebuf + sizeof (namebuf) - 32) + abort (); + p[0] = *letter; + p[1] = '\0'; + q = p + 1; + switch (e[0].etype) + { + case ETYPE_STRUCT_ARRAY: + case ETYPE_UNION_ARRAY: + if (e[0].arr_len == 0 || e[0].arr_len == 255) + { + *letter += 1 + e[0].len; + return 1 + e[0].len; + } + i = generate_random () % e[0].arr_len; + snprintf (p, sizeof (namebuf) - (p - namebuf) - 1, + "%c[%d]", *letter, i); + q = strchr (p, '\0'); + /* FALLTHROUGH */ + case ETYPE_STRUCT: + case ETYPE_UNION: + *q++ = '.'; + ++*letter; + for (i = 1; i <= e[0].len; ) + { + i += subvalues (e + i, q, letter); + if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY) + { + *letter += e[0].len - i + 1; + break; + } + } + return 1 + e[0].len; + case ETYPE_TYPE: + ++*letter; + output_FNB ('F', e); + return 1; + case ETYPE_ARRAY: + if (e[0].arr_len == 0 || e[0].arr_len == 255) + { + ++*letter; + return 1; + } + i = generate_random () % e[0].arr_len; + snprintf (p, sizeof (namebuf) - (p - namebuf), + "%c[%d]", *letter, i); + output_FNB ('F', e); + if ((generate_random () & 7) == 0) + { + j = generate_random () % e[0].arr_len; + if (i != j) + { + snprintf (p, sizeof (namebuf) - (p - namebuf), + "%c[%d]", *letter, j); + output_FNB ('F', e); + } + } + ++*letter; + return 1; + case ETYPE_BITFLD: + ++*letter; + if (e[0].len != 0) + output_FNB ('B', e); + return 1; + } +} + +/* DERIVED FROM: +-------------------------------------------------------------------- +lookup2.c, by Bob Jenkins, December 1996, Public Domain. +hash(), hash2(), hash3, and mix() are externally useful functions. +Routines to test the hash are included if SELF_TEST is defined. +You can use this free for any purpose. It has no warranty. +-------------------------------------------------------------------- +*/ + +/* +-------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. +For every delta with one or two bit set, and the deltas of all three + high bits or all three low bits, whether the original value of a,b,c + is almost all zero or is uniformly distributed, +* If mix() is run forward or backward, at least 32 bits in a,b,c + have at least 1/4 probability of changing. +* If mix() is run forward, every bit of c will change between 1/3 and + 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) +mix() was built out of 36 single-cycle latency instructions in a + structure that could supported 2x parallelism, like so: + a -= b; + a -= c; x = (c>>13); + b -= c; a ^= x; + b -= a; x = (a<<8); + c -= a; b ^= x; + c -= b; x = (b>>13); + ... + Unfortunately, superscalar Pentiums and Sparcs can't take advantage + of that parallelism. They've also turned some of those single-cycle + latency instructions into multi-cycle latency instructions. Still, + this is the fastest good hash I could find. There were about 2^^68 + to choose from. I only looked at a billion or so. +-------------------------------------------------------------------- +*/ +/* same, but slower, works on systems that might have 8 byte hashval_t's */ +#define mix(a,b,c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<< 8); \ + c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \ + a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \ + b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \ + a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \ + b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \ +} + +/* +-------------------------------------------------------------------- +hash() -- hash a variable-length key into a 32-bit value + k : the key (the unaligned variable-length array of bytes) + len : the length of the key, counting by bytes + level : can be any 4-byte value +Returns a 32-bit value. Every bit of the key affects every bit of +the return value. Every 1-bit and 2-bit delta achieves avalanche. +About 36+6len instructions. + +The best hash table sizes are powers of 2. There is no need to do +mod a prime (mod is sooo slow!). If you need less than 32 bits, +use a bitmask. For example, if you need only 10 bits, do + h = (h & hashmask(10)); +In which case, the hash table should have hashsize(10) elements. + +If you are hashing n strings (ub1 **)k, do it like this: + for (i=0, h=0; i= 12) + { + a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24)); + b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24)); + c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24)); + mix(a,b,c); + k += 12; len -= 12; + } + + /*------------------------------------- handle the last 11 bytes */ + c += length; + switch(len) /* all the case statements fall through */ + { + case 11: c+=((hashval_t)k[10]<<24); + case 10: c+=((hashval_t)k[9]<<16); + case 9 : c+=((hashval_t)k[8]<<8); + /* the first byte of c is reserved for the length */ + case 8 : b+=((hashval_t)k[7]<<24); + case 7 : b+=((hashval_t)k[6]<<16); + case 6 : b+=((hashval_t)k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=((hashval_t)k[3]<<24); + case 3 : a+=((hashval_t)k[2]<<16); + case 2 : a+=((hashval_t)k[1]<<8); + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + mix(a,b,c); + /*-------------------------------------------- report the result */ + return c; +} + +hashval_t +e_hash (const void *a) +{ + const struct entry *e = a; + hashval_t ret = 0; + int i; + + if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION) + abort (); + for (i = 0; i <= e[0].len; ++i) + { + int attriblen; + ret = iterative_hash (&e[i], offsetof (struct entry, attrib), ret); + attriblen = e[i].attrib ? strlen (e[i].attrib) : -1; + ret = iterative_hash (&attriblen, sizeof (int), ret); + if (e[i].attrib) + ret = iterative_hash (e[i].attrib, attriblen, ret); + } + return ret; +} + +int +e_eq (const void *a, const void *b) +{ + const struct entry *ea = a, *eb = b; + int i; + if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION) + abort (); + if (ea[0].len != eb[0].len) + return 0; + for (i = 0; i <= ea[0].len; ++i) + { + if (ea[i].etype != eb[i].etype + || ea[i].len != eb[i].len + || ea[i].arr_len != eb[i].arr_len + || ea[i].type != eb[i].type) + return 0; + if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL)) + return 0; + if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0) + return 0; + } + return 1; +} + +static int +e_exists (const struct entry *e) +{ + struct entry *h; + hashval_t hval; + + hval = e_hash (e); + for (h = hash_table[hval % HASH_SIZE]; h; h = h->next) + if (e_eq (e, h)) + return 1; + return 0; +} + +static void +e_insert (struct entry *e) +{ + hashval_t hval; + + hval = e_hash (e); + e->next = hash_table[hval % HASH_SIZE]; + hash_table[hval % HASH_SIZE] = e; +} + +void +output (struct entry *e) +{ + int i; + char c; + struct entry *n; + const char *skip_cint = ""; + + if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION) + abort (); + + if (e_exists (e)) + return; + + n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry)); + memcpy (n, e, (e[0].len + 1) * sizeof (struct entry)); + e_insert (n); + + if (idx == limidx) + switchfiles (e[0].len); + + for (i = 1; i <= e[0].len; ++i) + if ((e[i].etype == ETYPE_TYPE || e[i].etype == ETYPE_ARRAY) + && (e[i].type->type == TYPE_CINT || e[i].type->type == TYPE_CUINT)) + break; + if (i <= e[0].len) + skip_cint = "CI"; + if (e[0].attrib) + fprintf (outfile, (generate_random () & 1) + ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint, + idx, e[0].etype == ETYPE_STRUCT ? "struct" : "union", + e[0].attrib); + else if (e[0].etype == ETYPE_STRUCT) + fprintf (outfile, "T%s(%d,", skip_cint, idx); + else + fprintf (outfile, "U%s(%d,", skip_cint, idx); + c = 'a'; + for (i = 1; i <= e[0].len; ) + i += subfield (e + i, &c); + fputs (",", outfile); + c = 'a'; + for (i = 1; i <= e[0].len; ) + { + i += subvalues (e + i, namebuf, &c); + if (e[0].etype == ETYPE_UNION) + break; + } + fputs (")\n", outfile); + if (output_one && idx == limidx) + exit (0); + ++idx; +} + +enum FEATURE +{ + FEATURE_VECTOR = 1, + FEATURE_COMPLEX = 2, + FEATURE_ZEROARRAY = 8, + FEATURE_ZEROBITFLD = 16, + ALL_FEATURES = FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY + | FEATURE_ZEROBITFLD +}; + +void +singles (enum FEATURE features) +{ + struct entry e[2]; + int i; + memset (e, 0, sizeof (e)); + e[0].etype = ETYPE_STRUCT; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + e[0].len = 1; + e[0].attrib = NULL; + for (i = 0; i < NTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &base_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } + if (features & FEATURE_COMPLEX) + for (i = 0; i < NCTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &complex_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } + if (features & FEATURE_VECTOR) + for (i = 0; i < NVTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &vector_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } +} + +void +choose_type (enum FEATURE features, struct entry *e, int r, int in_array) +{ + int i; + + i = NTYPES2 - NTYPES1; + if (features & FEATURE_COMPLEX) + i += NCTYPES2; + if (features & FEATURE_VECTOR) + i += NVTYPES2; + r >>= 2; + r %= i; + if (r < NTYPES2 - NTYPES1) + e->type = &base_types[r + NTYPES1]; + r -= NTYPES2 - NTYPES1; + if (e->type == NULL && (features & FEATURE_COMPLEX)) + { + if (r < NCTYPES2) + e->type = &complex_types[r]; + r -= NCTYPES2; + } + if (e->type == NULL && (features & FEATURE_VECTOR)) + { + if (r < NVTYPES2) + e->type = &vector_types[r]; + r -= NVTYPES2; + } + if (e->type == NULL) + abort (); +} + +/* This is from gcc.c-torture/execute/builtin-bitops-1.c. */ +static int +my_ffsll (unsigned long long x) +{ + int i; + if (x == 0) + return 0; + /* We've tested LLONG_MAX for 64 bits so this should be safe. */ + for (i = 0; i < 64; i++) + if (x & (1ULL << i)) + break; + return i + 1; +} + +void +generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, + int len) +{ + int r, i, j, ret = 1, n, incr, sametype; + + for (n = 0; n < len; n += incr) + { + r = generate_random (); + /* 50% ETYPE_TYPE base_types NTYPES1 + 12.5% ETYPE_TYPE other + 12.5% ETYPE_ARRAY + 12.5% ETYPE_BITFLD + 12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */ + i = (r & 7); + r >>= 3; + incr = 1; + switch (i) + { + case 6: /* BITfields disabled for now as _Bool bitfields are broken. */ + case 0: + case 1: + case 2: + case 3: + e[n].etype = ETYPE_TYPE; + e[n].type = &base_types[r % NTYPES1]; + break; + case 4: + e[n].etype = ETYPE_TYPE; + choose_type (features, &e[n], r, 0); + break; + case 5: + e[n].etype = ETYPE_ARRAY; + i = r & 1; + r >>= 1; + if (i) + e[n].type = &base_types[r % NTYPES1]; + else + choose_type (features, &e[n], r, 1); + r = generate_random (); + if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0) + { + e[n].arr_len = 0; + if (n == len - 1 && (r & 4) + && (parent->etype == ETYPE_STRUCT + || parent->etype == ETYPE_STRUCT_ARRAY)) + { + int k; + for (k = 0; k < n; ++k) + if (e[k].etype != ETYPE_BITFLD || e[k].len) + { + e[n].arr_len = 255; + break; + } + } + } + else if ((r & 3) != 3) + e[n].arr_len = (r >> 2) & 7; + else + e[n].arr_len = (r >> 2) & 31; + break; +#if 0 + case 6: + sametype = 1; + switch (r & 7) + { + case 0: + case 1: + case 2: + break; + case 3: + case 4: + case 5: + incr = 1 + (r >> 3) % (len - n); + break; + case 6: + case 7: + sametype = 0; + incr = 1 + (r >> 3) % (len - n); + break; + } + for (j = n; j < n + incr; ++j) + { + int mi, ma; + + e[j].etype = ETYPE_BITFLD; + if (j == n || !sametype) + { + r = generate_random (); + r >>= 2; + e[j].type + = &bitfld_types[r % n_bitfld_types]; + } + else + e[j].type = e[n].type; + r = generate_random (); + mi = 0; + ma = 0; + switch (e[j].type->bitfld) + { + case 'C': ma = 8; break; + case 'S': ma = 16; break; + case 'I': ma = 32; break; + case 'L': + case 'Q': ma = 64; break; + case 'B': ma = 1; break; + case ' ': + if (e[j].type->type == TYPE_UENUM) + mi = my_ffsll (e[j].type->maxval + 1) - 1; + else if (e[j].type->type == TYPE_SENUM) + mi = my_ffsll (e[j].type->maxval + 1); + else + abort (); + if (!mi) + mi = 1; + if (mi <= 32) + ma = 32; + else + ma = 64; + break; + default: + abort (); + } + e[j].len = ma + 1; + if (sametype && (r & 3) == 0 && ma > 1) + { + int sum = 0, k; + for (k = n; k < j; ++k) + sum += e[k].len; + sum %= ma; + e[j].len = sum ? ma - sum : ma; + } + r >>= 2; + if (! (features & FEATURE_ZEROBITFLD) && mi == 0) + mi = 1; + if (e[j].len < mi || e[j].len > ma) + e[j].len = mi + (r % (ma + 1 - mi)); + r >>= 6; + if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0 + && mi == 0) + e[j].len = 0; + } + break; +#endif + case 7: + switch (r & 7) + { + case 0: + case 1: + case 2: + e[n].etype = ETYPE_STRUCT; + break; + case 3: + case 4: + e[n].etype = ETYPE_UNION; + break; + case 5: + case 6: + e[n].etype = ETYPE_STRUCT_ARRAY; + break; + case 7: + e[n].etype = ETYPE_UNION_ARRAY; + break; + } + r >>= 3; + e[n].len = r % (len - n); + incr = 1 + e[n].len; + generate_fields (features, &e[n + 1], &e[n], e[n].len); + if (e[n].etype == ETYPE_STRUCT_ARRAY + || e[n].etype == ETYPE_UNION_ARRAY) + { + r = generate_random (); + if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0) + { + e[n].arr_len = 0; + if (n + incr == len && (r & 4) + && (parent->etype == ETYPE_STRUCT + || parent->etype == ETYPE_STRUCT_ARRAY)) + { + int k; + for (k = 0; k < n; ++k) + if (e[k].etype != ETYPE_BITFLD || e[k].len) + { + e[n].arr_len = 255; + break; + } + } + } + else if ((r & 3) != 3) + e[n].arr_len = (r >> 2) & 7; + else + e[n].arr_len = (r >> 2) & 31; + } + break; + } + } +} + +void +generate_random_tests (enum FEATURE features, int len) +{ + struct entry e[len + 1]; + int i, r; + if (len > 'z' - 'a' + 1) + abort (); + memset (e, 0, sizeof (e)); + r = generate_random (); + if ((r & 7) == 0) + e[0].etype = ETYPE_UNION; + else + e[0].etype = ETYPE_STRUCT; + r >>= 3; + e[0].len = len; + generate_fields (features, &e[1], &e[0], len); + output (e); +} + +struct { const char *name; enum FEATURE f; } +features[] = { +{ "normal", 0 }, +{ "complex", FEATURE_COMPLEX }, +{ "vector", FEATURE_VECTOR }, +{ "[0] :0", FEATURE_ZEROARRAY | FEATURE_ZEROBITFLD }, +{ "complex vector [0]", + FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY } +}; + +int +main (int argc, char **argv) +{ + int i, j, count, c, n = 3000; + char *optarg; + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 1; + + i = 1; + while (i < argc) + { + c = '\0'; + if (argv[i][0] == '-' && argv[i][2] == '\0') + c = argv[i][1]; + optarg = argv[i + 1]; + if (!optarg) + goto usage; + switch (c) + { + case 'n': + n = atoi (optarg); + break; + case 'd': + destdir = optarg; + break; + case 's': + srcdir = optarg; + break; + case 'i': + output_one = 1; + limidx = atoi (optarg); + break; + default: + fprintf (stderr, "unrecognized option %s\n", argv[i]); + goto usage; + } + i += 2; + } + + if (output_one) + { + outfile = fopen ("/dev/null", "w"); + if (outfile == NULL) + { + fputs ("could not open /dev/null", stderr); + return 1; + } + n = limidx + 1; + } + + if (destdir == NULL && !output_one) + { + usage: + fprintf (stderr, "Usage:\n\ +%s [-s srcdir -d destdir] [-n count] [-i idx]\n\ +Either -s srcdir -d destdir or -i idx must be used\n", argv[0]); + return 1; + } + + if (srcdir == NULL && !output_one) + goto usage; + + for (i = 0; i < NTYPES2; ++i) + if (base_types[i].bitfld) + bitfld_types[n_bitfld_types++] = base_types[i]; + for (i = 0; i < sizeof (features) / sizeof (features[0]); ++i) + { + int startidx = idx; + if (! output_one) + limidx = idx; + if (!i) + count = 200; + else + count = 20; + for (j = 1; j <= 9; ++j) + while (idx < startidx + j * count) + generate_random_tests (features[i].f, j); + while (idx < startidx + count * 10) + generate_random_tests (features[i].f, 10 + (generate_random () % 16)); + } + for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i) + { + int startidx; + startidx = idx; + if (! output_one) + limidx = idx; + singles (features[i].f); + if (!i) + { + count = 1000; + while (idx < startidx + 1000) + generate_random_tests (features[i].f, 1); + } + else + { + startidx = idx; + count = 100; + while (idx < startidx + 100) + generate_random_tests (features[i].f, 1); + } + startidx = idx; + for (j = 2; j <= 9; ++j) + while (idx < startidx + (j - 1) * count) + generate_random_tests (features[i].f, j); + while (idx < startidx + count * 9) + generate_random_tests (features[i].f, 10 + (generate_random () % 16)); + } + if (! output_one) + limidx = idx; + while (idx < n) + generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25)); + fclose (outfile); + return 0; +}
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/struct-layout-encoding-1_generate.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.h =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.h (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.h (revision 309) @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +struct generate_random_data + { + int *fptr, *rptr, *state; + int rand_type, rand_deg, rand_sep; + int *end_ptr; + }; + +extern void generate_srandom (unsigned int); +extern char *generate_initstate (unsigned int, char *, size_t); +extern char *generate_setstate (char *); +extern long int generate_random (void); +extern int generate_random_r (struct generate_random_data *, int *); +extern int generate_srandom_r (unsigned int, struct generate_random_data *); +extern int generate_initstate_r (unsigned int, char *, size_t, + struct generate_random_data *); +extern int generate_setstate_r (char *, struct generate_random_data *);
trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-encoding/generate-random.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-3.m (revision 309) @@ -0,0 +1,49 @@ +/* Check if the @defs() construct preserves the correct + layout of bitfields. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "-Wpadded" } */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); +extern int strcmp(const char *str1, const char *str2); +#define CHECK_IF(expr) if(!(expr)) abort() + +enum Enum { one, two, three, four }; + +@interface Base: Object { + unsigned a: 2; + int b: 3; + enum Enum c: 4; + unsigned d: 5; +} /* { dg-warning "padding struct size to alignment boundary" } */ +@end + +@interface Derived: Base { + signed e: 5; + int f: 4; + enum Enum g: 3; +} /* { dg-warning "padding struct size to alignment boundary" } */ +@end + +/* Note that the semicolon after @defs(...) is optional. */ + +typedef struct { @defs(Base) } Base_t; /* { dg-warning "padding struct size to alignment boundary" } */ +typedef struct { @defs(Derived); } Derived_t; /* { dg-warning "padding struct size to alignment boundary" } */ + +int main(void) +{ + CHECK_IF(sizeof(Base_t) == sizeof(Base)); + CHECK_IF(sizeof(Derived_t) == sizeof(Derived)); + +#ifdef __NEXT_RUNTIME__ + CHECK_IF(!strcmp(@encode(Base), "{Base=#b2b3b4b5}")); + CHECK_IF(!strcmp(@encode(Derived), "{Derived=#b2b3b4b5b5b4b3}")); + + CHECK_IF(!strcmp(@encode(Base_t), "{?=#b2b3b4b5}")); + CHECK_IF(!strcmp(@encode(Derived_t), "{?=#b2b3b4b5b5b4b3}")); +#endif /* __NEXT_RUNTIME__ */ + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-1.m (revision 309) @@ -0,0 +1,58 @@ +/* Test for handling of protocol hierarchies. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +/* One-line substitute for objc/objc.h */ +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +@protocol NSObj +- (void)someMethod; +@end + +@protocol NSCopying +- (void)someOtherMethod; +@end + +@interface NSObject +- (void)someMethod; +@end + +@implementation NSObject +- (void)someMethod {} +@end + +@protocol Booing +- (void)boo; +@end + +@interface Boo: NSObject // protocol has only one parent +@end + +@implementation Boo +- (void)boo {} +@end + +@protocol Fooing // Fooing has two parent protocols +- (void)foo; +@end + +@interface Foo: NSObject +@end + +@implementation Foo +- (void)foo {} +- (void)someOtherMethod {} +@end + +int foo(void) { + id stupidVar; + [stupidVar boo]; + [stupidVar foo]; + [stupidVar anotherMsg]; /* { dg-warning ".\\-anotherMsg. not found in protocol" } */ + /* { dg-warning "no .\\-anotherMsg. method found" "" { target *-*-* } 51 } */ + return 0; +} + +/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ +/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ +/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/alias.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/alias.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/alias.m (revision 309) @@ -0,0 +1,12 @@ +/* Test alias warnings. */ +/* { dg-do compile } */ + +@compatibility_alias class1 class2; /* { dg-warning "annot find class" } */ + +@interface class3; +@end + +@interface class4; +@end + +@compatibility_alias class4 class3; /* { dg-warning "lass" "already exists" } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/anon-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/anon-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/anon-1.m (revision 309) @@ -0,0 +1,14 @@ +/* Test for graceful handling of anonymous ivars. */ +/* { dg-do compile } */ + +@interface Foo { + unsigned char : 1; + int e: 3; + signed: 2; + float f; +} +@end + +@implementation Foo +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/id-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/id-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/id-1.m (revision 309) @@ -0,0 +1,7 @@ +/* Test attempt to redefine 'id' in an incompatible fashion. */ +/* { dg-do compile } */ + +typedef int id; /* { dg-error "conflicting types for .id." } */ +/* { dg-message "previous declaration of .id. was here" "" { target *-*-* } 0 } */ + +id b; Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/desig-init-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/desig-init-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/desig-init-2.m (revision 309) @@ -0,0 +1,7 @@ +/* Test handling of C99 designator lists in Objective-C. Test array + designators after structure member designators. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct s { int a[2]; } x = { .a[0] = 1 }; Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-3.m (revision 309) @@ -0,0 +1,75 @@ +/* Method encoding tests for stand-alone @protocol declarations. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ + +#include +#include "../objc-obj-c++-shared/Protocol1.h" +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#ifdef __cplusplus +#define ProtoBool bool +#else +#define ProtoBool _Bool +#endif + +#ifndef __NEXT_RUNTIME__ +#include +#endif + +extern int sscanf(const char *str, const char *format, ...); +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +enum Enum { + zero, one, two, three +}; +typedef enum Enum Enum; +typedef signed char ObjCBool; /* as used by the NeXT runtime */ + +@protocol Proto +union __XXAngle { unsigned int alpha, beta; }; +typedef struct { float x, y; union __XXAngle a; } XXPoint; +typedef struct { double width, height; } XXSize; +typedef struct _XXRect { XXPoint origin; XXSize size; struct _XXRect *next; } XXRect; +- (void) char:(signed char)c float:(float)f double:(double)d unsigned:(unsigned)u short:(short)s long:(long)l; +- (void *)setRect:(XXRect)r withBool:(ProtoBool)b withInt:(int)i; ++ (Enum *)getEnum:(XXPoint *)pt enum:(enum Enum)e bool:(ObjCBool)b; ++ (ProtoBool **)getBool:(ObjCBool **)b; +@end + +Protocol *proto = @protocol(Proto); +struct objc_method_description *meth; +unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7; + +static void scan_initial(const char *pattern) { + totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1; + sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6, &offs7); + CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 + sizeof(SEL) && totsize >= offs2); +} + +int main(void) { + const char *string; + + meth = [proto descriptionForInstanceMethod: @selector(char:float:double:unsigned:short:long:)]; + if (sizeof (long) == 8) + string = "v%u@%u:%uc%uf%ud%uI%us%uq%u"; + else + string = "v%u@%u:%uc%uf%ud%uI%us%ul%u"; + scan_initial(string); + CHECK_IF(offs3 == offs2 + sizeof(int) && offs4 == offs3 + sizeof(float)); + CHECK_IF(offs5 == offs4 + sizeof(double) && offs6 == offs5 + sizeof(unsigned)); + CHECK_IF(offs7 == offs6 + sizeof(int) && totsize == offs7 + sizeof(long)); + meth = [proto descriptionForInstanceMethod: @selector(setRect:withBool:withInt:)]; + scan_initial("^v%u@%u:%u{_XXRect={?=ff(__XXAngle=II)}{?=dd}^{_XXRect}}%uB%ui%u"); + CHECK_IF(offs3 == offs2 + sizeof(XXRect) && offs4 == offs3 + sizeof(int)); + CHECK_IF(totsize == offs4 + sizeof(int)); + meth = [proto descriptionForClassMethod: @selector(getEnum:enum:bool:)]; + scan_initial("^i%u@%u:%u^{?=ff(__XXAngle=II)}%ui%uc%u"); + CHECK_IF(offs3 == offs2 + sizeof(XXPoint *) && offs4 == offs3 + sizeof(enum Enum)); + CHECK_IF(totsize == offs4 + sizeof(int)); /* 'ObjCBool' is really 'char' */ + meth = [proto descriptionForClassMethod: @selector(getBool:)]; + scan_initial("^^B%u@%u:%u^*%u"); + CHECK_IF(totsize == offs2 + sizeof(ObjCBool **)); + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-1.m (revision 309) @@ -0,0 +1,87 @@ +/* Test various ObjC types assignments and comparisons. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +#include + +@protocol MyProtocol +- (void) foo; +@end + +@interface MyClass +@end + +@interface MyOtherClass +- (void) foo; +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_c = nil; + MyOtherClass *obj_cp = nil; + Class obj_C = Nil; + + /* Assigning to an 'id' variable should never + generate a warning. */ + obj = obj_p; /* Ok */ + obj = obj_c; /* Ok */ + obj = obj_cp; /* Ok */ + obj = obj_C; /* Ok */ + + /* Assigning to a 'MyClass *' variable should always generate a + warning, unless done from an 'id'. */ + obj_c = obj; /* Ok */ + obj_c = obj_p; /* { dg-warning "distinct Objective\\-C type" } */ + obj_c = obj_cp; /* { dg-warning "distinct Objective\\-C type" } */ + obj_c = obj_C; /* { dg-warning "distinct Objective\\-C type" } */ + + /* Assigning to an 'id' variable should generate a + warning if done from a 'MyClass *' (which doesn't implement + MyProtocol), but not from an 'id' or from a 'MyOtherClass *' + (which implements MyProtocol). */ + obj_p = obj; /* Ok */ + obj_p = obj_c; /* { dg-warning "does not implement" } */ + obj_p = obj_cp; /* Ok */ + obj_p = obj_C; /* { dg-warning "distinct Objective\\-C type" } */ + + /* Assigning to a 'MyOtherClass *' variable should always generate + a warning, unless done from an 'id' or an 'id' (since + MyOtherClass implements MyProtocol). */ + obj_cp = obj; /* Ok */ + obj_cp = obj_c; /* { dg-warning "distinct Objective\\-C type" } */ + obj_cp = obj_p; /* Ok */ + obj_cp = obj_C; /* { dg-warning "distinct Objective\\-C type" } */ + + /* Any comparison involving an 'id' must be without warnings. */ + if (obj == obj_p) ; /* Ok */ /*Bogus warning here in 2.95.4*/ + if (obj_p == obj) ; /* Ok */ + if (obj == obj_c) ; /* Ok */ + if (obj_c == obj) ; /* Ok */ + if (obj == obj_cp) ; /* Ok */ + if (obj_cp == obj) ; /* Ok */ + if (obj == obj_C) ; /* Ok */ + if (obj_C == obj) ; /* Ok */ + + /* Any comparison between 'MyClass *' and anything which is not an 'id' + must generate a warning. */ + if (obj_c == obj_p) ; /* { dg-warning "lacks a cast" } */ + if (obj_p == obj_c) ; /* { dg-warning "lacks a cast" } */ + if (obj_c == obj_cp) ; /* { dg-warning "lacks a cast" } */ + if (obj_cp == obj_c) ; /* { dg-warning "lacks a cast" } */ + if (obj_c == obj_C) ; /* { dg-warning "lacks a cast" } */ + if (obj_C == obj_c) ; /* { dg-warning "lacks a cast" } */ + + /* Any comparison between 'MyOtherClass *' (which implements + MyProtocol) and an 'id' implementing MyProtocol are Ok. */ + if (obj_cp == obj_p) ; /* Ok */ + if (obj_p == obj_cp) ; /* Ok */ + + + if (obj_p == obj_C) ; /* { dg-warning "lacks a cast" } */ + if (obj_C == obj_p) ; /* { dg-warning "lacks a cast" } */ + if (obj_cp == obj_C) ; /* { dg-warning "lacks a cast" } */ + if (obj_C == obj_cp) ; /* { dg-warning "lacks a cast" } */ + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-3.m (revision 309) @@ -0,0 +1,19 @@ +/* Test if caught exception objects are accessible inside the + @catch block. (Yes, I managed to break this.) */ +/* Author: Ziemowit Laski */ + +/* { dg-do compile } */ +/* { dg-options "-fobjc-exceptions" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +const char *foo(void) +{ + @try { + return "foo"; + } + @catch (Object* theException) { + return [theException name]; + } +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-20.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-20.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-20.m (revision 309) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +/* We used to crash after we found the type for int[m] was declared as invalid. */ +/* PR objc/29197 */ + +@ implementation NGActiveSocket ++ (void) socketPair:(int[m]) _pair {} /* { dg-error "" } */ + /* { dg-warning "" "" { target *-*-* } 7 } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-1.m (revision 309) @@ -0,0 +1,5 @@ +/* Test super classes. */ +/* { dg-do compile } */ + +@interface class0 : supclass0 +@end /* { dg-error "annot find interface declaration for .*, superclass" } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-7.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-7.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-7.m (revision 309) @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +#include +#include + +struct f +{ + _Bool a; +}; + + +int main(void) +{ + if (objc_sizeof_type (@encode (struct f)) != sizeof(struct f)) + abort (); + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-5.m (revision 309) @@ -0,0 +1,32 @@ +/* Test assignments and comparisons involving `one-off' protocols. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +#include + +@protocol MyProtocol +- (void) method; +@end + +@interface MyClass +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_cp = nil; + + obj_cp = obj; /* Ok */ + obj = obj_cp; /* Ok */ + + obj_cp = obj_p; /* Ok */ + obj_p = obj_cp; /* Ok */ + + if (obj_cp == obj) ; /* Ok */ + if (obj == obj_cp) ; /* Ok */ + + if (obj_cp == obj_p) ; /* Ok */ + if (obj_p == obj_cp) ; /* Ok */ + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dwarf-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dwarf-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dwarf-2.m (revision 309) @@ -0,0 +1,4 @@ +/* { dg-options "-gdwarf-2 -dA -gno-strict-dwarf" } */ +/* { dg-final { scan-assembler "0x10\[^0-9a-f\].*DW_AT_language" } } */ +/* { dg-skip-if "No Dwarf" { { *-*-aix* alpha*-dec-osf* hppa*-*-hpux* } && { ! hppa*64*-*-* } } { "*" } { "" } } */ +int x; Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-7.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-7.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-7.m (revision 309) @@ -0,0 +1,27 @@ +/* Test for graceful compilation of @synchronized statements. */ + +/* { dg-do compile } */ +/* { dg-options "-fobjc-exceptions" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Derived: Object +- (id) meth; +@end + +@implementation Derived +- (id) meth { + return self; +} + +static Derived* rewriteDict(void) { + static Derived *sDict = 0; + if (sDict == 0) { + @synchronized ([Derived class]) { + if (sDict == 0) + sDict = [Derived new]; + } + } + return sDict; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-9.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-9.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-9.m (revision 309) @@ -0,0 +1,19 @@ +/* Yet another mysterious gimplifier crasher. */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +@class NSString; +@protocol NSObject +@end +@interface NSObject { +} +@end +void __setRetained(id *ivar, id value) { + *ivar = value; +} +static NSString *_logProcessPrefix = 0; +@implementation NSObject (ScopeAdditions) ++ (void)setObjectLogProcessPrefix:(NSString *)processPrefix { + __setRetained(&_logProcessPrefix, processPrefix); +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-3.m (revision 309) @@ -0,0 +1,57 @@ +/* Check if sending messages to super does not interfere with sending messages + to classes. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +@interface Base: Object ++ (int) class_func1; +- (int) instance_func1; +@end + +@interface Derived: Base ++ (int) class_func1; +@end + +@interface Derived (Categ) +- (int) instance_func1; +@end + +@implementation Base ++ (int) class_func1 { return 234; } +- (int) instance_func1 { return 345; } +@end + +@implementation Derived ++ (int) class_func1 { + int i = [super class_func1]; + i += [Base class_func1]; + return i; +} +@end + +@implementation Derived (Categ) +- (int) instance_func1 { + int i = [super instance_func1]; + i += [Base class_func1]; /* { dg-bogus "invalid receiver type" } */ + return i; +} +@end + +int main(void) { + Base *base = [[Base alloc] init]; /* { dg-bogus "invalid receiver type" } */ + Derived *derived = [[Derived alloc] init]; + CHECK_IF([Base class_func1] == 234); /* { dg-bogus "invalid receiver type" } */ + CHECK_IF([Derived class_func1] == 234 + 234); + CHECK_IF([base instance_func1] == 345); + CHECK_IF([derived instance_func1] == 234 + 345); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-1.m (revision 309) @@ -0,0 +1,6 @@ +/* Test for graceful handling of missing protocol declarations. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface Foo /* { dg-error "cannot find protocol declaration for .Missing." } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/private-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/private-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/private-2.m (revision 309) @@ -0,0 +1,54 @@ +/* Test warnings for shadowing instance variables. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +#include + +@interface MySuperClass +{ +@private + int private; + +@protected + int protected; + +@public + int public; +} +- (void) test; +@end + +@implementation MySuperClass +- (void) test +{ + /* FIXME: I wonder if the warnings shouldn't be better generated + when the variable is declared, rather than used! */ + int private = 12; + int protected = 12; + int public = 12; + int a; + + a = private; /* { dg-warning "hides instance variable" } */ + a = protected; /* { dg-warning "hides instance variable" } */ + a = public; /* { dg-warning "hides instance variable" } */ +} +@end + + +@interface MyClass : MySuperClass +@end + +@implementation MyClass +- (void) test +{ + int private = 12; + int protected = 12; + int public = 12; + int a; + + /* The private variable can be shadowed without warnings, because + * it's invisible, and not accessible, to the subclass! */ + a = private; /* Ok */ + a = protected; /* { dg-warning "hides instance variable" } */ + a = public; /* { dg-warning "hides instance variable" } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-10.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-10.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-10.m (revision 309) @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@protocol Foo +- (id)meth1; +- (id)meth2:(int)arg; +@end + +@interface Derived1: Object +@end + +@interface Derived2: Object ++ (Derived1 *)new; +@end + +id func(void) { + Object *o = [Object new]; + return o; /* { dg-warning "class .Object. does not implement the .Foo. protocol" } */ +} + +@implementation Derived2 ++ (Derived1 *)new { + Derived2 *o = [super new]; + return o; /* { dg-warning "distinct Objective\\-C type in return" } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-2.m (revision 309) @@ -0,0 +1,16 @@ +/* Test that we don't ICE when issuing a -Wselector warning. */ +/* { dg-options "-Wselector" } */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Foo +@end +@implementation Foo +-(void) foo +{ + SEL a; + a = @selector(b1ar); +} +@end +/* { dg-warning "creating selector for nonexistent method .b1ar." "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pr28050.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pr28050.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pr28050.m (revision 309) @@ -0,0 +1,2 @@ +/* { dg-do compile } */ +int i = [0]; /* { dg-error "expected .:. before .\\]. token" } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-3.m (revision 309) @@ -0,0 +1,48 @@ +/* Test for sending messages to aliased classes (and instances thereof). */ +/* Author: Ziemowit Laski . */ +/* { dg-options "" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +@interface Int1: Object ++ (int) classMeth; +- (int) instanceMeth; +@end + +@interface Int2: Object ++ (int) classMeth; +- (int) instanceMeth; +@end + +@implementation Int1 ++ (int) classMeth { return 345; } +- (int) instanceMeth { return 697; } +@end + +@implementation Int2 ++ (int) classMeth { return 1345; } +- (int) instanceMeth { return 1697; } +@end + +typedef Int1 Int1Typedef; +@compatibility_alias Int1Alias Int1Typedef; +@compatibility_alias Int2Alias Int2; +typedef Int2Alias Int2Typedef; + +int main(void) { + Int1Alias *int1alias = [[Int1Typedef alloc] init]; + Int2Typedef *int2typedef = [[Int2Alias alloc] init]; + + CHECK_IF([Int1Typedef classMeth] == 345 && [Int2Alias classMeth] == 1345); + CHECK_IF([int1alias instanceMeth] == 697 && [int2typedef instanceMeth] == 1697); + CHECK_IF([(Int2Typedef *)int1alias instanceMeth] == 697); + CHECK_IF([(Int1Alias *)int2typedef instanceMeth] == 1697); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-7.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-7.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-7.m (revision 309) @@ -0,0 +1,29 @@ +/* Check if finding multiple signatures for a method is handled gracefully. */ +/* Author: Ziemowit Laski */ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-selector-match" } */ + + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Class1 +- (void)setWindow:(Object *)wdw; +@end + +@interface Class2 +- (void)setWindow:(Class1 *)window; +@end + +id foo(void) { + Object *obj = [[Object alloc] init]; + id obj2 = obj; + [obj setWindow:nil]; /* { dg-warning ".Object. may not respond to .\\-setWindow:." } */ + /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 20 } */ + /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 20 } */ + /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 20 } */ + [obj2 setWindow:nil]; /* { dg-warning "multiple methods named .\\-setWindow:. found" } */ + /* { dg-message "using .\\-\\(void\\)setWindow:\\(Object \\*\\)wdw." "" { target *-*-* } 10 } */ + /* { dg-message "also found .\\-\\(void\\)setWindow:\\(Class1 \\*\\)window." "" { target *-*-* } 14 } */ + + return obj; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/typedef-alias-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/typedef-alias-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/typedef-alias-1.m (revision 309) @@ -0,0 +1,16 @@ +/* Typedefs of ObjC types should work without any bogus warnings. */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +typedef Object MyObject; + +int main (int argc, const char * argv[]) +{ + Object* a = nil; + MyObject* b = a; + Object* c = b; + + return 0; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-1.m (revision 309) @@ -0,0 +1,46 @@ +/* Check for warnings about missing [super dealloc] calls. */ +/* Author: Ziemowit Laski */ + +/* { dg-do compile } */ + +@interface Foo { + void *isa; +} +- (void) dealloc; +- (void) some_other; +@end + +@interface Bar: Foo { + void *casa; +} +- (void) dealloc; +@end + +@interface Baz: Bar { + void *usa; +} +- (void) dealloc; +@end + +@implementation Foo +- (void) dealloc { + isa = 0; /* Should not warn here. */ +} +- (void) some_other { + isa = (void *)-1; +} +@end + +@implementation Bar +- (void) dealloc { + casa = 0; + [super some_other]; +} /* { dg-warning "method possibly missing a .super dealloc. call" } */ +@end + +@implementation Baz +- (void) dealloc { + usa = 0; + [super dealloc]; /* Should not warn here. */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-2.m (revision 309) @@ -0,0 +1,20 @@ +/* Don't forget to look in protocols if a class (and its superclasses) do not + provide a suitable method. */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@protocol Zot +-(void) zot; +@end + +@interface Foo : Object +@end + +int foo() +{ + Foo *f=nil; + [f zot]; /* There should be no warnings here! */ + return 0; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-4.m (revision 309) @@ -0,0 +1,31 @@ +/* Ensure that the preprocessor handles ObjC string constants gracefully. */ +/* Author: Ziemowit Laski */ +/* { dg-options "-fconstant-string-class=MyString " } */ +/* { dg-do run } */ + +extern void abort(void); + +@interface MyString +{ + void *isa; + char *str; + int len; +} +@end + +#define kMyStringMacro1 "My String" +#define kMyStringMacro2 @"My String" + +void *_MyStringClassReference; + +@implementation MyString +@end + +int main(void) { + MyString* aString1 = @kMyStringMacro1; + MyString* aString2 = kMyStringMacro2; + if(aString1 != aString2) { + abort(); + } + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/func-ptr-2.m (revision 309) @@ -0,0 +1,41 @@ +/* Check if method parameters that are functions are gracefully decayed + into pointers. */ +/* Contributed by Ziemowit Laski */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include +/* provide an Object class for NeXT runtimes 10.5 and above */ +#include "../objc-obj-c++-shared/Object1.h" + +@interface Func: Object ++ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func; +@end + +@implementation Func ++ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func { + return func (a, b); +} +@end + +static int my_computation(int a, int b) { + return a * 2 + b * 3; +} + +static int processNumber(int a, int b, int func(int, int)) { + return func(a, b); +} + +int main(void) { + int result = processNumber (6, 8, my_computation); + if (result != 36) + abort (); + + result = [Func processNumber:8 and:6 usingFunction:my_computation]; + if (result != 34) + abort (); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/param-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/param-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/param-1.m (revision 309) @@ -0,0 +1,20 @@ +/* Test if compiler detects object as an parameter to a method + or not. It is not valid. */ +/* { dg-do compile } */ + +@interface foo +@end + +@implementation foo +@end + +@interface bar +-(void) my_method:(foo) my_param; /* { dg-error "can not use an object as parameter to a method" } */ +@end + +@implementation bar +-(void) my_method:(foo) my_param /* { dg-error "can not use an object as parameter to a method" } */ +{ +} +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stret-2.m (revision 309) @@ -0,0 +1,49 @@ +/* Test for handling of struct-returning methods + for the Mac OS X ("NeXT") runtime (which uses specialized entry + points). */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-require-effective-target ilp32 } */ + +#include "../objc-obj-c++-shared/Object1.h" + +struct astruct { + float a, b; + char c; +} glob = { 1.0, 2.0, 'a' }; + +struct bstruct { + float a, b, c, d, e, f; +} globb = { 1, 2, 3, 4, 5, 6 }; + +@interface foo : Object +- (struct astruct) stret; +- (struct bstruct) stretb; +@end + +@implementation foo : Object +- (struct astruct) stret { return glob; } +- (struct bstruct) stretb { return globb; } +@end + +@interface bar: foo +- (struct astruct) stret; +- (struct bstruct) stretb; +@end + +@implementation bar +- (struct astruct) stret { return [super stret]; } +- (struct bstruct) stretb { return [super stretb]; } +@end + +struct astruct afunc(foo *foo_obj) { + return [foo_obj stret]; +} + +/* { dg-final { scan-assembler "objc_msgSend_stret" } } */ +/* { dg-final { scan-assembler "objc_msgSendSuper_stret" } } */ + +/* { dg-final { scan-assembler-not "objc_msgSend\[^_S\]" } } */ +/* { dg-final { scan-assembler-not "objc_msgSendSuper\[^_\]" } } */ + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-12.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-12.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-12.m (revision 309) @@ -0,0 +1,25 @@ +/* Contributed by Igor Seleznev . */ +/* This used to be broken. */ + +#include + +@interface A ++ (A *)currentContext; +@end + +@interface B ++ (B *)currentContext; +@end + +int main() +{ + [A currentContext]; /* { dg-bogus "multiple declarations" } */ + return 0; +} + +@implementation A ++ (A *)currentContext { return nil; } +@end +@implementation B ++ (B *)currentContext { return nil; } +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-8.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-8.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-8.m (revision 309) @@ -0,0 +1,43 @@ +/* Test for assigning compile-time constant-string objects to static variables. */ +/* Contributed by Ziemowit Laski */ +/* { dg-options "-fconstant-string-class=Foo" } */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +@interface Foo: Object { + char *cString; + unsigned int len; +} +@end + +#ifndef NEXT_OBJC_USE_NEW_INTERFACE +struct objc_class _FooClassReference; +#else +Class _FooClassReference; +#endif + +@implementation Foo : Object +- (char *)customString { + return cString; +} +@end + +static const Foo *appKey = @"MyApp"; +static int CFPreferencesSynchronize (const Foo *ref) { + return ref == appKey; +} + +static void PrefsSynchronize(void) +{ + if(!CFPreferencesSynchronize(appKey)) + abort(); +} + +int main () { + PrefsSynchronize(); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-6.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-6.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-6.m (revision 309) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +@class Base; +@protocol _Protocol; + +@interface ClassA { +} +-(void) func1:(Base<_Protocol> *)inTarget; +@end + +int main() +{ + ClassA* theA = 0; + Base<_Protocol>* myBase = 0; + [theA func1:myBase]; + + return 0; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-16.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-16.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-16.m (revision 309) @@ -0,0 +1,24 @@ +/* Do not warn about "slightly" mismatched method signatures if + -Wstrict-selector-match is off. */ + +/* { dg-do compile } */ +/* { dg-options "-Wno-strict-selector-match" } */ + +#include + +@interface Base +- (id) meth1: (Base *)arg1; +- (id) window; +@end + +@interface Derived: Base +- (id) meth1: (Derived *)arg1; +- (Base *)window; +@end + +void foo(void) { + id r; + + [r meth1:r]; + [r window]; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/objc-gc-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/objc-gc-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/objc-gc-4.m (revision 309) @@ -0,0 +1,64 @@ +/* Test looking up fields in superclasses in the context of write-barriers + (where component references get rewritten). */ +/* Contributed by Ziemowit Laski */ + +/* { dg-do compile } */ +/* { dg-options "-fobjc-gc" } */ +/* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@class MyWindow; + +@interface MyDocument : Object { + MyWindow *_window; +} +@end + +@interface MyFileDocument : MyDocument { + struct { + unsigned int autoClose:1; + unsigned int openForUI:1; + unsigned int isClosing:1; + unsigned int needsDiskCheck:1; + unsigned int isWritable:1; + unsigned int representsFileOnDisk:1; + unsigned int RESERVED:26; + } _fdFlags; +} +@end + +@interface MyTextFileDocument : MyFileDocument { + Object *_textStorage; + struct __tfdFlags { + unsigned int immutable:1; + unsigned int lineEnding:2; + unsigned int isClosing:1; + unsigned int settingsAreSet:1; + unsigned int usesTabs:1; + unsigned int isUTF8WithBOM:1; + unsigned int wrapsLines:1; + unsigned int usingDefaultLanguage:1; + unsigned int RESERVED:23; + } _tfdFlags; + int _tabWidth; + int _indentWidth; +} +@end + +@interface MyRTFFileDocument : MyTextFileDocument +- (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type; +@end + +@implementation MyRTFFileDocument +- (BOOL)readFromFile:(const char *)fileName ofType:(const char *)type { + if (_textStorage && fileName) { + [_textStorage free]; + return YES; + } else if (type) { + _textStorage = [MyRTFFileDocument new]; + return NO; + } + return (fileName && type); +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type-2.m (revision 309) @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* Contributed by Alexander Malmberg: PR18456 */ + +@interface Foo +-(void) foo; +@end + +void *ip; + +void (*func1)(void); + +struct +{ + int a:2; +} struct1,struct2[2]; + +union +{ + int a:2; +} union1,union2[2]; + +Foo **f; + +int main(int argc,char **argv) +{ + [(struct {int a;} *)ip foo]; /* { dg-warning "invalid receiver type" } */ + [func1 foo]; /* { dg-warning "invalid receiver type" } */ + [struct1.a foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-warning "cast to pointer from integer" "" { target *-*-* } 28 } */ + [union1.a foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-warning "cast to pointer from integer" "" { target *-*-* } 30 } */ + [struct1 foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-error "cannot convert" "" { target *-*-* } 32 } */ + [union1 foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-error "cannot convert" "" { target *-*-* } 34 } */ + [struct2 foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-error "cannot convert" "" { target *-*-* } 36 } */ + [union2 foo]; /* { dg-warning "invalid receiver type" } */ + /* { dg-error "cannot convert" "" { target *-*-* } 38 } */ + [f foo]; /* { dg-warning "invalid receiver type" } */ +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/lookup-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/lookup-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/lookup-1.m (revision 309) @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include +#include "../objc-obj-c++-shared/Object1.h" + +typedef struct MyWidget { + int a; +} MyWidget; + +MyWidget gWidget = { 17 }; + +@protocol MyProto +- (MyWidget *)widget; +@end + +@interface Foo: Object +@end + +@interface Bar: Foo +@end + +@interface Container: Object ++ (MyWidget *)elementForView:(Foo *)view; +@end + +@implementation Foo +@end + +@implementation Bar +- (MyWidget *)widget { + return &gWidget; +} +@end + +@implementation Container ++ (MyWidget *)elementForView:(Foo *)view +{ + MyWidget *widget = (MyWidget *) nil; + if ([view conformsTo:@protocol(MyProto)]) { + widget = [(Foo *)view widget]; + } + return widget; +} +@end + +int main(void) { + id view = [Bar new]; + MyWidget *w = [Container elementForView: view]; + + if (!w || w->a != 17) + abort (); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-1.m (revision 309) @@ -0,0 +1,19 @@ +/* Test for obscuring of @interfaces with local vars. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface View +@end + +void foo(void) +{ + int View; /* ok */ + View = 1; /* ok */ + View *view; /* { dg-error "undeclared|only once|it appears" } */ +} + +void bar(void) +{ + View *view; /* ok */ + View = 1; /* { dg-error "parse error|syntax error|expected" } */ +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-2.m (revision 309) @@ -0,0 +1,29 @@ +/* Check if the '-fno-zero-link' flag correctly _omits_ an objc_getClass() call. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-options "-fno-zero-link" } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object ++ (int) getValue; +@end + +@implementation Base ++ (int) getValue { return 1593; } +@end + +int main(void) { + int val = [Base getValue]; + CHECK_IF(val == 1593); + return 0; +} + +/* { dg-final { scan-assembler "_OBJC_CLASS_REFERENCES_0" } } */ +/* { dg-final { scan-assembler-not "objc_getClass" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-10.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-10.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-10.m (revision 309) @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +typedef struct Vec { + double x, y; + int z; +} xyz_t ; + +typedef struct { + float fscalar; + double dscalar; + xyz_t dv; + int iscalar; +} anonymous; + +const char *enc = @encode(xyz_t); +const char *enc2 = @encode(anonymous); + +/* { dg-final { scan-assembler "{Vec=ddi}" } } */ +/* { dg-final { scan-assembler "{?=fd{Vec=ddi}i}" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-11.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-11.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-11.m (revision 309) @@ -0,0 +1,33 @@ +/* Test if ObjC constant string layout is checked properly, regardless of how + constant string classes get derived. */ +/* Contributed by Ziemowit Laski */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-options "-fconstant-string-class=XStr" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface XString: Object { +@protected + char *bytes; +} +@end + +@interface XStr : XString { +@public + unsigned int len; +} +@end + +#ifndef NEXT_OBJC_USE_NEW_INTERFACE +extern struct objc_class _XStrClassReference; +#else +extern Class _XStrClassReference; +#endif + +const XStr *appKey = @"MyApp"; + +/* { dg-final { scan-assembler ".section __OBJC, __cstring_object" } } */ +/* { dg-final { scan-assembler ".long\t__XStrClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler ".quad\t__XStrClassReference\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-4.m (revision 309) @@ -0,0 +1,28 @@ +/* Make sure that bitfield types are printed correctly, and that ivar redeclaration + (@interface vs. @implementation) checks take the bitfield width into account. */ +/* Author: Ziemowit Laski */ +/* { dg-do compile } */ + +@interface Base { + int i; +} +@end + +@interface WithBitfields: Base { + void *isa; + unsigned a: 3; + signed b: 4; + int c: 5; +} +@end + +@implementation WithBitfields { + char *isa; /* { dg-error "conflicting instance variable type .char \\*isa." } */ + /* { dg-error "previous declaration of .void \\*isa." "" { target *-*-* } 12 } */ + unsigned a: 5; /* { dg-error "conflicting instance variable type .unsigned( int)? a: 5." } */ + /* { dg-error "previous declaration of .unsigned( int)? a: 3." "" { target *-*-* } 13 } */ + signed b: 4; /* This one is fine. */ + int c: 3; /* { dg-error "conflicting instance variable type .int c: 3." } */ + /* { dg-error "previous declaration of .int c: 5." "" { target *-*-* } 15 } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/weak-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/weak-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/weak-1.m (revision 309) @@ -0,0 +1,13 @@ +/* Test for #pragma weak where the weak alias symbol isn't declared, + although the symbol it is an alias for is defined in the + translation unit. Bug 7544. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +/* { dg-require-alias "" } */ +/* { dg-options "-fno-common" } */ + +/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?bar1" } } */ + +#pragma weak bar1 = foo1 +void foo1 (void) {} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-hier-2.m (revision 309) @@ -0,0 +1,49 @@ +/* Test protocol warning. */ +/* Contributed by Devang Patel . */ +/* { dg-do compile } */ + +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +@protocol Bar +@end + +id Foo_Bar () { } + +typedef struct +{ + int i; +} MyStruct; + +@interface Foo +{ + id _mainData; + MyStruct *_anotherData; +} + +-(id) mainDataSource; +-(id) anotherDataSource; +-(id) my_method: (int) i; +@end + +@implementation Foo +-(id) anotherDataSource +{ + return (id)_anotherData; +} + +-(id) mainDataSource +{ + return _mainData; +} + +-(id) my_method: (int) i +{ + id one = [self anotherDataSource]; + + i = i - 1; + // Do not issue warning about my_method not found in protocol + return [(one ? [self mainDataSource] : one) my_method:i]; +} + +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-4.m (revision 309) @@ -0,0 +1,93 @@ +/* Encoding tests for ObjC class layouts. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include "../objc-obj-c++-shared/next-mapping.h" +#ifdef __NEXT_RUNTIME__ +#include +#else +#include +#endif + +extern void abort(void); +extern int strcmp(const char *s1, const char *s2); + +#define CHECK_IF(expr) if(!(expr)) abort() + +@class Int1, Int2; +struct Nested; + +struct Innermost { + unsigned char a, b; + struct Nested *encl; +}; + +struct Nested { + float a, b; + Int1 *next; + struct Innermost innermost; +}; + +@interface Int1: Object { + signed char a, b; + Int2 *int2; + struct Nested nested; +} +@end + +@interface Int2: Int1 { + struct Innermost *innermost; + Int1 *base; +} +@end + +@implementation Int1 +@end + +@implementation Int2 +@end + +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +Ivar *ivar; +#else +struct objc_ivar *ivar; +#endif + +static void check_ivar(const char *name, const char *type) { +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + CHECK_IF(!strcmp(ivar_getName(*ivar), name)); + CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type)); +#else + CHECK_IF(!strcmp(ivar->ivar_name, name)); + CHECK_IF(!strcmp(ivar->ivar_type, type)); +#endif + ivar++; +} + +int main(void) { +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + ivar = class_copyIvarList ((Class)objc_get_class("Int1"), NULL); +#else + ivar = ((Class)objc_get_class("Int1"))->ivars->ivar_list; +#endif + check_ivar("a", "c"); + check_ivar("b", "c"); + check_ivar("int2", "@\"Int2\""); + check_ivar("nested", + "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}"); + +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + ivar = class_copyIvarList ((Class)objc_get_class("Int2"), NULL); +#else + ivar = ((Class)objc_get_class("Int2"))->ivars->ivar_list; +#endif + check_ivar("innermost", "^{Innermost=CC^{Nested}}"); + check_ivar("base", "@\"Int1\""); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-4.m (revision 309) @@ -0,0 +1,26 @@ +/* Check that the compiler does not incorrectly complain about + exceptions being caught by previous @catch blocks. */ +/* Author: Ziemowit Laski */ + +/* { dg-do compile } */ +/* { dg-options "-Wall -fobjc-exceptions" } */ + +@interface Exception +@end + +@interface FooException : Exception +@end + +extern void foo(); + +void test() +{ + @try { + foo(); + } + @catch (FooException* fe) { + } + @catch (Exception* e) { + } +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-2.m (revision 309) @@ -0,0 +1,37 @@ +/* Test simple ObjC types casts. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +#include + +@protocol MyProtocol +- (void) foo; +@end + +@interface MyClass +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_c = nil; + Class obj_C = Nil; + + /* All these casts should generate no warnings. */ + + obj = (id)obj_p; + obj = (id)obj_c; + obj = (id)obj_C; + obj_c = (MyClass *)obj; + obj_c = (MyClass *)obj_p; + obj_c = (MyClass *)obj_C; + obj_p = (id)obj; + obj_p = (id)obj_c; + obj_p = (id)obj_C; + obj_C = (Class)obj; + obj_C = (Class)obj_p; + obj_C = (Class)obj_c; + + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-2.m (revision 309) @@ -0,0 +1,44 @@ +/* Test calling super from within a category class method. */ +/* Author: Ziemowit Laski */ +/* { dg-do compile } */ + +typedef struct objc_object { struct objc_class *isa; } *id; + +@interface NSObject ++ (int) test_func0; +@end +@interface NSMenuItem: NSObject ++ (int) test_func0; +@end + +@implementation NSObject ++ (int) test_func0 +{} +@end + +@implementation NSMenuItem ++ (int) test_func0 +{ + return [super test_func0]; +} +@end + +@interface NSObject (Test) ++ (int) test_func; +@end + +@implementation NSObject (Test) ++ (int) test_func +{} +@end + +@interface NSMenuItem (Test) ++ (int) test_func; +@end + +@implementation NSMenuItem (Test) ++ (int) test_func +{ + return [super test_func]; /* { dg-bogus "dereferencing pointer to incomplete type" } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/conditional-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/conditional-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/conditional-1.m (revision 309) @@ -0,0 +1,45 @@ +/* Testing conditional warnings (without headers). */ +/* Author: David Ayers */ + +/* { dg-do compile } */ + +#define nil ((id)0) +@interface MyObject +@end + +@protocol MyProtocol +@end + +@interface MyProtoObject +@end + + +int +main (int argc, char *argv[]) +{ + id var_id = nil; + id var_id_p = nil; + MyObject *var_obj = nil; + MyProtoObject *var_obj_p = nil; + + var_id = (var_id == var_obj) ? var_id : var_obj; + var_id = (var_id == var_obj) ? var_id : var_obj_p; + + /* Ayers: Currently, the following test case passes for + technically the wrong reason (see below). + */ + var_obj_p = (var_id == var_obj) ? var_obj_p : var_obj; /* { dg-warning "distinct Objective-C types" } */ + var_obj_p = (var_id == var_obj) ? var_obj_p : var_id_p; + + /* Ayers: The first of the following test cases + should probably warn for var_obj_p = var_obj, + yet that would require extensive changes to + build_conditional_expr to create a tree with + multiple types that the assignment would have + to evaluate both versions for correct diagnostics. + */ + var_obj_p = (var_id == var_obj) ? var_id : var_obj; + var_obj_p = (var_id == var_obj) ? var_id : var_obj_p; + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-8.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-8.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-8.m (revision 309) @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +#include +#include + +union f +{ + char i; + double f1; + short t; +}; + +union g +{ + int i; +}; + + +int main(void) +{ + if (objc_sizeof_type (@encode (union f)) != sizeof(union f)) + abort (); + if (objc_alignof_type (@encode (union f)) != __alignof__(union f)) + abort (); + if (objc_sizeof_type (@encode (union g)) != sizeof(union g)) + abort (); + if (objc_alignof_type (@encode (union g)) != __alignof__(union g)) + abort (); + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-protocol-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-protocol-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-protocol-1.m (revision 309) @@ -0,0 +1,441 @@ +/* Check Class types */ +/* Author: David Ayers */ +/* { dg-do compile } */ + +#include +#include + +@protocol MyProto1 ++(void)doItClass1; +-(void)doItInstance1; +@end + +@protocol MyProto2 ++(void)doItClass2; +-(void)doItInstance2; +@end + +@interface MyClass1 +{ + Class isa; +} +@end +@implementation MyClass1 ++(void)doItClass1{} +-(void)doItInstance1{} +@end + +@interface MyClass2 : MyClass1 +@end +@implementation MyClass2 ++(void)doItClass2{} +-(void)doItInstance2{} +@end + +@interface MyClass3 +{ + Class isa; +} +@end +@interface MyClass4 : MyClass3 +@end + +/*----------------------------------------*/ + +Class cls = 0; +Class clsP1 = 0; +Class clsP2 = 0; + +void +testSimple(void) +{ + [cls doItClass1]; + [cls doItInstance1]; + [cls doItClass2]; + [cls doItInstance2]; + + [clsP1 doItClass1]; + [clsP1 doItInstance1]; /* { dg-warning "instead of" } */ + [clsP1 doItClass2]; /* { dg-warning "not found in protocol" } */ + [clsP1 doItInstance2]; /* { dg-warning "not found in protocol" } */ + + [clsP2 doItClass1]; /* { dg-warning "not found in protocol" } */ + [clsP2 doItInstance1]; /* { dg-warning "not found in protocol" } */ + [clsP2 doItClass2]; + [clsP2 doItInstance2]; /* { dg-warning "instead of" } */ + + [MyClass1 doItClass1]; + [MyClass1 doItInstance1]; + [MyClass1 doItClass2]; /* { dg-warning "may not respond to" } */ + [MyClass1 doItInstance2]; /* { dg-warning "may not respond to" } */ + + [MyClass2 doItClass1]; + [MyClass2 doItInstance1]; + [MyClass2 doItClass2]; + [MyClass2 doItInstance2]; /* { dg-warning "may not respond to" } */ + + [MyClass3 doItClass1]; /* { dg-warning "may not respond to" } */ + [MyClass3 doItInstance1]; /* { dg-warning "may not respond to" } */ + + [MyClass4 doItClass1]; + [MyClass4 doItInstance1]; /* { dg-warning "may not respond to" } */ +} + +/*----------------------------------------*/ +/* Protocols declared by categories */ + +@protocol MyProto3 ++(void)doItClass3; +-(void)doItInstance3; +@end +@protocol MyProto4 ++(void)doItClass4; +-(void)doItInstance4; +@end + +@interface MyClass1 (Category1) +@end +@interface MyClass2 (Category2) +@end + +void +testCategory(void) +{ + [cls doItClass3]; + [cls doItInstance3]; + [cls doItClass4]; + [cls doItInstance4]; + + [MyClass1 doItClass3]; + [MyClass1 doItInstance3]; + [MyClass1 doItClass4]; /* { dg-warning "may not respond" } */ + [MyClass1 doItInstance4]; /* { dg-warning "may not respond" } */ + + [MyClass2 doItClass3]; + [MyClass2 doItInstance3]; + [MyClass2 doItClass4]; + [MyClass2 doItInstance4]; /* { dg-warning "may not respond" } */ + +} + +/*----------------------------------------*/ +/* Inherited protocols declared by categories */ + +@protocol MyProto5 ++(void)doItClass5; +-(void)doItInstance5; +@end + +@protocol MyProto6 ++(void)doItClass6; +-(void)doItInstance6; +@end + +@interface MyClass1 (Category3) +@end +@interface MyClass2 (Category4) +@end + +Class clsP5 = 0; +Class clsP6 = 0; + +void +testCategoryInherited(void) +{ + [cls doItClass5]; + [cls doItInstance5]; + [cls doItClass6]; + [cls doItInstance6]; + + [clsP5 doItClass1]; + [clsP5 doItInstance1]; /* { dg-warning "instead of" } */ + [clsP5 doItClass2]; /* { dg-warning "not found in protocol" } */ + [clsP5 doItInstance2]; /* { dg-warning "not found in protocol" } */ + + [clsP6 doItClass1]; /* { dg-warning "not found in protocol" } */ + [clsP6 doItInstance1]; /* { dg-warning "not found in protocol" } */ + [clsP6 doItClass2]; + [clsP6 doItInstance2]; /* { dg-warning "instead of" } */ + + + [MyClass1 doItClass5]; + [MyClass1 doItInstance5]; + [MyClass1 doItClass6]; /* { dg-warning "may not respond" } */ + [MyClass1 doItInstance6]; /* { dg-warning "may not respond" } */ + + [MyClass2 doItClass5]; + [MyClass2 doItInstance5]; + [MyClass2 doItClass6]; + [MyClass2 doItInstance6]; /* { dg-warning "may not respond" } */ + +} + +/*----------------------------------------*/ +/* Forward declared root protocols */ + +@protocol FwProto; + +@interface MyClass1 (Forward) +@end + +Class clsP7 = 0; + +void +testForwardeDeclared1(void) +{ + [cls doItClass7]; /* { dg-warning "no .\\+doItClass7. method found" } */ + [cls doItInstance7]; /* { dg-warning "no .\\+doItInstance7. method found" } */ + + [clsP7 doItClass7]; /* { dg-warning "not found in protocol" } */ + /* { dg-warning "no .\\+doItClass7. method found" "" { target *-*-* } 189 } */ + [clsP7 doItInstance7]; /* { dg-warning "not found in protocol" } */ + /* { dg-warning "no .\\+doItInstance7. method found" "" { target *-*-* } 191 } */ + + [MyClass1 doItClass7]; /* { dg-warning "may not respond" } */ + [MyClass1 doItInstance7]; /* { dg-warning "may not respond" } */ + + [MyClass2 doItClass7]; /* { dg-warning "may not respond" } */ + [MyClass2 doItInstance7]; /* { dg-warning "may not respond" } */ + +} + +@protocol FwProto ++(void)doItClass7; +-(void)doItInstance7; +@end + +void +testForwardeDeclared2(void) +{ + [cls doItClass7]; + [cls doItInstance7]; + + [clsP7 doItClass7]; + [clsP7 doItInstance7]; /* { dg-warning "instead of" } */ + + [MyClass1 doItClass7]; + [MyClass1 doItInstance7]; + + [MyClass2 doItClass7]; + [MyClass2 doItInstance7]; +} + +/*----------------------------------------*/ +/* Inherited non root protocols */ + +@protocol MyProto8 ++(void)doItClass8; +-(void)doItInstance8; +@end + +@protocol MyProto9 ++(void)doItClass9; +-(void)doItInstance9; +@end + +@interface MyClass1 (InheritedNonRoot) +@end + +Class clsP8 = 0; +Class clsP9 = 0; + +void +testInheritedNonRoot(void) +{ + [cls doItClass8]; + [cls doItInstance8]; + [cls doItClass9]; + [cls doItInstance9]; + + [clsP8 doItClass8]; + [clsP8 doItInstance8]; /* { dg-warning "instead of" } */ + [clsP8 doItClass9]; /* { dg-warning "not found in protocol" } */ + [clsP8 doItInstance9]; /* { dg-warning "not found in protocol" } */ + + [clsP9 doItClass8]; + [clsP9 doItInstance8]; /* { dg-warning "instead of" } */ + [clsP9 doItClass9]; + [clsP9 doItInstance9]; /* { dg-warning "instead of" } */ + + [MyClass1 doItClass8]; + [MyClass1 doItInstance8]; + [MyClass1 doItClass9]; + [MyClass1 doItInstance9]; + + [MyClass2 doItClass8]; + [MyClass2 doItInstance8]; + [MyClass2 doItClass9]; + [MyClass2 doItInstance9]; + +} + +/*----------------------------------------*/ +/* Prototype mismatch */ + +@protocol MyOtherProto1 ++(id)doItClass1; +-(id)doItInstance1; +@end +@interface MyOtherClass1 +@end + +Class oclsP1; + +void +testPrototypeMismatch(void) +{ + id tmp1 = [oclsP1 doItClass1]; + id tmp2 = [oclsP1 doItInstance1]; /* { dg-warning "instead of" } */ + + [clsP1 doItClass1]; + [clsP1 doItInstance1]; /* { dg-warning "instead of" } */ +} + +id obj = nil; +id objP1 = nil; +id objP2 = nil; +id objP5 = nil; +int num = 0; +void *ptr = 0; + +MyClass1 *mc1 = nil; + +void +testComptypes(void) +{ + { /* id , id */ + objP1 == objP2; /* { dg-warning "lacks a cast" } */ + objP2 == objP1; /* { dg-warning "lacks a cast" } */ + + objP1 == objP5; + objP5 == objP1; + } + { /* id , SomeClass * */ + mc1 == objP1; + objP1 == mc1; + + mc1 == objP2; /* { dg-warning "lacks a cast" } */ + objP2 == mc1; /* { dg-warning "lacks a cast" } */ + } + { /* id , id */ + obj == objP1; + objP1 == obj; + } + { /* id , Class */ + cls == objP1; /* { dg-warning "lacks a cast" } */ + objP1 == cls; /* { dg-warning "lacks a cast" } */ + } + { /* id , non-ObjC */ + num == objP1; /* { dg-warning "between pointer" } */ + objP1 == num; /* { dg-warning "between pointer" } */ + + ptr == objP1; + objP1 == ptr; + } + { /* Class , Class */ + clsP1 == clsP2; /* { dg-warning "lacks a cast" } */ + clsP2 == clsP1; /* { dg-warning "lacks a cast" } */ + + clsP1 == clsP5; + clsP5 == clsP1; + } + { /* Class , SomeClass * */ + mc1 == clsP1; /* { dg-warning "lacks a cast" } */ + clsP1 == mc1; /* { dg-warning "lacks a cast" } */ + } + { /* Class , id */ + obj == clsP1; + clsP1 == obj; + } + { /* Class , Class */ + cls == clsP1; + clsP1 == cls; + } + { /* Class , non-ObjC */ + num == clsP1; /* { dg-warning "between pointer" } */ + clsP1 == num; /* { dg-warning "between pointer" } */ + + ptr == clsP1; + clsP1 == ptr; + } + { /* Class , id */ + clsP1 == objP1; /* { dg-warning "lacks a cast" } */ + objP1 == clsP1; /* { dg-warning "lacks a cast" } */ + } + + { /* id , id */ + objP1 = objP2; /* { dg-warning "does not conform" } */ + objP2 = objP1; /* { dg-warning "does not conform" } */ + + objP1 = objP5; + objP5 = objP1; /* { dg-warning "does not conform" } */ + } + { /* id , SomeClass * */ + mc1 = objP1; + objP1 = mc1; + + mc1 = objP2; /* { dg-warning "does not conform" } */ + objP2 = mc1; /* { dg-warning "does not implement" } */ + } + { /* id , id */ + obj = objP1; + objP1 = obj; + } + { /* id , Class */ + cls = objP1; /* { dg-warning "distinct Objective\\-C type" } */ + objP1 = cls; /* { dg-warning "distinct Objective\\-C type" } */ + } + { /* id , non-ObjC */ + num = objP1; /* { dg-warning "makes integer" } */ + objP1 = num; /* { dg-warning "makes pointer" } */ + + ptr = objP1; + objP1 = ptr; + } + { /* Class , Class */ + clsP1 = clsP2; /* { dg-warning "does not conform" } */ + clsP2 = clsP1; /* { dg-warning "does not conform" } */ + + clsP1 = clsP5; + clsP5 = clsP1; /* { dg-warning "does not conform" } */ + } + { /* Class , SomeClass * */ + /* These combinations should always elicit a warning. */ + mc1 = clsP1; /* { dg-warning "distinct Objective\\-C type" } */ + clsP1 = mc1; /* { dg-warning "distinct Objective\\-C type" } */ + + mc1 = clsP2; /* { dg-warning "distinct Objective\\-C type" } */ + clsP2 = mc1; /* { dg-warning "distinct Objective\\-C type" } */ + } + { /* Class , id */ + obj = clsP1; + clsP1 = obj; + } + { /* Class , Class */ + cls = clsP1; + clsP1 = cls; + } + { /* Class , non-ObjC */ + num = clsP1; /* { dg-warning "makes integer" } */ + clsP1 = num; /* { dg-warning "makes pointer" } */ + + ptr = clsP1; + clsP1 = ptr; + } + { /* Class , id */ + clsP1 = objP1; /* { dg-warning "distinct Objective\\-C type" } */ + objP1 = clsP1; /* { dg-warning "distinct Objective\\-C type" } */ + } +} + +int main () +{ + testSimple(); + testCategory(); + testCategoryInherited(); + return(0); +} + +/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ +/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ +/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-1.m (revision 309) @@ -0,0 +1,20 @@ +/* Redeclarations of class names. */ +/* { dg-do compile } */ + +typedef int foo; + +@class foo; /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-error "previous declaration of" "" { target *-*-* } 4 } */ + +typedef int bar; + +@interface bar +@end /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-error "previous declaration of" "" { target *-*-* } 9 } */ + +int glob; + +@implementation glob +@end /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-error "previous declaration of" "" { target *-*-* } 15 } */ +/* { dg-warning "annot find interface declaration" "" { target *-*-* } 18 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-6.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-6.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-6.m (revision 309) @@ -0,0 +1,38 @@ +/* Test assignments and comparisons involving category protocols. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ + +#include + +@protocol MyProtocol +- (void) method; +@end + +@interface MyClass +@end + +@interface MyClass (Addition) +- (void) method; +@end + +@interface MyOtherClass : MyClass +@end + +int main() +{ + id obj_p = nil; + MyClass *obj_cp = nil; + MyOtherClass *obj_cp2 = nil; + + obj_cp = obj_p; /* { dg-warning "distinct Objective\\-C type" } */ + obj_cp2 = obj_p; /* { dg-warning "distinct Objective\\-C type" } */ + obj_p = obj_cp; /* Ok */ + obj_p = obj_cp2; /* Ok */ + + if (obj_cp == obj_p) ; /* Ok */ + if (obj_cp2 == obj_p) ; /* Ok */ + if (obj_p == obj_cp) ; /* Ok */ + if (obj_p == obj_cp2) ; /* Ok */ + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-1.m (revision 309) @@ -0,0 +1,93 @@ +/* Fix and continue should not interfere with computation of + local (static) function addresses. */ +/* Author: Ziemowit Laski */ + +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-options "-mfix-and-continue" } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +@class MyTarget, MySet; + +int global_value = 0; + +@interface MyTargetBuildContext : Object +{ + MyTarget * _target; + unsigned _cacheInvalDisableCount; + BOOL _cacheInvalidationNeeded; + unsigned short _isCreatingDependencies:1; + unsigned short _isCreatingHeadermap:1; + unsigned short _haveAddedIdleTimeInvoc:1; + BOOL _hasSetUpBuildSettings; +} +- (id)initWithTarget:(MyTarget *)target; +- (MyTarget *)target; +@end + +@interface MyTargetBuildContext (PrivateMethods) ++ (MySet *)_headerFileExtensions; +@end + +@interface MyCountedSet: Object { +@public + int cardinality; +} +- (id)init; +- (id)sortedArrayUsingFunction:(int (*)(id, id, void *))comparator with:(int)value; +@end + +@implementation MyCountedSet +- (id)init { + cardinality = 5; + global_value = 17; + return self; +} +- (id)sortedArrayUsingFunction:(int (*)(id, id, void *))comparator with:(int)value { + if(value == comparator(self, self, self)) + return self; + return nil; +} +@end + +@implementation MyTargetBuildContext : Object +- (id)initWithTarget:(MyTarget *)target +{ + self = [super init]; + return self; +} +- (MyTarget *)target +{ + return _target; +} + +static int _MyCompareObjectsByDecreasingSetCount (id object1, id object2, MyCountedSet * countedSet) +{ + global_value = 5; + return countedSet->cardinality; +} ++ (MySet *)_headerFileExtensions +{ + MySet * _headerFileExtensions = 0; + return _headerFileExtensions; +} +- (void)_recomputeHeadermap +{ + MyCountedSet *set = [MyCountedSet new]; + int (*functionPointer)(id, id, void *) = (int (*)(id, id, void *))_MyCompareObjectsByDecreasingSetCount; + id result = [set sortedArrayUsingFunction:functionPointer with:5]; +} +@end + +int main(void) { + MyTargetBuildContext *ctx = [MyTargetBuildContext new]; + [ctx _recomputeHeadermap]; + if (global_value != 5) + abort(); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-2.m (revision 309) @@ -0,0 +1,5 @@ +/* Test for graceful handling of missing protocol declarations. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +void *protRef = @protocol(Missing); /* { dg-error "cannot find protocol declaration for .Missing." } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-10.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-10.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-10.m (revision 309) @@ -0,0 +1,40 @@ +/* Ensure that @try/@catch blocks do not mess with types of + local objects (other than their volatile bits). */ + +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@protocol Proto1 +- (int)meth1; +@end + +@protocol Proto2 +- (int)meth2; +@end + +@interface MyClass: Object { + int a; +} +- (int)meth2; +- (Object *)parm1: (id)p1 parm2: (id)p2; +@end + +MyClass *mc1, *mc2; + +@implementation MyClass +- (int)meth2 { + return a; +} +- (Object *)parm1: (id)p1 parm2: (id)p2 { + @try { + mc2 = p2; /* { dg-warning "type .id . does not conform to the .Proto2. protocol" } */ + } + @catch (id exc) { + return exc; + } + mc1 = p1; /* no warning here! */ + return self; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-11.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-11.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-11.m (revision 309) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +#include "../objc-obj-c++-shared/Object1.h" + +@interface Derived: Object +@end + +extern Object* foo(void); +static Derived *test(void) +{ + Derived *m = foo(); /* { dg-warning "initialization from distinct Objective\\-C type" } */ + + return m; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/pch.exp =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/pch.exp (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/pch.exp (revision 309) @@ -0,0 +1,63 @@ +# Copyright (C) 1997, 2002, 2003, 2007, 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite for precompiled header interaction, +# that uses the `dg.exp' driver. + +# Load support procs. +load_lib objc-dg.exp +load_lib dg-pch.exp +load_lib torture-options.exp + +# Initialize `dg'. +dg-init + +torture-init + +set-torture-options $DG_TORTURE_OPTIONS + +set old_dg_do_what_default "${dg-do-what-default}" + +global torture_without_loops +set mytorture [concat [list {-O0 -g}] $torture_without_loops] + +# Main loop. +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.m]] { + + # We don't try to use the loop-optimizing options, since they are highly + # unlikely to make any difference to PCH. However, we do want to + # add -O0 -g, since users who want PCH usually want debugging and quick + # compiles. + dg-flags-pch $subdir $test "-fgnu-runtime" $mytorture ".h" +} + +if [istarget "*-*-darwin*" ] { + foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.m]] { + global torture_without_loops + + # We don't try to use the loop-optimizing options, since they are highly + # unlikely to make any difference to PCH. However, we do want to + # add -O0 -g, since users who want PCH usually want debugging and quick + # compiles. + dg-flags-pch $subdir $test "-fnext-runtime" $mytorture ".h" + } +} + +set dg-do-what-default "$old_dg_do_what_default" + +# All done. +torture-finish +dg-finish Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.hs =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.hs (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.hs (revision 309) @@ -0,0 +1,4 @@ +@interface TestClass ++ (int) test; +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/pch/interface-1.m (revision 309) @@ -0,0 +1,14 @@ +#include "interface-1.h" + +@implementation TestClass ++ (int) test +{ + return 0; +} +@end + +int main (void) +{ + return [TestClass test]; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-3.m (revision 309) @@ -0,0 +1,27 @@ +/* Test warning for non-existent selectors. */ +/* This is the "-fgnu-runtime" variant of objc.dg/selector-1.m. */ +/* { dg-options "-Wselector" } */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +typedef struct objc_object { struct objc_class *class_pointer; } *id; +typedef const struct objc_selector *SEL; + +@interface Foo +- (void) foo; +- (void) bar; +@end + +@implementation Foo +- (void) bar +{ +} + +- (void) foo +{ + SEL a,b,c; + a = @selector(b1ar); + b = @selector(bar); +} +@end /* { dg-warning "creating selector for nonexistent method .b1ar." } */ + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-4.m (revision 309) @@ -0,0 +1,26 @@ +/* Check if class references (generated for the NeXT runtime) are appropriately + folded. */ +/* Author: Ziemowit Laski . */ +/* The ABI is different for m64 darwin so skip this test for now */ +/* { dg-do compile { target { *-*-darwin* && { ! lp64 } } } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-fgnu-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +typedef Object ObjectTypedef1; +typedef ObjectTypedef1 ObjectTypedef2; +@compatibility_alias ObjectAlias1 ObjectTypedef2; +@compatibility_alias ObjectAlias2 ObjectAlias1; +typedef ObjectAlias2 ObjectTypedef3; + +void foo(void) { + id obj = [Object new]; + obj = [ObjectTypedef1 new]; + obj = [ObjectTypedef2 new]; + obj = [ObjectTypedef3 new]; + obj = [ObjectAlias1 new]; + obj = [ObjectAlias2 new]; +} + +/* { dg-final { scan-assembler "_OBJC_CLASS_REFERENCES_0" } } */ +/* { dg-final { scan-assembler-not "_OBJC_CLASS_REFERENCES_1" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-8.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-8.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-8.m (revision 309) @@ -0,0 +1,14 @@ +/* Check if casting the receiver type causes method lookup to succeed. This was broken + in Objective-C++. */ +/* Contributed by Ziemowit Laski */ +/* { dg-do compile } */ + +@interface A +@end + +@interface B: A +- (void)f; +@end + +void g(A *p) { [(B *)p f]; } + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-1.m (revision 309) @@ -0,0 +1,17 @@ +/* Reject ivars with an unknown size. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do compile } */ + +struct unknownStruct; + +@interface ArrayTest +{ + short unknownSize[unknownValue]; /* { dg-error ".unknownValue. (undeclared|was not declared)" } */ + /* { dg-error "instance variable .unknownSize. has unknown size" "" { target *-*-* } 9 } */ + struct unknownStruct unknownObj; /* { dg-error "field .unknownObj. has incomplete type" } */ + /* { dg-error "instance variable .unknownObj. has unknown size" "" { target *-*-* } 11 } */ + long knownSize[3]; /* ok */ + char zeroSize[2 - 2]; /* ok (apparently) */ + int missingSize[]; /* { dg-error "instance variable .missingSize. has unknown size" } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/error-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/error-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/error-1.m (revision 309) @@ -0,0 +1,6 @@ +/* { dg-options "-w" } */ +/* { dg-do compile } */ +@implementation A ++B ++C {} /* { dg-error "expected '\{' before '\\\+' token" } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-1.m (revision 309) @@ -0,0 +1,24 @@ +/* Test errors for constant strings. */ +/* { dg-do compile } */ + +#ifdef __cplusplus +extern void baz(...); +#endif + +void foo() +{ + baz(@"hiya"); /* { dg-error "annot find interface declaration" } */ +} + +@interface NXConstantString +{ + void *isa; + char *str; + int len; +} +@end + +void bar() +{ + baz(@"howdah"); +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-1.m (revision 309) @@ -0,0 +1,25 @@ +/* Test for hiding of ivars by local variables. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface Sprite { + int a; +} +@end + +Sprite *glob; + +@interface blah +{ + Sprite* sprite; +} +@end + +@implementation blah +- (Sprite *)load +{ + Sprite *sprite = 0; + Sprite *glob = 0; /* ok */ + return sprite; /* { dg-warning "hides instance variable" } */ +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/next-runtime-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/next-runtime-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/next-runtime-1.m (revision 309) @@ -0,0 +1,19 @@ +/* Test that the correct version number (6) is set in the module descriptor + when compiling for the NeXT runtime. */ +/* Author: Ziemowit Laski */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface FooBar: Object +- (void)boo; +@end + +@implementation FooBar +- (void)boo { } +@end + +/* { dg-final { scan-assembler "L_OBJC_MODULES:\n\[ \t\]*\.long\t6\n" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler "L_OBJC_MODULES:\n\[ \t\]*\.quad\t6\n" { target { *-*-darwin* && { lp64 } } } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sizeof-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sizeof-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/sizeof-1.m (revision 309) @@ -0,0 +1,34 @@ +/* Check that the sizeof() operator works with ObjC classes and their aliases. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "" } */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Foo: Object { + int a, b; + float c, d; +} +@end + +@implementation Foo +@end + +typedef Object MyObject; +typedef struct Foo Foo_type; + +@compatibility_alias AliasObject Object; + +int main(void) { + CHECK_IF(sizeof(Foo) > sizeof(Object) && sizeof(Object) > 0); + CHECK_IF(sizeof(Foo) == sizeof(Foo_type)); + CHECK_IF(sizeof(Object) == sizeof(MyObject)); + CHECK_IF(sizeof(Object) == sizeof(AliasObject)); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-dealloc-2.m (revision 309) @@ -0,0 +1,46 @@ +/* Check for warnings about missing [super dealloc] calls. */ +/* Author: Ziemowit Laski */ + +/* { dg-do compile } */ + +@interface Foo { + void *isa; +} +- (void) dealloc; +- (void) some_other; +@end + +@interface Bar: Foo { + void *casa; +} +- (void) dealloc0; +@end + +@interface Baz: Bar { + void *usa; +} +- (void) dealloc; +@end + +@implementation Foo +- (void) dealloc { + isa = 0; /* Should not warn here. */ +} +- (void) some_other { + isa = (void *)-1; +} +@end + +@implementation Bar +- (void) dealloc0 { + casa = 0; + [super some_other]; /* Should not warn here. */ +} +@end + +@implementation Baz +- (void) dealloc { + usa = 0; + [super dealloc0]; +} /* { dg-warning "method possibly missing a .super dealloc. call" } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-5.m (revision 309) @@ -0,0 +1,27 @@ +/* Positive test case for constant string layout. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-options "-fconstant-string-class=MyConstantString" } */ +/* { dg-do compile } */ + +@interface MyBase { + const char *p; +} +@end + +@interface MyConstantString: MyBase { + union { + void *u; + unsigned char *c; + } _contents; + unsigned int _count; +} +@end + +/* The NeXT runtime initializes the 'isa' pointer of string constants at + compile time. */ +#ifdef __NEXT_RUNTIME__ +extern void *_MyConstantStringClassReference; +#endif + +MyConstantString *str = @"Hello"; Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-3.m (revision 309) @@ -0,0 +1,26 @@ +/* Crash due to descriptionFor(Instance|Class)Method applied to + a protocol with no instance/class methods respectively. + Problem report and original fix by richard@brainstorm.co.uk. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ +#include "../objc-obj-c++-shared/Protocol1.h" +#include "../objc-obj-c++-shared/Object1.h" +#include + +@protocol NoInstanceMethods ++ testMethod; +@end + +@protocol NoClassMethods +- testMethod; +@end + +int +main() +{ +[@protocol(NoInstanceMethods) descriptionForInstanceMethod: @selector(name)]; +[@protocol(NoInstanceMethods) descriptionForClassMethod: @selector(name)]; +[@protocol(NoClassMethods) descriptionForInstanceMethod: @selector(name)]; +[@protocol(NoClassMethods) descriptionForClassMethod: @selector(name)]; +return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-13.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-13.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-13.m (revision 309) @@ -0,0 +1,78 @@ +/* Test if instance methods of root classes are used as class methods, if no + "real" methods are found. For receivers of type 'id' and 'Class', all + root classes must be considered. */ +/* Author: Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include + +#ifdef __NEXT_RUNTIME__ +#define OBJC_GETCLASS objc_getClass +#else +#define OBJC_GETCLASS objc_get_class +#endif + +extern void abort(void); +extern int strcmp(const char *, const char *); +#define CHECK_IF(expr) if(!(expr)) abort() + +@protocol Proto +- (const char *) method4; +@end + +@interface Root +{ Class isa; } ++ (const char *) method2; +@end + +@interface Derived: Root +- (const char *) method1; +- (const char *) method2; +- (const char *) method3; +@end + +@interface Root (Categ) +- (const char *) method3; +@end + +@implementation Root (Categ) +- (const char *) method3 { return "Root(Categ)::-method3"; } +- (const char *) method4 { return "Root(Categ)::-method4"; } +@end + +@implementation Derived +- (const char *) method1 { return "Derived::-method1"; } +- (const char *) method2 { return "Derived::-method2"; } +- (const char *) method3 { return "Derived::-method3"; } +@end + +@implementation Root +#ifdef __NEXT_RUNTIME__ ++ initialize { return self; } +#endif +- (const char *) method1 { return "Root::-method1"; } ++ (const char *) method2 { return "Root::+method2"; } +@end + +int main(void) +{ + Class obj = OBJC_GETCLASS("Derived"); + + /* None of the following should elicit compiler-time warnings. */ + + CHECK_IF(!strcmp([Root method1], "Root::-method1")); + CHECK_IF(!strcmp([Root method2], "Root::+method2")); + CHECK_IF(!strcmp([Root method3], "Root(Categ)::-method3")); + CHECK_IF(!strcmp([Root method4], "Root(Categ)::-method4")); + CHECK_IF(!strcmp([Derived method1], "Root::-method1")); + CHECK_IF(!strcmp([Derived method2], "Root::+method2")); + CHECK_IF(!strcmp([Derived method3], "Root(Categ)::-method3")); + CHECK_IF(!strcmp([Derived method4], "Root(Categ)::-method4")); + CHECK_IF(!strcmp([obj method1], "Root::-method1")); + CHECK_IF(!strcmp([obj method2], "Root::+method2")); + CHECK_IF(!strcmp([obj method3], "Root(Categ)::-method3")); + CHECK_IF(!strcmp([obj method4], "Root(Categ)::-method4")); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-qual-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-qual-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-qual-1.m (revision 309) @@ -0,0 +1,53 @@ +/* Check that protocol qualifiers are compiled and encoded properly. */ +/* Author: Ziemowit Laski */ +/* { dg-options "" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Protocol1.h" +#ifndef __NEXT_RUNTIME__ +#include +#endif + +/* The encoded parameter sizes will be rounded up to match pointer alignment. */ +#define ROUND(s,a) (a * ((s + a - 1) / a)) +#define aligned_sizeof(T) ROUND(sizeof(T),__alignof(void *)) + +extern int sscanf(const char *str, const char *format, ...); +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +@protocol Retain ++ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2; +- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2; +@end + +@interface Foo ++ (oneway void)retainArgument:(out bycopy id)arg with:(in signed char **)arg2; +@end + +@implementation Foo ++ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2 { } +- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2 { return nil; } +@end + +Protocol *proto = @protocol(Retain); +struct objc_method_description *meth; +unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7; + +static void scan_initial(const char *pattern) { + totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1; + sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6, &offs7); + CHECK_IF(!offs0 && offs1 == aligned_sizeof(id) && offs2 == offs1 + aligned_sizeof(SEL) && totsize >= offs2); +} + +int main(void) { + meth = [proto descriptionForInstanceMethod: @selector(address:with:)]; + scan_initial("O@%u@%u:%uRN@%uo^^S%u"); + CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 + aligned_sizeof(unsigned)); + meth = [proto descriptionForClassMethod: @selector(retainArgument:with:)]; + scan_initial("Vv%u@%u:%uoO@%un^*%u"); + CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 + aligned_sizeof(char **)); + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-9.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-9.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-9.m (revision 309) @@ -0,0 +1,25 @@ +/* Test if ObjC constant strings get placed in the correct section. */ +/* Contributed by Ziemowit Laski */ + +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface NSConstantString: Object { + char *cString; + unsigned int len; +} +@end + +#ifndef NEXT_OBJC_USE_NEW_INTERFACE +extern struct objc_class _NSConstantStringClassReference; +#else +Class _NSConstantStringClassReference; +#endif + +const NSConstantString *appKey = @"MyApp"; + +/* { dg-final { scan-assembler ".section __OBJC, __cstring_object" } } */ +/* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler ".quad\t__NSConstantStringClassReference\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-17.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-17.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-17.m (revision 309) @@ -0,0 +1,26 @@ +/* Test for spurious "may or may not return a value" warnings. */ + +/* { dg-do compile } */ +/* { dg-options "-Wreturn-type -Wextra" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Foo: Object +- (id) meth1; +- (void) meth2; +@end + +extern int bar; + +@implementation Foo +- (id) meth1 { + if (bar) + return [Object new]; + return; /* { dg-warning "'return' with no value, in function returning non-void" } */ +} +- (void) meth2 { + if (!bar) + return; + bar = 0; +} /* { dg-bogus "'return' with no value, in function returning non-void" } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bad-receiver-type.m (revision 309) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +@interface A + +- (void)test; + +@end + +extern int foo(); + +void baz() +{ + [foo test]; /* { dg-warning "invalid receiver type" } */ + /* { dg-error "cannot convert to a pointer type" "" { target *-*-* } 13 } */ +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-1.m (revision 309) @@ -0,0 +1,19 @@ +/* Test that compiling for the GNU runtime works (regardless of + the system runtime used). */ +/* Author: Ziemowit Laski */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +#include + +@interface FooBar: Object +- (void)boo; +@end + +int main () +{ + id fooBarInst = [[FooBar alloc] init]; + [fooBarInst boo]; + return 0; +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/naming-2.m (revision 309) @@ -0,0 +1,12 @@ +/* Test for collision of @interfaces with global vars. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface Foo +@end +float Foo; /* { dg-error "parse error|syntax error|expected" } */ + +double Bar; +@interface Bar +@end /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-error "previous declaration of" "" { target *-*-* } 9 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/zero-link-3.m (revision 309) @@ -0,0 +1,28 @@ +/* Check that the '-fzero-link' flag doesn't prevent messaging from working. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-options "-fzero-link" } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +//#import + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object ++ (int) getValue; +@end + +@implementation Base ++ (int) getValue { return 1593; } +@end + +int main(void) { + int val = [Base getValue]; + CHECK_IF(val == 1593); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/image-info.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/image-info.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/image-info.m (revision 309) @@ -0,0 +1,35 @@ +/* Check if the '-freplace-objc-classes' option causes the + __OBJC,__image_info section to be emitted. This is only + usable on MacOS X 10.3 and later. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-do compile { target { *-*-darwin* } } } */ +/* { dg-options "-freplace-objc-classes" } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +extern void abort(void); + +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object { +@public + int a; + float b; + char c; +} +- init; +@end + +@implementation Base +- init { + [super init]; + a = 123; + b = 1.23; + c = 'c'; + return self; +} +@end + +/* { dg-final { scan-assembler "\t.section __OBJC, __image_info.*\n\t.align.*\nL_OBJC_IMAGE_INFO.*:\n\t.long\t0\n\t.long\t1" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-11.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-11.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-11.m (revision 309) @@ -0,0 +1,43 @@ +/* { dg-do run } */ + +extern void abort (void); +extern int strcmp (const char *, const char *); + +typedef struct Vec { + double xv[10], yv[5]; + float fscal; + int z; +} xyz_t ; + +typedef struct { + float fscalar; + double dscalar; + xyz_t dv; + int iscalar; + long ln; + long long lln; +} anonymous; + +const char *enc = @encode(xyz_t); +const char *enc2 = @encode(anonymous); + +#ifdef __LP64__ +#define L "q" +#else +#define L "l" +#endif + +int main(void) { + const char *encode = @encode(long); + + if (strcmp (encode, L)) + abort (); + + if (strcmp (enc, "{Vec=[10d][5d]fi}")) + abort (); + + if (strcmp (enc2, "{?=fd{Vec=[10d][5d]fi}i" L "q}")) + abort (); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-12.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-12.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-12.m (revision 309) @@ -0,0 +1,16 @@ +/* { dg-options "-Wall -funit-at-a-time" } */ +/* { dg-do compile } */ +/* PR objc/27438, make sure that the decl produced by the front-end + does not cause a warning to be produced. */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +@interface NXConstantString +{ + void *isa; + const char * const nxcsptr; + const unsigned int nxcslen; +} +@end +NXConstantString *a = @"NSInconsistentArchiveException"; /* { dg-bogus "defined but not used" } */ + + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fwd-proto-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fwd-proto-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fwd-proto-1.m (revision 309) @@ -0,0 +1,29 @@ +/* Test forward-decls for @protocols. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +/* One-line substitute for objc/objc.h */ +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +@protocol Bar; +@protocol Boo; + +@protocol Foo +- (id )someMethod; +- (id )anotherMethod; /* { dg-error "annot find protocol declaration" } */ +@end + +@protocol Bar +- (id )someOtherMethod; +- (id )anotherMethod; /* { dg-error "annot find protocol declaration" } */ +- (id )yetAnotherMethod; +@end + +/* The following worthy test is stubbed out until we can get the + harness to match correctly on the "compilation terminated" message + when running on GNU/Linux. sts 2001-08-01 */ +#if 0 +@protocol Boo /* { /*dg*/-error "has circular dependency" } */ +@end +#endif + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-1.m (revision 309) @@ -0,0 +1,83 @@ +/* Check if bitfield ivars are inherited correctly (i.e., without + being "promoted" to ints). */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include + +extern void abort(void); + +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object +{ + int full; + int full2: 32; + int _refs: 8; + int field2: 3; + unsigned f3: 8; + short cc; + unsigned g: 16; + int r2: 8; + int r3: 8; + int r4: 2; + int r5: 8; + char c; +} +- (void)setValues; +@end + +@interface Derived: Base +{ + char d; + int _field3: 6; +} +- (void)checkValues; +@end + +@implementation Base +-(void)setValues { + full = 1; + full2 = 2; + _refs = 3; + field2 = 1; + f3 = 6; + cc = 7; + g = 8; + r2 = 9; + r3 = 10; + r4 = 1; + r5 = 12; + c = 13; +} +@end + +@implementation Derived +-(void)checkValues { + CHECK_IF(full == 1); + CHECK_IF(full2 == 2); + CHECK_IF(_refs == 3); + CHECK_IF(field2 == 1); + CHECK_IF(f3 == 6); + CHECK_IF(cc == 7); + CHECK_IF(g == 8); + CHECK_IF(r2 == 9); + CHECK_IF(r3 == 10); + CHECK_IF(r4 == 1); + CHECK_IF(r5 == 12); + CHECK_IF(c == 13); +} +@end + +int main(void) { + Derived *obj = [[Derived alloc] init]; + + [obj setValues]; + [obj checkValues]; + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/undeclared-selector.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/undeclared-selector.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/undeclared-selector.m (revision 309) @@ -0,0 +1,48 @@ +/* Test for -Wundeclared-selector. */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +/* { dg-options "-Wundeclared-selector" } */ + +#include + +@interface MyClass + ++ (void) methodA; +- (void) methodB; ++ (void) methodD; +- (void) methodF; + +@end + +@implementation MyClass + ++ (void) methodA {} +- (void) methodB {} ++ (void) methodD +{ + SEL d = @selector(methodD); /* Ok */ + SEL e = @selector(methodE); /* { dg-warning "undeclared selector" } */ +} + +- (void) methodE +{ + SEL e = @selector(methodE); /* Ok */ +} + +- (void) methodF +{ + SEL e = @selector(methodE); /* Ok */ +} + +@end + +int main (void) +{ + SEL a = @selector(methodA); /* Ok */ + SEL b = @selector(methodB); /* Ok */ + SEL c = @selector(methodC); /* { dg-warning "undeclared selector" } */ + SEL d = @selector(methodD); /* Ok */ + SEL e = @selector(methodE); /* Ok */ + return 0; + +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-5.m (revision 309) @@ -0,0 +1,113 @@ +/* Check ObjC class layout follows the ABI (informally) + set in the past. ObjC structs must be laid out as if + all ivars, including those inherited from superclasses, + were defined at once (i.e., any padding introduced for + superclasses should be removed). */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "-Wpadded" } */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include +#include + +#define CHECK_IF(expr) if(!(expr)) abort() + +enum Enum { zero, one, two, three, four }; + +@interface Base: Object { +@public + unsigned a: 2; + int b: 3; + enum Enum c: 4; + unsigned d: 5; +} /* { dg-warning "padding struct size to alignment boundary" } */ +@end + +struct Base_0 { + Class isa; + unsigned a: 2; + int b: 3; + enum Enum c: 4; + unsigned d: 5; +}; /* { dg-warning "padding struct size to alignment boundary" } */ + +@interface Derived: Base { +@public + signed e: 5; + unsigned f: 4; + enum Enum g: 3; +} /* { dg-warning "padding struct size to alignment boundary" } */ +@end + +struct Derived_0 { + Class isa; + unsigned a: 2; + int b: 3; + enum Enum c: 4; + unsigned d: 5; + signed e: 5; + int f: 4; + enum Enum g: 3; +}; /* { dg-warning "padding struct size to alignment boundary" } */ + +@interface Leaf: Derived { +@public + signed h: 2; +} /* { dg-warning "padding struct size to alignment boundary" } */ +@end + +struct Leaf_0 { + Class isa; + unsigned a: 2; + int b: 3; + enum Enum c: 4; + unsigned d: 5; + signed e: 5; + unsigned f: 4; + enum Enum g: 3; + signed h: 2; +}; /* { dg-warning "padding struct size to alignment boundary" } */ + +/* Note that the semicolon after @defs(...) is optional. */ + +typedef struct { @defs(Base) } Base_t; /* { dg-warning "padding struct size to alignment boundary" } */ +typedef struct { @defs(Derived); } Derived_t; /* { dg-warning "padding struct size to alignment boundary" } */ +typedef struct { @defs(Leaf); } Leaf_t; /* { dg-warning "padding struct size to alignment boundary" } */ + +int main(void) +{ + struct Leaf_0 l_0; + Leaf *l = (Leaf *)&l_0; + Leaf_t *l_t = (Leaf_t *)&l_0; + + CHECK_IF(sizeof(Base_t) == sizeof(Base)); + CHECK_IF(sizeof(Derived_t) == sizeof(Derived)); + CHECK_IF(sizeof(Leaf_t) == sizeof(Leaf)); + + CHECK_IF(sizeof(struct Base_0) == sizeof(Base)); + CHECK_IF(sizeof(struct Derived_0) == sizeof(Derived)); + CHECK_IF(sizeof(struct Leaf_0) == sizeof(Leaf)); + + l_0.isa = (Class)0; + l_0.a = 3; + l_0.b = 0; + l_0.c = three; + l_0.d = 31; + l_0.e = 0; + l_0.f = 15; + l_0.g = zero; + l_0.h = -2; + + CHECK_IF(!l_t->isa); + CHECK_IF(l->a == 3 && l_t->a == 3); + CHECK_IF(!l->b && !l_t->b); + CHECK_IF(l->c == three && l_t->c == three); + CHECK_IF(l->d == 31 && l_t->d == 31); + CHECK_IF(!l->e && !l_t->e); + CHECK_IF(l->f == 15 && l_t->f == 15); + CHECK_IF(l->g == zero && l_t->g == zero); + CHECK_IF(l->h == -2 && l_t->h == -2); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/static-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/static-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/static-1.m (revision 309) @@ -0,0 +1,33 @@ +/* Test out static (non-heap) allocations of ObjC class instances. + These should elicit errors. */ +/* Developed by Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface Object { + struct objc_class *isa; +} +@end + +@compatibility_alias MyObject Object; + +@interface Foo: Object { + int a; + Object *b; + Object c; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ +} +@end + +@compatibility_alias MyFoo Foo; + +typedef Foo FooAlias1; +typedef FooAlias1 FooAlias2; +typedef Object ObjectAlias1; +typedef struct Object ObjectAlias2; +Object staticObject1; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ +struct Object staticObject2; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ +static ObjectAlias1 staticObject3; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ +FooAlias1 staticFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ +extern FooAlias2 externFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ +static Foo staticFoo2; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ +MyObject staticMyObject1; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ +MyFoo staticMyFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dg.exp =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dg.exp (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/dg.exp (revision 309) @@ -0,0 +1,41 @@ +# GCC Objective-C testsuite that uses the `dg.exp' driver. +# Copyright (C) 1997, 2001, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Load support procs. +load_lib objc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[m\]]] \ + "-fgnu-runtime" $DEFAULT_CFLAGS + +# darwin targets can also run code with the NeXT runtime. +if [istarget "*-*-darwin*" ] { +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[m\]]] \ + "-fnext-runtime" $DEFAULT_CFLAGS +} + +# All done. +dg-finish Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-1.m (revision 309) @@ -0,0 +1,24 @@ +/* Test if the Objective-C @encode machinery distinguishes between + 'BOOL *' (which should be encoded as a pointer to BOOL) and 'char *' (which + should be encoded as '*'). This is somewhat tricky wrt the NeXT runtime, + where we have 'typedef char BOOL'. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-options "-fnext-runtime" } */ +#include +#include +#include + +int main(void) { + const char *BOOL_ptr = @encode(BOOL *); + const char *BOOL_ = @encode(BOOL); + const char *char_ptr = @encode(char *); + + if(*BOOL_ptr != '^' || strcmp(BOOL_ptr + 1, BOOL_)) + abort(); + + if(strcmp(char_ptr, "*")) + abort(); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-1.m (revision 309) @@ -0,0 +1,41 @@ +/* Test if the compiler accepts @throw / @try..@catch..@finally syntax. */ +/* Developed by Ziemowit Laski . */ +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include +#include + +@interface Frob: Object +@end + +@implementation Frob: Object +@end + +static int exc_control = 0; + +int proc() { + if(exc_control) { + printf ("Throwing (%d)... ", exc_control); + @throw [Frob new]; + } + return 1; +} + +int foo() +{ + @try { + return proc(); + } + @catch (Frob* ex) { + if(exc_control > 1) { + printf("Rethrowing (%d)... ", exc_control); + @throw; + } + return 0; + } + @finally { + printf("In @finally block (%d)... ", exc_control); + } +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/symtab-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/symtab-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/symtab-1.m (revision 309) @@ -0,0 +1,27 @@ +/* Check if the objc_symtab descriptor is being laid out correctly. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-do compile { target { *-*-darwin* } } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Base: Object +- (void)setValues; +@end + +@interface Derived: Base +- (void)checkValues; +@end + +@implementation Base +-(void)setValues { } +@end + +@implementation Derived +-(void)checkValues { } +@end + +/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.word\t2\n\t.word\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { i?86-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.long\t0\n\t.long\t0\n\t.short\t2\n\t.short\t0\n\t.long\tL_OBJC_CLASS_Derived.*\n\t.long\tL_OBJC_CLASS_Base.*\n" { target { powerpc-*-darwin* && { ! lp64 } } } } } */ +/* { dg-final { scan-assembler "L_OBJC_SYMBOLS.*:\n\t.quad\t0\n\t.long\t0\n\t.space 4\n\t.word\t2\n\t.word\t0\n\t.space 4\n\t.quad\tL_OBJC_CLASS_Derived.*\n\t.quad\tL_OBJC_CLASS_Base.*\n" { target { *-*-darwin* && { lp64 } } } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-5.m (revision 309) @@ -0,0 +1,76 @@ +/* Check if array arguments of ObjC methods are decayed to pointer types + in a proper fashion: + (1) The _encodings_ for the array arguments should remain to be '[4i]' and + such, since this has been the case since at least gcc 3.3. + (2) However, when building the static C functions out of ObjC method signatures, + we need to decay the arrays into pointers (as C does). + (3) If array size is not known (e.g., 'int a[]'), then the type shall be + encoded as a pointer. */ + +/* Contributed by Alexander Malmberg */ + +#include "../objc-obj-c++-shared/Object1.h" +#include "../objc-obj-c++-shared/next-mapping.h" +#include +#include +#define CHECK_IF(expr) if(!(expr)) abort() + +#ifdef __NEXT_RUNTIME__ +#define METHOD Method +#else +#include +#define METHOD Method_t +#define method_get_types(M) (M)->method_types +#endif + +@interface Test : Object +{ float j; } +-(void) test2: (int [5])a with: (int [])b; +-(id) test3: (Test **)b; /* { dg-message "previous declaration of .\\-\\(id\\)test3:\\(Test \\*\\*\\)b." } */ +@end + +@implementation Test +-(void) test2: (int [5])a with: (int [])b +{ + a[3] = *b; +} +-(void) test3: (Test [3][4])b { /* { dg-warning "conflicting types for .\\-\\(void\\)test3:\\(Test \\\[3\\\]\\\[4\\\]\\)b." } */ +} +@end + +int bb[6] = { 0, 1, 2, 3, 4, 5 }; +int *b = bb; +Test *cc[4]; +Test **c = cc; + +int offs1, offs2, offs3, offs4, offs5, offs6; + +int main(int argc, char **argv) +{ + Class testClass = objc_get_class("Test"); + METHOD meth; + + cc[0] = [Test new]; + CHECK_IF (bb[3] == 3); + [*c test2: b with: bb + 4]; + CHECK_IF (bb[3] == 4); + bb[3] = 0; + [*c test2: bb with: bb + 5]; + CHECK_IF (bb[3] == 5); + + meth = class_get_instance_method(testClass, @selector(test2:with:)); + offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = -1; + sscanf(method_get_types(meth), "v%d@%d:%d[%di]%d^i%d", &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6); + CHECK_IF (!offs2 && offs4 == 5 && offs3 > 0); + CHECK_IF (offs5 == 2 * offs3 && offs6 == 3 * offs3 && offs1 == 4 * offs3); + + meth = class_get_instance_method(testClass, @selector(test3:)); + offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = -1; + sscanf(method_get_types(meth), "v%d@%d:%d[%d[%d{Test=#f}]]%d", &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6); + CHECK_IF (!offs2 && offs4 == 3 && offs5 == 4 && offs3 > 0); + CHECK_IF (offs6 == 2 * offs3 && offs1 == 3 * offs3); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/va-meth-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/va-meth-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/va-meth-1.m (revision 309) @@ -0,0 +1,73 @@ +/* Based on objc/execute/va_method.m, by Nicola Pero */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +#include +#include + +/* Test methods with "C-style" trailing arguments, with or without ellipsis. */ + +@interface MathClass: Object +/* sum positive numbers; -1 ends the list */ ++ (int) sum: (int)firstNumber, int secondNumber, ...; ++ (int) prod: (int) firstNumber, int secondNumber, int thirdNumber; ++ (int) minimum: (int) firstNumber, ...; +@end + +@implementation MathClass ++ (int) sum: (int)firstNumber, int secondNumber, ... +{ + va_list ap; + int sum = 0, number = 0; + + va_start (ap, secondNumber); + number = firstNumber + secondNumber; + + while (number >= 0) + { + sum += number; + number = va_arg (ap, int); + } + + va_end (ap); + + return sum; +} ++ (int) prod: (int) firstNumber, int secondNumber, int thirdNumber { + return firstNumber * secondNumber * thirdNumber; +} ++ (int) minimum: (int)firstNumber, ... +{ + va_list ap; + int minimum = 999, number = 0; + + va_start (ap, firstNumber); + number = firstNumber; + + while (number >= 0) + { + minimum = (minimum < number ? minimum: number); + number = va_arg (ap, int); + } + + va_end (ap); + + return minimum; +} +@end + +int main (void) +{ + if ([MathClass sum: 1, 2, 3, 4, 5, -1] != 15) + abort (); + if ([MathClass prod: 4, 5, 6] != 120) + abort (); + if ([MathClass minimum: 17, 9, 133, 84, 35, -1] != 9) + abort (); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-3.m (revision 309) @@ -0,0 +1,63 @@ +/* Test assignments and comparisons between protocols (obscure case). */ +/* Author: Nicola Pero . */ +/* { dg-do compile } */ +#include + +@protocol MyProtocolA +- (void) methodA; +@end + +@protocol MyProtocolB +- (void) methodB; +@end + +@protocol MyProtocolAB +@end + +@protocol MyProtocolAC +- (void) methodC; +@end + +int main() +{ + id obj_a = nil; + id obj_b = nil; + id obj_ab = nil; + id obj_ac = nil; + + obj_a = obj_b; /* { dg-warning "does not conform" } */ + obj_a = obj_ab; /* Ok */ + obj_a = obj_ac; /* Ok */ + + obj_b = obj_a; /* { dg-warning "does not conform" } */ + obj_b = obj_ab; /* Ok */ + obj_b = obj_ac; /* { dg-warning "does not conform" } */ + + obj_ab = obj_a; /* { dg-warning "does not conform" } */ + obj_ab = obj_b; /* { dg-warning "does not conform" } */ + obj_ab = obj_ac; /* { dg-warning "does not conform" } */ + + obj_ac = obj_a; /* { dg-warning "does not conform" } */ + obj_ac = obj_b; /* { dg-warning "does not conform" } */ + obj_ac = obj_ab; /* { dg-warning "does not conform" } */ + + if (obj_a == obj_b) ; /* { dg-warning "lacks a cast" } */ + if (obj_b == obj_a) ; /* { dg-warning "lacks a cast" } */ + + if (obj_a == obj_ab) ; /* Ok */ + if (obj_ab == obj_a) ; /* Ok */ /* Spurious 2.95.4 warning here */ + + if (obj_a == obj_ac) ; /* Ok */ + if (obj_ac == obj_a) ; /* Ok */ /* Spurious 2.95.4 warning here */ + + if (obj_b == obj_ab) ; /* Ok */ + if (obj_ab == obj_b) ; /* Ok */ /* Spurious 2.95.4 warning here */ + + if (obj_b == obj_ac) ; /* { dg-warning "lacks a cast" } */ + if (obj_ac == obj_b) ; /* { dg-warning "lacks a cast" } */ + + if (obj_ab == obj_ac) ; /* { dg-warning "lacks a cast" } */ + if (obj_ac == obj_ab) ; /* { dg-warning "lacks a cast" } */ + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-5.m (revision 309) @@ -0,0 +1,27 @@ +/* Check that the compiler does correctly complain about + exceptions being caught by previous @catch blocks. */ +/* Force the use of NeXT runtime to see that we don't ICE after + generating the warning message. */ + +/* { dg-do compile } */ +/* { dg-options "-Wall -fobjc-exceptions" } */ + +@interface Exception +@end + +@interface FooException : Exception +@end + +extern void foo(); + +void test() +{ + @try { + foo(); + } + @catch (Exception* e) { /* { dg-warning "earlier handler" } */ + } + @catch (FooException* fe) { /* { dg-warning "will be caught" } */ + } +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/super-class-3.m (revision 309) @@ -0,0 +1,46 @@ +/* Ensure that the compiler does not emit spurious extern declarations named '_Foo', where 'Foo' + is an ObjC class name. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +#include +#define CHECK_IF(expr) if(!(expr)) abort() + +@interface _Child: Object ++ (int) flashCache; +@end + +@interface Child: _Child ++ (int) flushCache1; +@end + +@interface Child (Categ) ++ (int) flushCache2; +@end + +int _Object = 23; /* Should not conflict with @interface Object. */ + +@implementation _Child ++ (int) flashCache { return 12 + _Object; } +@end + +@implementation Child ++ (int) flushCache1 { return 7 + [super flashCache]; } +@end + +@implementation Child (Categ) ++ (int) flushCache2 { return 9 + [super flashCache]; } +@end + +int main(void) { + CHECK_IF([_Child flashCache] == 35); + CHECK_IF([Child flushCache1] == 42); + CHECK_IF([Child flushCache2] == 44); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-9.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-9.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/encode-9.m (revision 309) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +/* There was an ICE due to diving by zero in the objc front-end. */ + +struct f +{ + int i; + struct{} g[4]; + int tt; +}; + +char *e = @encode(struct f); Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-7.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-7.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/comp-types-7.m (revision 309) @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* We used to ICE because we removed the cast to List_linked* + in -[ListIndex_linked next]. */ + +@interface List +{ +@public + int firstLink; +} +@end + +@interface ListIndex_linked +{ +@public + List *collection; + int link; +} +@end + +@interface List_linked: List +@end + +@implementation List +@end + +@implementation ListIndex_linked +- next +{ + link = ((List_linked*)collection)->firstLink; +} +@end + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/class-2.m (revision 309) @@ -0,0 +1,14 @@ +/* Test super classes. */ +/* { dg-do compile } */ + +@interface supclass1 +@end + +@interface supclass2 +@end + +@interface class1 : supclass1 +@end + +@implementation class1 : supclass2 /* { dg-error "conflicting super class name" } */ +@end /* { dg-error "previous declaration" "" { target *-*-* } 13 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-9.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-9.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/try-catch-9.m (revision 309) @@ -0,0 +1,24 @@ +/* Check that taking the address of a local variable marked 'volatile' + by the compiler does not generate untoward errors. */ +/* Developed by Ziemowit Laski . */ + +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +void foo (int *arg1, int *arg2) +{ + *arg1 = *arg2; +} + +void bar (int arg) { + int rcvr; + + @try { + rcvr = arg; + } + @finally { + int *rcvr0 = &rcvr; + foo (rcvr0, &arg); + } +} + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/call-super-1.m (revision 309) @@ -0,0 +1,78 @@ +/* Check if objc_super stack variables are created correctly (and + not clobbered by other values). */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "-std=c99" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); + +#define CHECK_IF(expr) if(!(expr)) abort(); + +typedef struct _Point { + float x; + float y; +} Point; + +Point MakePoint ( float x , float y ) { + Point p; + p.x = x; + p.y = y; + return p; +} + +@interface Base: Object +- ( void ) translateOriginToPoint : ( Point ) translation ; +@end + +@interface Derived : Base +- ( void ) scrollToPoint : ( Point ) newOrigin ; +- ( void ) translateOriginToPoint : ( Point ) translation ; +@end + +int blort; +float result; + +@implementation Base +- ( void ) translateOriginToPoint : ( Point ) translation { + result = translation.x + translation.y; +} +@end + +@implementation Derived +- ( void ) scrollToPoint : ( Point ) newOrigin { + float transDeltaX =newOrigin.x, transDeltaY =newOrigin.y ; + Point w; + if ( ! blort ) { + w.x = transDeltaX ; w.y = transDeltaY ; + [ super translateOriginToPoint : w ] ; + return; + } + [ super translateOriginToPoint : MakePoint ( transDeltaX , transDeltaY ) ] ; + return; +} +- (void) translateOriginToPoint : ( Point ) translation { + /* This should never be called. */ + CHECK_IF(0); +} +@end + +int main(void) { + Derived *v = [Derived new]; + float r0 = 1.5 + 1.5; + blort = 1; + [v scrollToPoint: MakePoint(1.5, 1.5)]; + CHECK_IF(result == r0); + blort = 0; + [v scrollToPoint: MakePoint(1.5, 1.5)]; + CHECK_IF(result == r0); + blort = 1; + [v scrollToPoint: MakePoint(1.5, 1.5)]; + CHECK_IF(result == r0); + [v free]; + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fix-and-continue-2.m (revision 309) @@ -0,0 +1,24 @@ +/* Static variables, even if local, require indirect access through a stub + if -mfix-and-continue is enabled. */ + +/* Author: Ziemowit Laski */ + +/* { dg-do assemble { target *-*-darwin* } } */ +/* { dg-options "-mfix-and-continue" } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Foo: Object ++ (Object *)indexableFileTypes; +@end + +@implementation Foo ++ (Object *)indexableFileTypes +{ + static Object *fileTypes = 0; + if(!fileTypes) { + fileTypes = [Object new]; + } + return fileTypes; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-3.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-3.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/missing-proto-3.m (revision 309) @@ -0,0 +1,26 @@ +/* Ensure that the compiler gracefully handles missing protocol declarations. + In addition to not crashing :-), the compiler should properly handle + valid protocol references, even when they're mixed with invalid ones. */ +/* { dg-do compile } */ + +#include + +@protocol DefinedProtocol +- (id) missingMethod1; +@end + +@interface MyClass +/* { dg-error "cannot find protocol declaration for .UndefinedProtocol." "" { target *-*-* } 12 } */ +@end + +@implementation MyClass ++(Class)class +{ + return self; +} +@end + +/* { dg-warning "incomplete implementation of class .MyClass." "" { target *-*-* } 21 } */ +/* { dg-warning "method definition for .\\-missingMethod1. not found" "" { target *-*-* } 21 } */ +/* { dg-warning "class .MyClass. does not fully implement the .DefinedProtocol. protocol" "" { target *-*-* } 21 } */ + Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/headers.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/headers.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/headers.m (revision 309) @@ -0,0 +1,31 @@ +// Test for obscure conflicts with the system headers (inspired by similar +// test in libstdc++-v3). Author: Loren J. Rittle . +// { dg-options "-Wall -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wshadow" } +// { dg-do compile } + +#ifdef __NEXT_RUNTIME__ +#include +#else +#include +#endif +#include +#include +#ifdef __NEXT_RUNTIME__ +#include +#else +#include +#include +#endif + +#include +#ifndef __NEXT_RUNTIME__ +#include +#endif + +#include + +#ifndef __NEXT_RUNTIME__ +#include +#include +#include +#endif Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fsyntax-only.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fsyntax-only.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/fsyntax-only.m (revision 309) @@ -0,0 +1,11 @@ +/* Test -fsyntax-only compiler option */ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ + +@interface foo +-(void) my_method:(int) i with:(int) j; +@end + +@implementation foo +-(void) my_method:(int) i with:(int) j { } +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-1.m (revision 309) @@ -0,0 +1,30 @@ +/* Tests of duplication. */ +/* { dg-do compile } */ + +@interface class1 +- (int) meth1; +- (void) meth1; /* { dg-error "duplicate declaration of method .\\-meth1." } */ +@end + +@interface class2 ++ (void) meth1; ++ (int) meth1; /* { dg-error "duplicate declaration of method .\\+meth1." } */ +@end + +@interface class3 +- (int) meth1; +@end + +@implementation class3 +- (int) meth1 { return 0; } /* { dg-message "previous definition" } */ +- (int) meth1 { return 0; } /* { dg-error "redefinition of" } */ +@end + +@interface class4 ++ (void) meth1; +@end + +@implementation class4 ++ (void) meth1 {} /* { dg-message "previous definition" } */ ++ (void) meth1 {} /* { dg-error "redefinition of" } */ +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/extra-semi.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/extra-semi.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/extra-semi.m (revision 309) @@ -0,0 +1,10 @@ +/* Allow extra semicolons in between method declarations, + for old times' sake. */ + +/* { dg-do compile } */ + +@interface Foo + -(Foo *) expiration; + -(void) setExpiration:(Foo *) date;; + -(int) getVersion; +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/selector-4.m (revision 309) @@ -0,0 +1,30 @@ +/* Test whether including C++ keywords such as 'and', 'or', + 'not', etc., is allowed inside ObjC selectors (as it must be). */ +/* Author: Ziemowit Laski . */ + +/* { dg-do compile } */ + +@interface Int1 ++ (int)and_eq:(int)arg1 and:(int)arg2; +- (int)or_eq:(int)arg1 or:(int)arg3; +- (int)not:(int)arg1 xor:(int)arg2; +- (void)bitand:(char)c1 bitor:(char)c2; +- (void)compl:(float)f1 xor_eq:(double)d1; +- (void)not_eq; +@end + +@implementation Int1 ++ (int)and_eq:(int)arg1 and:(int)arg2 { return arg1 + arg2; } +- (int)or_eq:(int)arg1 or:(int)arg3 { return arg1 + arg3; } +- (int)not:(int)arg1 xor:(int)arg2 { return arg1 + arg2; } +- (void)bitand:(char)c1 bitor:(char)c2 { } +- (void)compl:(float)f1 xor_eq:(double)d1 { } +- (void)not_eq { } +@end + +/* { dg-final { scan-assembler "\\+\\\[Int1 and_eq:and:\\]|c_Int1__and_eq_and" } } */ +/* { dg-final { scan-assembler "\\-\\\[Int1 or_eq:or:\\]|i_Int1__or_eq_or" } } */ +/* { dg-final { scan-assembler "\\-\\\[Int1 not:xor:\\]|i_Int1__not_xor" } } */ +/* { dg-final { scan-assembler "\\-\\\[Int1 bitand:bitor:\\]|i_Int1__bitand_bitor" } } */ +/* { dg-final { scan-assembler "\\-\\\[Int1 compl:xor_eq:\\]|i_Int1__compl_xor_eq" } } */ +/* { dg-final { scan-assembler "\\-\\\[Int1 not_eq\\]|i_Int1__not_eq" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-5.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-5.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-5.m (revision 309) @@ -0,0 +1,20 @@ +/* Check if sending messages to "underspecified" objects is handled gracefully. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@class UnderSpecified; +typedef struct NotAClass { + int a, b; +} NotAClass; + +void foo(UnderSpecified *u, NotAClass *n) { + [n nonexistent_method]; /* { dg-warning "invalid receiver type" } */ + /* { dg-warning "no .\\-nonexistent_method. method found" "" { target *-*-* } 11 } */ + [NotAClass nonexistent_method]; /* { dg-error ".NotAClass. is not an Objective\\-C class name or alias" } */ + [u nonexistent_method]; /* { dg-warning "no .\\-nonexistent_method. method found" } */ + [UnderSpecified nonexistent_method]; /* { dg-warning "no .\\+nonexistent_method. method found" } */ +} + +/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ +/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ +/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stubify-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stubify-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stubify-1.m (revision 309) @@ -0,0 +1,35 @@ +/* All calls must be properly stubified. Complain about any "call + _objc_msgSend" without the $stub suffix. */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4" } */ + +typedef struct objc_object { } *id ; +int x = 41 ; +extern id objc_msgSend(id self, char * op, ...); +extern int bogonic (int, int, int) ; +@interface Document {} +- (Document *) window; +- (Document *) class; +- (Document *) close; +@end +@implementation Document +- (Document *) class { } +- (Document *) close { } +- (Document *) window { } +- (void)willEndCloseSheet:(void *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { + [[self window] close]; + ((void (*)(id, char *, int))objc_msgSend)([self class], (char *)contextInfo, 1); + ((void (*)(id, char *, int))bogonic)([self class], (char *)contextInfo, 1); + bogonic (3, 4, 5); + x++; +} +@end + +/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_objc_msgSend\n" } } */ +/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_objc_msgSend\\\$stub\n" } } */ +/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_bogonic\n" } } */ +/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_bogonic\\\$stub\n" } } */ +/* { dg-final { scan-assembler-not "\\\$non_lazy_ptr" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-9.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-9.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-9.m (revision 309) @@ -0,0 +1,45 @@ +/* Check if finding multiple signatures for a method is handled gracefully + when method lookup succeeds (see also method-7.m). */ +/* Contributed by Ziemowit Laski */ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-selector-match" } */ + + +#include "../objc-obj-c++-shared/Object1.h" + +@protocol MyObject +- (id)initWithData:(Object *)data; +@end + +@protocol SomeOther +- (id)initWithData:(int)data; +@end + +@protocol MyCoding +- (id)initWithData:(id)data; +@end + +@interface NTGridDataObject: Object +{ + Object *_data; +} ++ (NTGridDataObject*)dataObject:(id)data; +@end + +@implementation NTGridDataObject +- (id)initWithData:(id)data { + return data; +} ++ (NTGridDataObject*)dataObject:(id)data +{ + NTGridDataObject *result = [[NTGridDataObject alloc] initWithData:data]; + /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } 35 } */ + /* { dg-message "using .\\-\\(id\\)initWithData:\\(Object \\*\\)data." "" { target *-*-* } 11 } */ + /* { dg-message "also found .\\-\\(id\\)initWithData:\\(id \\)data." "" { target *-*-* } 19 } */ + /* { dg-message "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } 15 } */ + + /* The following warning is a consequence of picking the "wrong" method signature. */ + /* { dg-warning "passing argument 1 of .initWithData:. from distinct Objective\\-C type" "" { target *-*-* } 35 } */ + return result; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/type-size-2.m (revision 309) @@ -0,0 +1,61 @@ +/* Make sure that array arguments to methods are given the size of pointers. */ +/* As in the case of ivars, arrays without size (e.g., 'int []') are + encoded as pointers. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ +#include "../objc-obj-c++-shared/Object1.h" +#include "../objc-obj-c++-shared/next-mapping.h" +//#include +#ifdef __NEXT_RUNTIME__ +#include +#define METHOD Method +#else +#include +#define METHOD Method_t +#define method_get_types(M) (M)->method_types +#endif + +extern int sscanf(const char *str, const char *format, ...); +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +enum Enum { one, two, three, four }; + +@interface ArrayTest +- (const char *)str:(signed char [])arg1 with:(unsigned char *)arg2 and:(enum Enum[4])en; +- (int)meth1:(int [])arg1 with:(int [0])arg2 with:(int [2])arg3; +@end + +@implementation ArrayTest +- (int)meth1:(int [])arg1 with:(int [0])arg2 with:(int [2])arg3 { return 0; } +- (const char *)str:(signed char [])arg1 with:(unsigned char *)arg2 and:(enum Enum[4])en { return "str"; } +@end + +Class cls; +METHOD meth ; + +unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7; + +static void scan_initial(const char *pattern) { + totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1; + sscanf(method_get_types(meth), pattern, &totsize, &offs0, &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6, &offs7); + CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 + sizeof(SEL) && totsize >= offs2); +} + +int main(void) { + cls = objc_get_class("ArrayTest"); + + meth = class_get_instance_method(cls, @selector(str:with:and:)); + scan_initial("r*%u@%u:%u*%u*%u[4i]%u"); + CHECK_IF(offs3 == offs2 + sizeof(signed char *) && offs4 == offs3 + sizeof(unsigned char *)); + CHECK_IF(totsize == offs4 + sizeof(enum Enum *)); + meth = class_get_instance_method(cls, @selector(meth1:with:with:)); + scan_initial("i%u@%u:%u^i%u[0i]%u[2i]%u"); + CHECK_IF(offs3 == offs2 + sizeof(int *) && offs4 == offs3 + sizeof(int *)); + CHECK_IF(totsize == offs4 + sizeof(int *)); + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/isa-field-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/isa-field-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/isa-field-1.m (revision 309) @@ -0,0 +1,63 @@ +/* Ensure there are no bizarre difficulties with accessing the 'isa' field of objects. */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Object (Test) +- (Class) test1: (id)object; +@end + +@interface Derived: Object +- (Class) test2: (id)object; +@end + +@implementation Object (Test) + +Class test1(id object) { +#ifdef __NEXT_RUNTIME__ + Class cls = object->isa; +#else + Class cls = object->class_pointer; +#endif + return cls; +} +- (Class) test1: (id)object { +#ifdef __NEXT_RUNTIME__ + Class cls = object->isa; +#else + Class cls = object->class_pointer; +#endif + return cls; +} + +@end + +@implementation Derived + +Class test2(id object) { +#ifdef __NEXT_RUNTIME__ + Class cls = object->isa; +#else + Class cls = object->class_pointer; +#endif + return cls; +} +- (Class) test2: (id)object { +#ifdef __NEXT_RUNTIME__ + Class cls = object->isa; +#else + Class cls = object->class_pointer; +#endif + return cls; +} + +@end + +Class test3(id object) { +#ifdef __NEXT_RUNTIME__ + Class cls = object->isa; +#else + Class cls = object->class_pointer; +#endif + return cls; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-2.m (revision 309) @@ -0,0 +1,7 @@ +/* Test the -fconstant-string-class flag error. */ +/* { dg-do compile } */ +/* { dg-options "-fconstant-string-class=" } */ + +{ dg-error "no class name specified|missing argument" "" { target *-*-* } 0 } + +void foo () {} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-10.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-10.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-10.m (revision 309) @@ -0,0 +1,35 @@ +/* When there is only one candidate method available, make sure the + compiler uses its argument/return types when constructing the + message sends (so that proper C/C++ argument conversions may + take place). */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" + +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +static double d = 4.5920234e2; + +@interface Foo : Object +-(void) brokenType: (int)x floatingPoint: (double)y; +@end + + +@implementation Foo +-(void) brokenType: (int)x floatingPoint: (double)y +{ + CHECK_IF(x == 459); + CHECK_IF(y == d); +} +@end + +int main(void) +{ + Foo *foo=[Foo new]; + [foo brokenType: d floatingPoint: d]; + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h" Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/local-decl-2.m (revision 309) @@ -0,0 +1,42 @@ +/* Test for ivar access inside of class methods. It should be allowed (with a warning), but only + if no other declarations with the same name are seen. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" + +@interface Sprite: Object { + int sprite, spree; +} ++ (void)setFoo:(int)foo; ++ (void)setSprite:(int)sprite; +- (void)setFoo:(int)foo; +- (void)setSprite:(int)sprite; +@end + +int spree = 23; + +@implementation Sprite ++ (void)setFoo:(int)foo { + sprite = foo; /* { dg-warning "instance variable .sprite. accessed in class method" } */ + spree = foo; +} ++ (void)setSprite:(int)sprite { + int spree; + sprite = 15; + spree = 17; + ((Sprite *)self)->sprite = 16; /* NB: This is how one _should_ access */ + ((Sprite *)self)->spree = 18; /* ivars from within class methods! */ +} +- (void)setFoo:(int)foo { + sprite = foo; + spree = foo; +} +- (void)setSprite:(int)sprite { + int spree; + sprite = 15; /* { dg-warning "local declaration of .sprite. hides instance variable" } */ + self->sprite = 16; + spree = 17; /* { dg-warning "local declaration of .spree. hides instance variable" } */ + self->spree = 18; +} +@end Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-4.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-4.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/proto-lossage-4.m (revision 309) @@ -0,0 +1,52 @@ +/* Test for situations in which protocol conformance information + may be lost while casting. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +/* One-line substitute for objc/objc.h */ +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +@protocol Proto +- (long)someValue; +@end + +@interface Obj +- (long)anotherValue; +@end + +long foo(void) { + long receiver = 2; + Obj *objrcvr; + Obj *objrcvr2; + + /* NB: Since 'receiver' is an invalid ObjC message receiver, the compiler + should warn but then search for methods as if we were messaging 'id'. */ + + receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .long int." } */ + receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .long int." } */ + + receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ +/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 28 } */ + + receiver += [(Obj *)receiver anotherValue]; + receiver += [(Obj *)receiver someValue]; + receiver += [(Obj *)receiver anotherValue]; + receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ +/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 34 } */ + + receiver += [objrcvr anotherValue]; + receiver += [(Obj *)objrcvr someValue]; + receiver += [(Obj *)objrcvr anotherValue]; + receiver += [objrcvr2 someValue]; + receiver += [objrcvr2 anotherValue]; + receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ +/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 42 } */ + + receiver += [(Obj *)objrcvr2 anotherValue]; + + return receiver; +} + +/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ +/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ +/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-6.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-6.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/const-str-6.m (revision 309) @@ -0,0 +1,27 @@ +/* Negative test case for constant string layout. */ +/* Contributed by Ziemowit Laski . */ + +/* { dg-options "-fconstant-string-class=MyConstantString" } */ +/* { dg-do compile } */ + +@interface MyBase { + char p; +} +@end + +@interface MyConstantString: MyBase { + union { + void *u; + unsigned char *c; + } _contents; + char _count; +} +@end + +/* The NeXT runtime initializes the 'isa' pointer of string constants at + compile time. */ +#ifdef __NEXT_RUNTIME__ +extern void *_MyConstantStringClassReference; +#endif + +MyConstantString *str = @"Hello"; /* { dg-error "interface .MyConstantString. does not have valid constant string layout" } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-14.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-14.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-14.m (revision 309) @@ -0,0 +1,17 @@ +/* Test if context-sensitive "in", "out", "byref", etc., qualifiers can be + used as method selectors. */ +/* Author: Ziemowit Laski . */ +/* { dg-do compile } */ + +@interface Foo +- (void)insertNewButtonImage:(Foo *)newButtonImage in:(Foo *)buttonCell; ++ (oneway void)oneway:(int)i2 byref:(int)i3 out:(float)f4 bycopy:(float)f5; +@end + +@implementation Foo +- (void)insertNewButtonImage:(Foo *)newButtonImage in:(Foo *)buttonCell { } ++ (oneway void)oneway:(int)i2 byref:(int)i3 out:(float)f4 bycopy:(float)f5 { } +@end + +/* { dg-final { scan-assembler "insertNewButtonImage:in:" } } */ +/* { dg-final { scan-assembler "oneway:byref:out:bycopy:" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/member-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/member-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/member-1.m (revision 309) @@ -0,0 +1,5 @@ +void foo() +{ + struct A a; /* { dg-error "storage size" } */ + a.i; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-18.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-18.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/method-18.m (revision 309) @@ -0,0 +1,29 @@ +/* Do not warn about "slightly" mismatched method signatures if + -Wstrict-selector-match is off. */ +/* { dg-do compile } */ +/* { dg-options "-Wno-strict-selector-match" } */ + +#include + +typedef enum { en1_1, en1_2 } En1; +typedef enum { en2_1, en2_2 } En2; +typedef struct { int a, b; } St1; +typedef struct { unsigned a, b; } St2; + +@interface Base +- (id) meth1: (En1)arg1; +- (St1) window; +@end + +@interface Derived: Base +- (id) meth1: (En2)arg1; +- (St2)window; +@end + +void foo(void) { + id r; + En1 en; + + [r meth1:en]; + [r window]; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/gnu-runtime-2.m (revision 309) @@ -0,0 +1,30 @@ +/* Sanity check for GNU-runtime version of constant strings, + regardless of runtime used on target system. */ + +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +#include +#include +#include + +@interface NXConstantString: Object +{ + char *c_string; + unsigned int len; +} +-(const char *) cString; +-(unsigned int) length; +@end + +@implementation NXConstantString +-(const char *) cString { return c_string; } +-(unsigned int) length { return len; } +@end + +int main(int argc, void **args) +{ + if (strcmp ([@"this is a string" cString], "this is a string")) + abort (); + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stabs-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stabs-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/stabs-1.m (revision 309) @@ -0,0 +1,18 @@ +/* Check if the final SO STABS record goes into the .text section. */ +/* Contributed by Ziemowit Laski */ + +/* { dg-do compile } */ +/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* } { "*" } { "" } } */ +/* { dg-options "-gstabs" } */ + +@interface MyClass ++ newWithArg: arg; +@end + +@implementation MyClass ++ newWithArg: arg +{ +} +@end + +/* { dg-final { scan-assembler "(.SUBSPA.*\[\$\]CODE\[\$\]|.text\"?)\n\t.stabs.*100,0,0,(\[\.\$\])?L?L\[\$\]?etext\[0-9\]*\n(\[\.\$\])?L?L\[\$\]?etext" } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/volatile-1.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/volatile-1.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/volatile-1.m (revision 309) @@ -0,0 +1,18 @@ +/* Test for proper handling of volatile parameters in ObjC methods. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* Contributed by Ziemowit Laski */ + +@interface Test +-(void) test2: (volatile int) a; +@end + +@implementation Test +-(void) test2: (volatile int) a +{ + /* The following assignment should NOT be optimized away. */ + a = 1; +} +@end + +/* { dg-final { scan-assembler "li r\[0-9\]+,1" { target powerpc*-*-darwin* } } } */ Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-2.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-2.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/bitfield-2.m (revision 309) @@ -0,0 +1,56 @@ +/* Check if bitfield ivars are correctly @encode'd when + the NeXT runtime is used. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "-fsigned-char" } */ +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ + +typedef struct objc_object { struct objc_class *class_pointer; } *id; + +extern void abort(void); +extern int strcmp(const char *, const char *); + +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base +{ + struct objc_class *isa; + int full; + int full2: 32; + int _refs: 8; + int field2: 3; + unsigned f3: 8; + short cc; + unsigned g: 16; + int r2: 8; + int r3: 8; + int r4: 2; + int r5: 8; + char c; +} +@end + +@interface Derived: Base +{ + char d; + int _field3: 6; +} +@end + +@implementation Base +@end + +@implementation Derived +@end + +int main(void) { + const char *s1r = "{Base=#ib32b8b3b8sb16b8b8b2b8c}"; + const char *s1 = @encode(Base); + const char *s2r = "{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}"; + const char *s2 = @encode(Derived); + + CHECK_IF(!strcmp(s1r, s1)); + CHECK_IF(!strcmp(s2r, s2)); + + return 0; +} Index: trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/defs.m =================================================================== --- trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/defs.m (nonexistent) +++ trunk/gnu-src/gcc-4.5.1/gcc/testsuite/objc.dg/defs.m (revision 309) @@ -0,0 +1,70 @@ +/* Check if the @defs() construct preserves the correct + offsets of ivars. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-options "" } */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +#include "../objc-obj-c++-shared/Object1.h" +//#include + +extern void abort(void); + +#define CHECK_IF(expr) if(!(expr)) abort(); + +@interface Base: Object { +@public + int a; + float b; + char c; +} +@end + +@interface Derived: Base { +@public + double d; + unsigned e; + id f; +} +- init; +@end + +struct Derived_defs { + @defs(Derived); +}; + +@implementation Base +@end +@implementation Derived +- init { + [super init]; + a = 123; + b = 1.23; + c = 'c'; + d = 123.456; + e = 456; + f = isa; + return self; +} +@end + +int main(void) { + Derived *derived = [[Derived alloc] init]; + struct Derived_defs *derived_defs = (struct Derived_defs *)derived; + + CHECK_IF(derived->a == derived_defs->a && derived_defs->a == 123); + CHECK_IF(derived->b == derived_defs->b && derived_defs->b == (float)1.23); + CHECK_IF(derived->c == derived_defs->c && derived_defs->c == 'c'); + CHECK_IF(derived->d == derived_defs->d && derived_defs->d == (double)123.456); + CHECK_IF(derived->e == derived_defs->e && derived_defs->e == 456); + CHECK_IF(derived->f == derived_defs->f && derived_defs->f == derived_defs->isa); + + /* Try out the "inline" notation as well. */ + CHECK_IF(((struct { @defs(Derived); } *)derived)->a == 123); + CHECK_IF(((struct { @defs(Derived); } *)derived)->c == 'c'); + CHECK_IF(((struct { @defs(Derived); } *)derived)->e == 456); + + return 0; +} + +#include "../objc-obj-c++-shared/Object1-implementation.h"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.