blob: 01888afc4f61e20ae5da96092784bb37c6aef842 [file] [log] [blame]
Howard Hinnantc325fa72012-02-01 21:01:52 +00001//===----------------- 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 Rathnayake57e446d2016-05-31 12:01:32 +000010// UNSUPPORTED: libcxxabi-no-exceptions
11
Howard Hinnantc325fa72012-02-01 21:01:52 +000012#include <cassert>
13
14#if __has_feature(cxx_nullptr)
15
16struct A
17{
18 const int i;
19 int j;
20};
21
22typedef const int A::*md1;
23typedef int A::*md2;
24
25void test1()
26{
27 try
28 {
29 throw nullptr;
30 assert(false);
31 }
Richard Smith2f984ca2016-07-19 20:19:37 +000032 catch (md2 p)
Howard Hinnantc325fa72012-02-01 21:01:52 +000033 {
Richard Smith2f984ca2016-07-19 20:19:37 +000034 assert(!p);
Howard Hinnantc325fa72012-02-01 21:01:52 +000035 }
36 catch (md1)
37 {
38 assert(false);
39 }
40}
41
42void test2()
43{
44 try
45 {
46 throw nullptr;
47 assert(false);
48 }
Richard Smith2f984ca2016-07-19 20:19:37 +000049 catch (md1 p)
Howard Hinnantc325fa72012-02-01 21:01:52 +000050 {
Richard Smith2f984ca2016-07-19 20:19:37 +000051 assert(!p);
Howard Hinnantc325fa72012-02-01 21:01:52 +000052 }
53 catch (md2)
54 {
55 assert(false);
56 }
57}
58
59#else
60
61void test1()
62{
63}
64
65void test2()
66{
67}
68
69#endif
70
71int main()
72{
73 test1();
74 test2();
75}