Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / nullptr21.C
blobc30cb3c8b6de0880e5274d399e63f4960cdc32f8
1 // { dg-do run }
2 // { dg-options "-std=c++0x" }
4 // Test throw and catch
6 #include <cstdio>
8 typedef decltype(nullptr) nullptr_t;
10 int main()
12   try {
13     throw nullptr;
14   } catch (void*) {
15     printf("Test 1 Fail");
16   } catch (bool) {
17     printf("Test 1 Fail");
18   } catch (int) {
19     printf("Test 1 Fail");
20   } catch (long int) {
21     printf("Test 1 Fail");
22   } catch (nullptr_t) {
23     printf("Test 1 OK");
24   } catch (...) {
25     printf("Test 1 Fail");
26   }  // { dg-output "Test 1 OK" }
28   nullptr_t mynull = 0;
29   try {
30     throw mynull;
31   } catch (void*) {
32     printf("Test 2 Fail");
33   } catch (bool) {
34     printf("Test 2 Fail");
35   } catch (int) {
36     printf("Test 2 Fail");
37   } catch (long int) {
38     printf("Test 2 Fail");
39   } catch (nullptr_t) {
40     printf("Test 2 OK");
41   } catch (...) {
42     printf("Test 2 Fail");
43   }  // { dg-output "Test 2 OK" }