[llvm-commits] [test-suite] r129831 - in /test-suite/trunk/SingleSource/UnitTests: member-function-pointers.cpp member-function-pointers.reference_output
Daniel Dunbar
daniel at zuster.org
Tue Apr 19 16:15:37 PDT 2011
Author: ddunbar
Date: Tue Apr 19 18:15:37 2011
New Revision: 129831
URL: http://llvm.org/viewvc/llvm-project?rev=129831&view=rev
Log:
Add a test for member function pointer conversion to bool.
Added:
test-suite/trunk/SingleSource/UnitTests/member-function-pointers.cpp
test-suite/trunk/SingleSource/UnitTests/member-function-pointers.reference_output
Added: test-suite/trunk/SingleSource/UnitTests/member-function-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/member-function-pointers.cpp?rev=129831&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/member-function-pointers.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/member-function-pointers.cpp Tue Apr 19 18:15:37 2011
@@ -0,0 +1,35 @@
+#include <cstdio>
+
+// Test for member function pointers.
+
+
+struct A {
+ virtual void f0() {
+ printf("CHECK 0\n");
+ }
+ virtual void f1() {
+ printf("CHECK 1\n");
+ }
+};
+typedef void (A::*MFP)();
+
+MFP f0_a() {
+ return &A::f0;
+}
+MFP f0_b() {
+ return &A::f1;
+}
+int main() {
+ A a;
+
+ // Check conversion to bool. We explicitly check a virtual function whose
+ // offset will be 0, on some platforms this may be a corner case.
+ MFP x = f0_a();
+ MFP y = f0_b();
+ if (x)
+ (a.*x)();
+ if (y)
+ (a.*y)();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/UnitTests/member-function-pointers.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/member-function-pointers.reference_output?rev=129831&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/member-function-pointers.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/member-function-pointers.reference_output Tue Apr 19 18:15:37 2011
@@ -0,0 +1,3 @@
+CHECK 0
+CHECK 1
+exit 0
More information about the llvm-commits
mailing list