|
42 | 42 | rcpp_output_type = 1 ; \ |
43 | 43 | } \ |
44 | 44 | catch(Rcpp::internal::LongjumpException& __ex__) { \ |
45 | | - Rcpp::internal::resumeJump(__ex__.token); \ |
46 | | - rcpp_output_type = 2 ; \ |
47 | | - rcpp_output_condition = PROTECT(string_to_try_error("Unexpected LongjumpException")) ; \ |
| 45 | + rcpp_output_type = 3 ; \ |
| 46 | + rcpp_output_condition = __ex__.token; \ |
48 | 47 | } \ |
49 | 48 | catch(Rcpp::exception& __ex__) { \ |
50 | 49 | rcpp_output_type = 2 ; \ |
|
65 | 64 | SEXP stop_sym = Rf_install( "stop" ) ; \ |
66 | 65 | SEXP expr = PROTECT( Rf_lang2( stop_sym , rcpp_output_condition ) ) ; \ |
67 | 66 | Rf_eval( expr, R_GlobalEnv ) ; \ |
| 67 | + } \ |
| 68 | + if (rcpp_output_type == 3) { \ |
| 69 | + Rcpp::internal::resumeJump(rcpp_output_condition); \ |
| 70 | + Rf_error("Internal error: Rcpp longjump failed to resume"); \ |
68 | 71 | } |
69 | 72 | #endif |
70 | 73 |
|
71 | 74 | #ifndef END_RCPP |
72 | 75 | #define END_RCPP VOID_END_RCPP return R_NilValue; |
73 | 76 | #endif |
74 | 77 |
|
| 78 | + |
| 79 | +// There is no return in case of a longjump exception |
| 80 | + |
75 | 81 | #ifndef END_RCPP_RETURN_ERROR |
76 | 82 | #define END_RCPP_RETURN_ERROR \ |
77 | 83 | } \ |
78 | 84 | catch (Rcpp::internal::InterruptedException &__ex__) { \ |
79 | 85 | return Rcpp::internal::interruptedError(); \ |
80 | 86 | } \ |
81 | 87 | catch (Rcpp::internal::LongjumpException& __ex__) { \ |
82 | | - Rcpp::internal::resumeJump(__ex__.token); \ |
83 | | - return string_to_try_error("Unexpected LongjumpException") ; \ |
| 88 | + rcpp_output_type = 3 ; \ |
| 89 | + rcpp_output_condition = __ex__.token; \ |
84 | 90 | } \ |
85 | 91 | catch (std::exception &__ex__) { \ |
86 | 92 | return exception_to_try_error(__ex__); \ |
87 | 93 | } \ |
88 | 94 | catch (...) { \ |
89 | 95 | return string_to_try_error("c++ exception (unknown reason)"); \ |
90 | 96 | } \ |
| 97 | + if (rcpp_output_type == 3) { \ |
| 98 | + Rcpp::internal::resumeJump(rcpp_output_condition); \ |
| 99 | + Rf_error("Internal error: Rcpp longjump failed to resume"); \ |
| 100 | + } \ |
91 | 101 | return R_NilValue; |
92 | 102 | #endif |
93 | 103 |
|
|
0 commit comments