summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/const2.C
blob: b4efbbe3564d7099f81aa9bb69f79c80209a3ef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// PR optimization/6631

// { dg-do run }
// { dg-options "-O" }

extern "C" void abort (void);

struct QSize
{
  QSize();
  QSize( int w, int h );
  int wd, ht;
  friend inline const QSize operator+( const QSize &, const QSize & );
};

inline QSize::QSize()
{ wd = ht = -1; }

inline QSize::QSize( int w, int h )
{ wd = w; ht = h; }

inline const QSize operator+( const QSize & s1, const QSize & s2 )
{ return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }

QSize minimumSize()
{
  return QSize (100, 200);
}

QSize totalMinimumSize()
{
    QSize s = minimumSize();
    return s + QSize( 0, 0 );
}

int main()
{
  QSize s = totalMinimumSize();
  if (s.wd != 100 || s.ht != 200)
    abort ();
}