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
{{ message }}
Repository navigation
Commit 0a6ea03
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -1964,6 +1965,63 @@ class TestFunctions : public TestFixture {
1964
1965
ASSERT_EQUALS("", errout_str());
1965
1966
}
1966
1967
1968
+
voidcheckMissingReturn10() { // #12551
1969
+
check("enum class E { E1, E2 };\n"
1970
+
"template <E type>\n"
1971
+
"static bool f() {\n"
1972
+
" if constexpr (type == E::E1) {\n"
1973
+
" return true;\n"
1974
+
" }\n"
1975
+
" else if constexpr (type == E::E2) {\n"
1976
+
" return false;\n"
1977
+
" }\n"
1978
+
"}\n");
1979
+
ASSERT_EQUALS("", errout_str());
1980
+
1981
+
check("enum class E { E1, E2 };\n"
1982
+
"template <E type>\n"
1983
+
"static bool f() {\n"
1984
+
" if constexpr (type == E::E1) {\n"
1985
+
" return true;\n"
1986
+
" }\n"
1987
+
" else if constexpr (type == E::E2) {\n"
1988
+
" return false;\n"
1989
+
" }\n"
1990
+
"}\n"
1991
+
"int main() {\n"
1992
+
" return f<E::E1>();\n"
1993
+
"}\n");
1994
+
ASSERT_EQUALS("", errout_str());
1995
+
1996
+
check("enum E { E1, E2, E3 };\n"
1997
+
"bool f(E e) {\n"
1998
+
" if (e == E1)\n"
1999
+
" return true;\n"
2000
+
" else if (e == E2)\n"
2001
+
" return false;\n"
2002
+
"}\n");
2003
+
ASSERT_EQUALS("[test.cpp:6:21]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
2004
+
2005
+
check("enum E { E1, E2 };\n"
2006
+
"bool f(E e, E g) {\n"
2007
+
" if (e == E1)\n"
2008
+
" return true;\n"
2009
+
" else if (g == E2)\n"
2010
+
" return false;\n"
2011
+
"}\n");
2012
+
ASSERT_EQUALS("[test.cpp:6:21]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
2013
+
2014
+
check("enum E { E1, E2 };\n"
2015
+
"namespace ns { int x; }\n"
2016
+
"bool f() {\n"
2017
+
" if (ns::x == E1)\n"
2018
+
" return true;\n"
2019
+
" else if (ns::x == E2)\n"
2020
+
" return false;\n"
2021
+
"}\n");
2022
+
ASSERT_EQUALS("[test.cpp:7:21]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
2023
+
}
2024
+
1967
2025
voidcheckMissingReturnStdInt() {// #14482 - FN
1968
2026
check("std::int32_t f() {}\n");
1969
2027
ASSERT_EQUALS("[test.cpp:1:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
0 commit comments