Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / g++.dg / opt / anchor1.C
blob5d30afbe8a3ceaa43715b8df267779b9527c1274
1 // { dg-do run }
2 // { dg-options "-O2" }
4 // The size of the construction vtable for YFont in YCoreFont was not
5 // updated to reflect its actual size.  On targets with section anchor
6 // support, the vtable for YCoreFont was laid out immediately after
7 // that, but the compiler thought it was about 40 bytes closer to the
8 // anchor than it actually was.
10 extern "C" void abort (void);
12 class refcounted {
13 public:
14     int __refcount;
16 public:
17     refcounted(): __refcount(0) {};
18     virtual ~refcounted() {}
21 class YFont : public virtual refcounted {
22 public:
23     virtual ~YFont() {}
25     virtual int ascent() const = 0;
28 struct XFontStruct {
31 class YCoreFont : public YFont {
32 public:
33     YCoreFont(char const * name);
34     virtual ~YCoreFont();
36     virtual int ascent() const { return 2; }
38 private:
39     XFontStruct * fFont;
42 YCoreFont::YCoreFont(char const * name) {
45 YCoreFont::~YCoreFont() {
48 int foo(YCoreFont *ycf)
50   ycf->ascent ();
53 int main()
55   YCoreFont ycf("");
56   if (foo(&ycf) != 2)
57     abort ();
58   return 0;