Howard Hinnant | 2d6810f | 2012-02-01 20:53:21 +0000 | [diff] [blame^] | 1 | //===--------------- catch_member_function_pointer_01.cpp -----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include <cassert> |
| 11 | |
| 12 | struct A |
| 13 | { |
| 14 | void foo() {} |
| 15 | void bar() const {} |
| 16 | }; |
| 17 | |
| 18 | typedef void (A::*mf1)(); |
| 19 | typedef void (A::*mf2)() const; |
| 20 | |
| 21 | void test1() |
| 22 | { |
| 23 | try |
| 24 | { |
| 25 | throw &A::foo; |
| 26 | assert(false); |
| 27 | } |
| 28 | catch (mf2) |
| 29 | { |
| 30 | assert(false); |
| 31 | } |
| 32 | catch (mf1) |
| 33 | { |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | void test2() |
| 38 | { |
| 39 | try |
| 40 | { |
| 41 | throw &A::bar; |
| 42 | assert(false); |
| 43 | } |
| 44 | catch (mf1) |
| 45 | { |
| 46 | assert(false); |
| 47 | } |
| 48 | catch (mf2) |
| 49 | { |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | int main() |
| 54 | { |
| 55 | test1(); |
| 56 | test2(); |
| 57 | } |