Debian Codegraph @

gcc/testsuite/g++.dg/warn/effc2.C

raw
1 // { dg-do compile }
2 // { dg-options "-Weffc++" }
3 // Contributed by Benjamin Kosnik <bkoz at redhat dot com>
4 // PR c++/16169 : Improve -Weffc++ rule 15
5
6 struct A {
7 const A& foo();
8 const A& operator=(int)
9 { return foo(); }
10 };
11
12 struct B {
13 B& foo();
14 B& operator=(int)
15 { return foo(); }
16 };
17
18 struct C {
19 C& operator=(int)
20 { return *this; }
21 };
22
23 struct D {
24 D operator=(int)
25 { return *this; } // { dg-warning "should return a reference" }
26 };
27
28 struct E {
29 E& foo();
30 E operator=(int)
31 { return foo(); } // { dg-warning "should return a reference" }
32 };
33
34 struct F
35 {
36 operator float();
37 float operator=(int)
38 { return *this; } // { dg-warning "should return a reference" }
39 };