1 // Copyright (c) Microsoft. All rights reserved. 2 // Licensed under the MIT license. See LICENSE file in the project root for 3 // full license information. 4 5 #include <stdio.h> 6 7 typedef void (*OperationF)(); TestFunction()8void TestFunction() { throw 1; } RethrowIt()9void RethrowIt() { throw; } 10 HandleRethrown1(OperationF perform)11int HandleRethrown1(OperationF perform) { 12 int ret = 0; 13 try { 14 perform(); 15 return 0; 16 } catch (...) { 17 // ellipsis catch 18 try { 19 RethrowIt(); 20 } catch (...) { 21 ret = 1; 22 } 23 } 24 25 return ret; 26 } 27 HandleRethrown2(OperationF perform)28int HandleRethrown2(OperationF perform) { 29 int ret = 0; 30 try { 31 perform(); 32 return 0; 33 } catch (int j) { 34 // non-ellipsis catch 35 try { 36 RethrowIt(); 37 } catch (int i) { 38 ret = i; 39 } 40 } 41 42 return ret; 43 } 44 main()45int main() { 46 int exit_code1; 47 int exit_code2; 48 exit_code1 = HandleRethrown1(TestFunction); 49 exit_code2 = HandleRethrown2(TestFunction); 50 51 if (exit_code1 == 1 && exit_code2 == 1) { 52 printf("passed"); 53 } else { 54 printf("failed"); 55 } 56 57 return 0; 58 } 59