summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/effc2.C
blob: fb765f0d81a1517f0d3667d18c60bd64335c54c3 (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
// { dg-do compile }
// { dg-options "-Weffc++" }
// Contributed by Benjamin Kosnik <bkoz at redhat dot com>
// PR c++/16169 : Improve -Weffc++ rule 15

struct A {
 const A& foo();
 const A& operator=(int)
 { return foo(); }
};

struct B {
  B& foo();
  B& operator=(int)
  { return foo(); }
};

struct C {
  C& operator=(int)
  { return *this; }
};

struct D {
  D operator=(int)
  { return *this; }      // { dg-warning "should return a reference" }
};

struct E {
  E& foo();
  E operator=(int)
  { return foo(); }      // { dg-warning "should return a reference" }
};

struct F
{
  operator float();
  float operator=(int)
  { return *this; }      // { dg-warning "should return a reference" }
};