aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C
new file mode 100644
index 000000000..bc5732de9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Wself-assign-3.C
@@ -0,0 +1,35 @@
+// Test how operands_equal_p handles a NULL operand.
+// { dg-do compile }
+// { dg-options "-Wself-assign" }
+
+#include <cstdio>
+
+namespace testing {
+
+class Foo {
+ int f;
+ public:
+ Foo() { printf("Construct Foo\n"); }
+};
+
+class Bar {
+ int b;
+ public:
+ Bar(int x) { printf("Construct Bar\n"); }
+
+ void operator=(const Foo& foo) {
+ printf("Assign Foo to Bar\n");
+ }
+};
+
+}
+
+template <class T>
+void func(T t) {
+ ::testing::Bar(1) = ::testing::Foo(); // used to trigger a segfault
+ ::testing::Foo() = ::testing::Foo();
+}
+
+main() {
+ func(2);
+}