Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 1 | //===----------------- catch_member_pointer_nullptr.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 | |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 10 | // UNSUPPORTED: libcxxabi-no-exceptions |
| 11 | |
Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 12 | #include <cassert> |
| 13 | |
| 14 | #if __has_feature(cxx_nullptr) |
| 15 | |
| 16 | struct A |
| 17 | { |
| 18 | const int i; |
| 19 | int j; |
| 20 | }; |
| 21 | |
| 22 | typedef const int A::*md1; |
| 23 | typedef int A::*md2; |
| 24 | |
| 25 | void test1() |
| 26 | { |
| 27 | try |
| 28 | { |
| 29 | throw nullptr; |
| 30 | assert(false); |
| 31 | } |
Richard Smith | 2f984ca | 2016-07-19 20:19:37 +0000 | [diff] [blame] | 32 | catch (md2 p) |
Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 33 | { |
Richard Smith | 2f984ca | 2016-07-19 20:19:37 +0000 | [diff] [blame] | 34 | assert(!p); |
Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 35 | } |
| 36 | catch (md1) |
| 37 | { |
| 38 | assert(false); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void test2() |
| 43 | { |
| 44 | try |
| 45 | { |
| 46 | throw nullptr; |
| 47 | assert(false); |
| 48 | } |
Richard Smith | 2f984ca | 2016-07-19 20:19:37 +0000 | [diff] [blame] | 49 | catch (md1 p) |
Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 50 | { |
Richard Smith | 2f984ca | 2016-07-19 20:19:37 +0000 | [diff] [blame] | 51 | assert(!p); |
Howard Hinnant | c325fa7 | 2012-02-01 21:01:52 +0000 | [diff] [blame] | 52 | } |
| 53 | catch (md2) |
| 54 | { |
| 55 | assert(false); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | #else |
| 60 | |
| 61 | void test1() |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | void test2() |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | int main() |
| 72 | { |
| 73 | test1(); |
| 74 | test2(); |
| 75 | } |