1 /* { dg-options "-fdiagnostics-show-caret" } */
3 /* Verify that we emit a "return *this;" fix-it hint for
4 a missing return in an assignment operator. */
7 s1& operator=(const s1&) { } // { dg-warning "no return statement in function returning non-void" }
8 /* { dg-begin-multiline-output "" }
9 s1& operator=(const s1&) { }
12 { dg-end-multiline-output "" } */
15 /* Likewise for +=. */
18 s2& operator+=(const s2&) {} // { dg-warning "no return statement in function returning non-void" }
19 /* { dg-begin-multiline-output "" }
20 s2& operator+=(const s2&) {}
23 { dg-end-multiline-output "" } */
26 /* No warning for "void" return. */
29 void operator=(const s3&) { }
32 /* We shouldn't issue the fix-it hint if the return type isn't right. */
35 int operator=(int) { } // { dg-warning "no return statement in function returning non-void" }
36 /* { dg-begin-multiline-output "" }
37 int operator=(int) { }
39 { dg-end-multiline-output "" } */
42 /* Example of a multi-line fix-it hint. */
46 s5& operator=(const s5& z) {
48 } // { dg-warning "no return statement in function returning non-void" }
49 /* { dg-begin-multiline-output "" }
54 { dg-end-multiline-output "" } */
57 /* Example of a multi-line fix-it hint with other statements. */
59 extern void log (const char *);
62 s6& operator=(const s6& z) {
65 } // { dg-warning "no return statement in function returning non-void" }
66 /* { dg-begin-multiline-output "" }
71 { dg-end-multiline-output "" } */
74 /* Another example of a multi-line fix-it hint with other statements. */
78 s7& operator=(const s6& z) {
84 } // { dg-warning "no return statement in function returning non-void" }
85 /* { dg-begin-multiline-output "" }
90 { dg-end-multiline-output "" } */