| 1371 | |
| 1372 | @with_all_eh_sjlj |
| 1373 | def test_exceptions_uncaught(self): |
| 1374 | src = r''' |
| 1375 | #include <stdio.h> |
| 1376 | #include <exception> |
| 1377 | struct X { |
| 1378 | ~X() { |
| 1379 | printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no"); |
| 1380 | } |
| 1381 | }; |
| 1382 | int main() { |
| 1383 | printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no"); |
| 1384 | try { |
| 1385 | X x; |
| 1386 | throw 1; |
| 1387 | } catch(...) { |
| 1388 | printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no"); |
| 1389 | } |
| 1390 | printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no"); |
| 1391 | return 0; |
| 1392 | } |
| 1393 | ''' |
| 1394 | self.do_run(src, 'exception? no\nexception? yes\nexception? no\nexception? no\n') |
| 1395 | |
| 1396 | src = r''' |
| 1397 | #include <fstream> |
| 1398 | #include <iostream> |
| 1399 | int main() { |
| 1400 | std::ofstream os("test"); |
| 1401 | os << std::unitbuf << "foo"; // trigger a call to std::uncaught_exceptions from |
| 1402 | // std::basic_ostream::sentry::~sentry |
| 1403 | std::cout << "done\n"; |
| 1404 | } |
| 1405 | ''' |
| 1406 | self.do_run(src, 'done\n') |
| 1407 | |
| 1408 | @with_all_eh_sjlj |
| 1409 | def test_exceptions_uncaught_2(self): |