summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/effc2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/effc2.C')
-rw-r--r--gcc/testsuite/g++.dg/warn/effc2.C39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/effc2.C b/gcc/testsuite/g++.dg/warn/effc2.C
new file mode 100644
index 000000000..fb765f0d8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/effc2.C
@@ -0,0 +1,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" }
+};