This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New C++ test
- To: gcc-patches at gcc dot gnu dot org
- Subject: New C++ test
- From: Neil Booth <neilb at earthling dot net>
- Date: Sun, 26 Nov 2000 17:26:20 +0000
This is from a PR I've closed.
Neil.
* g++.old-deja/g++.other/overload12.C
Index: g++.old-deja/g++.other/overload12.C
===================================================================
RCS file: overload12.C
diff -N overload12.C
--- /dev/null Tue May 5 13:32:27 1998
+++ overload12.C Sun Nov 26 09:25:47 2000
@@ -0,0 +1,30 @@
+// Build don't link:
+// Origin: Neil Booth <neilb@earthling.net> from bug #27.
+
+struct A{};
+
+struct B:A{};
+
+struct C:B{};
+
+struct CX
+{
+ C c;
+
+ operator C&(){return c;}
+};
+
+// viable functions for call below
+void f(A&);
+void f(B&);
+
+int main()
+{
+ CX cx;
+ C c;
+
+ f(c); // the standard conversion to B& is better than to A&
+
+ f(cx); // after user defined conversion to C&
+ // the standard conversion to B& is better than to A&
+}