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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [obj-c++.dg/] [cxx-ivars-2.mm] - Diff between revs 308 and 338

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 308 Rev 338
// Check if the '- .cxx_construct' and '-.cxx_destruct' methods get called
// Check if the '- .cxx_construct' and '-.cxx_destruct' methods get called
// and if they perform their desired function.
// and if they perform their desired function.
// { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } }
// { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } }
// { dg-do run { target *-*-darwin* } }
// { dg-do run { target *-*-darwin* } }
// { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } }
// { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } }
// { dg-options "-fobjc-call-cxx-cdtors" }
// { dg-options "-fobjc-call-cxx-cdtors" }
#include "../objc-obj-c++-shared/Object1.h"
#include "../objc-obj-c++-shared/Object1.h"
#include 
#include 
#define CHECK_IF(expr) if(!(expr)) abort()
#define CHECK_IF(expr) if(!(expr)) abort()
static int ctor1_called, ctor2_called, dtor1_called;
static int ctor1_called, ctor2_called, dtor1_called;
struct bar {
struct bar {
  int a, b;
  int a, b;
  bar(void) {
  bar(void) {
    a = 5; b = 6;
    a = 5; b = 6;
    ctor1_called++;
    ctor1_called++;
  }
  }
  ~bar(void) {
  ~bar(void) {
    a = b = 99;
    a = b = 99;
    dtor1_called++;
    dtor1_called++;
  }
  }
};
};
struct boo: bar {
struct boo: bar {
  int c;
  int c;
  boo(int _c = 9): c(_c) {
  boo(int _c = 9): c(_c) {
    ctor2_called++;
    ctor2_called++;
  }
  }
};
};
@interface Baz: Object {
@interface Baz: Object {
@public
@public
  bar aa;
  bar aa;
}
}
@end
@end
@implementation Baz
@implementation Baz
@end
@end
@interface Foo: Baz {
@interface Foo: Baz {
@public
@public
  int a;
  int a;
  boo bb;
  boo bb;
  bar b;
  bar b;
  float c;
  float c;
  bar d;
  bar d;
}
}
@end
@end
@implementation Foo
@implementation Foo
@end
@end
int main (void)
int main (void)
{
{
  CHECK_IF(!ctor1_called && !ctor2_called && !dtor1_called); /* are we sane? */
  CHECK_IF(!ctor1_called && !ctor2_called && !dtor1_called); /* are we sane? */
  Baz *baz = [Baz new];
  Baz *baz = [Baz new];
  CHECK_IF(ctor1_called && !ctor2_called && !dtor1_called);
  CHECK_IF(ctor1_called && !ctor2_called && !dtor1_called);
  CHECK_IF(baz->aa.a == 5 && baz->aa.b == 6);
  CHECK_IF(baz->aa.a == 5 && baz->aa.b == 6);
  ctor1_called = 0;  /* reset */
  ctor1_called = 0;  /* reset */
  [baz free];
  [baz free];
  CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
  CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
  dtor1_called = 0;  /* reset */
  dtor1_called = 0;  /* reset */
  Foo *foo = [Foo new];
  Foo *foo = [Foo new];
  CHECK_IF(ctor1_called && ctor2_called && !dtor1_called);
  CHECK_IF(ctor1_called && ctor2_called && !dtor1_called);
  CHECK_IF(foo->bb.a == 5 && foo->bb.b == 6 && foo->bb.c == 9);
  CHECK_IF(foo->bb.a == 5 && foo->bb.b == 6 && foo->bb.c == 9);
  CHECK_IF(foo->b.a == 5 && foo->b.b == 6);
  CHECK_IF(foo->b.a == 5 && foo->b.b == 6);
  CHECK_IF(foo->d.a == 5 && foo->d.b == 6);
  CHECK_IF(foo->d.a == 5 && foo->d.b == 6);
  ctor1_called = ctor2_called = 0;  /* reset */
  ctor1_called = ctor2_called = 0;  /* reset */
  [foo free];
  [foo free];
  CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
  CHECK_IF(!ctor1_called && !ctor2_called && dtor1_called);
}
}
#include "../objc-obj-c++-shared/Object1-implementation.h"
#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.