You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1880,6 +1881,43 @@ class TestFunctions : public TestFixture {
1880
1881
ASSERT_EQUALS("[test.cpp:3:5]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1881
1882
}
1882
1883
1884
+
voidcheckMissingReturn7() {// #14370 FN try/catch
1885
+
check("int foo(void) {\n"
1886
+
" try { return readData(); }\n"
1887
+
" catch (...) {}\n"
1888
+
"}\n");
1889
+
ASSERT_EQUALS("[test.cpp:3:18]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1890
+
1891
+
check("int foo(void) {\n"
1892
+
" try { return readData(); }\n"
1893
+
" catch (const E& e) {}\n"
1894
+
" catch (...) { return 2; }\n"
1895
+
"}\n");
1896
+
ASSERT_EQUALS("[test.cpp:3:25]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1897
+
1898
+
check("int foo(void) {\n"
1899
+
" try { x=1; }\n"
1900
+
" catch (...) { return 2; }\n"
1901
+
"}\n");
1902
+
ASSERT_EQUALS("[test.cpp:2:11]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1903
+
1904
+
check("int foo(void) {\n"
1905
+
" try { return readData(); }\n"
1906
+
" catch (...) { return 0; }\n"
1907
+
"}\n");
1908
+
ASSERT_EQUALS("", errout_str());
1909
+
1910
+
check("int foo(void)\n"
1911
+
" try { x=1; }\n"
1912
+
" catch (...) { return 2; }\n");
1913
+
ASSERT_EQUALS("[test.cpp:2:11]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1914
+
1915
+
check("int foo(void)\n"
1916
+
" try { return readData(); }\n"
1917
+
" catch (...) { }\n");
1918
+
ASSERT_EQUALS("[test.cpp:3:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1919
+
}
1920
+
1883
1921
// NRVO check
1884
1922
voidreturnLocalStdMove1() {
1885
1923
check("struct A{}; A f() { A var; return std::move(var); }");
0 commit comments