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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [optimize2.C] - Diff between revs 149 and 154

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

Rev 149 Rev 154
// { dg-do run  }
// { dg-do run  }
// { dg-options "-O2" }
// { dg-options "-O2" }
//
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 May 2001 
// Contributed by Nathan Sidwell 26 May 2001 
// Bug 2823. Inlineing the body of a thunk broke things. But that's
// Bug 2823. Inlineing the body of a thunk broke things. But that's
// rarely a sensible thing to do anyway.
// rarely a sensible thing to do anyway.
#include 
#include 
#include 
#include 
int objCount = 0;
int objCount = 0;
struct Thing
struct Thing
{
{
  int count;
  int count;
  Thing ();
  Thing ();
  Thing (Thing const &src);
  Thing (Thing const &src);
  ~Thing ();
  ~Thing ();
};
};
Thing::Thing ()
Thing::Thing ()
  :count (0)
  :count (0)
{
{
  objCount++;
  objCount++;
  std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
  std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
}
}
Thing::Thing (Thing const &src)
Thing::Thing (Thing const &src)
  :count (0)
  :count (0)
{
{
  objCount++;
  objCount++;
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
}
}
Thing::~Thing ()
Thing::~Thing ()
{
{
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
  std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
  if (count)
  if (count)
    std::abort ();
    std::abort ();
  count--;
  count--;
  objCount--;
  objCount--;
}
}
void x(Thing name)
void x(Thing name)
{
{
  // destruct name here
  // destruct name here
}
}
class Base
class Base
{
{
  public:
  public:
  virtual void test(const Thing& s) = 0;
  virtual void test(const Thing& s) = 0;
};
};
class Impl : virtual public Base
class Impl : virtual public Base
{
{
  public:
  public:
  virtual void test(const Thing& s)
  virtual void test(const Thing& s)
  {
  {
    x(s); // copy construct temporary
    x(s); // copy construct temporary
  }
  }
};
};
int main()
int main()
{
{
  Impl *impl = new Impl();
  Impl *impl = new Impl();
  impl->test( Thing ());        // This will use a thunk
  impl->test( Thing ());        // This will use a thunk
  return objCount != 0;
  return objCount != 0;
}
}
 
 

powered by: WebSVN 2.1.0

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