summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.jason/opeq.C
blob: 60fc5c1ae269503ecc77ad053f7fef44782e361b (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
// { dg-do run  }
// PRMS Id: 4297 (related to 3525)
// Bug: Generating default op= didn't set TYPE_HAS_ASSIGNMENT, so it wasn't
// found.

extern "C" int printf (const char *, ...);

class Y 
{
public:
    Y(const char*) {}
    Y& operator = (const Y&) { return *this; }
};
    

class X
{
public:
    X(int v, const char* m) : _v(v), _m (m) {}
    X () : _v(0), _m("Unknown") {}
    // Defining our own op= here makes things work correctly.

private:
    int _v;
    int _m4;
    // Adding more members here increases the count on u.
    Y _m;
};

const X sPassed (1, "Passed"), sFailed (-1, "Failed");

int main (int, char**)
{
    X result;
    int u = 0;
    result = (u++ ? sPassed : sFailed);
    if (u == 1)
      return 0;
    return 1;
}