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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [copy4.C] - Rev 699

Compare with Previous | Blame | View Log

// { dg-do run  }
// GROUPS passed copy-ctors
// Using Cfront 3.0.1 the programm below prints
// 
//        A()
//        A(const A& a)
//        ~A()
//        A(A& a)        <---- !!!
//        ~A()
//        ~A()
// 
// the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints
// 
//        A()
//        A(const A& a)
//        ~A()
//        A(const A& a)  <---- !!!
//        ~A()
//        ~A()

extern "C" int printf (const char *, ...);
extern "C" void exit (int);

int count = 0;

void
die (int x)
{
  if (x != ++count)
    {
      printf ("FAIL\n");
      exit (1);
    }
}

class A {
public:
  A() { die (1); }
  A(const A& a) { die (2); }
  A(A& a) { die (4); }
  ~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); }
};

void foo1(const A& a) {
  A b = a;
}

void foo2( A& a) {
  A b = a;
}

int main() {
  A a;

  foo1(a);
  foo2(a);

  printf ("PASS\n");
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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