[llvm-commits] [test-suite] r111754 - in /test-suite/trunk/SingleSource/Regression/C++: pointer_method2.cpp pointer_method2.reference_output

John McCall rjmccall at apple.com
Sat Aug 21 17:10:45 PDT 2010


Author: rjmccall
Date: Sat Aug 21 19:10:45 2010
New Revision: 111754

URL: http://llvm.org/viewvc/llvm-project?rev=111754&view=rev
Log:
Add a regression test which covers both virtual and non-virtual calls
through method pointers.


Added:
    test-suite/trunk/SingleSource/Regression/C++/pointer_method2.cpp
    test-suite/trunk/SingleSource/Regression/C++/pointer_method2.reference_output

Added: test-suite/trunk/SingleSource/Regression/C++/pointer_method2.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C%2B%2B/pointer_method2.cpp?rev=111754&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C++/pointer_method2.cpp (added)
+++ test-suite/trunk/SingleSource/Regression/C++/pointer_method2.cpp Sat Aug 21 19:10:45 2010
@@ -0,0 +1,37 @@
+#include <stdio.h>
+
+struct A {
+  int a;
+  virtual void foo() = 0;
+  void bar() { printf("A::bar(): a=%x\n", a); }
+};
+
+struct B {
+  int b;
+  virtual void foo() = 0;
+  void bar() { printf("B::bar(): b=%x\n", b); }
+};
+
+struct C : A, B {
+  int c;
+  virtual void foo() { printf("C::foo(), c=%x\n", c); }
+  void bar() { printf("C::bar(), c=%x\n", c); }
+};
+
+template <class T> void invoke(C &c, void (T::*fn)()) {
+  (c.*fn)();
+}
+
+int main() {
+  C c;
+  c.a = 0xff;
+  c.b = 0xf0f;
+  c.c = 0xf00f;
+
+  invoke(c, &A::foo);
+  invoke(c, &A::bar);
+  invoke(c, &B::foo);
+  invoke(c, &B::bar);
+  invoke(c, &C::foo);
+  invoke(c, &C::bar);
+}

Added: test-suite/trunk/SingleSource/Regression/C++/pointer_method2.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C%2B%2B/pointer_method2.reference_output?rev=111754&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C++/pointer_method2.reference_output (added)
+++ test-suite/trunk/SingleSource/Regression/C++/pointer_method2.reference_output Sat Aug 21 19:10:45 2010
@@ -0,0 +1,7 @@
+C::foo(), c=f00f
+A::bar(): a=ff
+C::foo(), c=f00f
+B::bar(): b=f0f
+C::foo(), c=f00f
+C::bar(), c=f00f
+exit 0





More information about the llvm-commits mailing list