summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p5840.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.mike/p5840.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.mike/p5840.C36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5840.C b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C
new file mode 100644
index 000000000..1cd033005
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C
@@ -0,0 +1,36 @@
+// { dg-do run }
+// prms-id: 5840
+
+class Signal {
+public:
+ int Name(void) { return 1; }
+};
+
+class Derived : public Signal {
+public:
+ int Name(void) { return 2; }
+};
+
+template <class Foo , int (Foo::*Id)(void)>
+class Bar
+{
+public:
+ int value (Foo* a) { return (a->*Id)(); }
+};
+
+/* The following line is illegal under the new rules for non-type
+ template arguments in the standard, so it is commented out. */
+/* template class Bar <Derived, &Signal::Name>; */
+template class Bar <Signal, &Signal::Name>;
+template class Bar <Derived, &Derived::Name>;
+
+Derived a;
+
+/* Bar<Derived, &Signal::Name> dispatcher1; */
+Bar<Derived, &Derived::Name> dispatcher2;
+
+int main() {
+ /* int i1 = dispatcher1.value(&a); */
+ int i2 = dispatcher2.value(&a);
+ return /* i1 != 1 || */ i2 != 2;
+}