[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / optimize2.C
bloba16394fd4816c217a584b009c7e9204b91692a57
1 // { dg-do run  }
2 // { dg-options "-O2" }
3 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
4 // 
5 // Copyright (C) 2001 Free Software Foundation, Inc.
6 // Contributed by Nathan Sidwell 26 May 2001 <nathan@codesourcery.com>
8 // Bug 2823. Inlineing the body of a thunk broke things. But that's
9 // rarely a sensible thing to do anyway.
11 #include <cstdio>
12 #include <cstdlib>
14 int objCount = 0;
16 struct Thing
18   int count;
20   Thing ();
21   Thing (Thing const &src);
22   
23   ~Thing ();
24   
27 Thing::Thing ()
28   :count (0)
30   objCount++;
31   std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
34 Thing::Thing (Thing const &src)
35   :count (0)
37   objCount++;
38   std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
41 Thing::~Thing ()
43   std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
44   if (count)
45     std::abort ();
46   count--;
47   objCount--;
50 void x(Thing name)
52   // destruct name here
55 class Base
57   public:
58   virtual void test(const Thing& s) = 0;
61 class Impl : virtual public Base
63   public:
64   virtual void test(const Thing& s)
65   {
66     x(s); // copy construct temporary
67   }
70 int main()
72   Impl *impl = new Impl();
73   
74   impl->test( Thing ());        // This will use a thunk
75   return objCount != 0;