aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.brendan/misc9.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/misc9.C28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C
new file mode 100644
index 00000000000..88071c6e04a
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C
@@ -0,0 +1,28 @@
+// Build don't link:
+// GROUPS passed miscellaneous
+//The program listed below produces the following error during compilation:
+// % g++ bug17.cc
+// bug17.cc: In method `class Y& Y::operator = (const class Y&)':
+// bug17.cc:18: invalid use of non-lvalue array
+
+class X {
+public:
+ X& operator=(const X&) { return *this; }
+};
+
+struct S {
+ char c[10];
+ X x;
+};
+
+class Y {
+ S s;
+public:
+ const S& f() const { return s; }
+
+ Y& operator=(const Y& _Y) {
+ s = _Y.s; // this line compiles
+ s = _Y.f(); // this line does not compile
+ return *this;
+ }
+};