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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [template/] [ptrmem18.C] - Rev 801

Go to most recent revision | Compare with Previous | Blame | View Log

// PR c++/33616
// { dg-do run }
// { dg-options "-O2" }

extern "C" void abort ();

struct S {
  int c;
  S () : c (0) {}
  virtual void f1 () { c += 1; }
  virtual void f2 () { c += 16; }
};

struct T {
  S s;
};

typedef void (S::*Q) ();

template <Q P>
void test1 (T *t)
{
  (t->s.*P)();
}

template <Q P>
void test2 (T *t)
{
  S &s = t->s;
  (s.*P)();
}

int
main ()
{
  T t;
  test1 <&S::f1> (&t);
  if (t.s.c != 1)
    abort ();
  test1 <&S::f2> (&t);
  if (t.s.c != 17)
    abort ();
  test2 <&S::f1> (&t);
  if (t.s.c != 18)
    abort ();
  test2 <&S::f2> (&t);
  if (t.s.c != 34)
    abort ();
}

Go to most recent revision | 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.