CPP: Add tests of AV Rule 114.ql with non-trivial return types.

This commit is contained in:
Geoffrey White
2018-10-19 22:45:48 +01:00
parent 6811d527e1
commit c97a5ed292
2 changed files with 46 additions and 0 deletions

View File

@@ -3,3 +3,7 @@
| test.c:39:9:39:14 | ExprStmt | Function f6 should return a value of type int but does not return a value here |
| test.cpp:16:1:18:1 | { ... } | Function g2 should return a value of type MyValue but does not return a value here |
| test.cpp:48:2:48:26 | if (...) ... | Function g7 should return a value of type MyValue but does not return a value here |
| test.cpp:74:1:76:1 | { ... } | Function g10 should return a value of type second but does not return a value here |
| test.cpp:80:1:82:1 | { ... } | Function g11 should return a value of type first but does not return a value here |
| test.cpp:86:1:88:1 | { ... } | Function g12 should return a value of type second but does not return a value here |
| test.cpp:86:1:88:1 | { ... } | Function g12 should return a value of type second but does not return a value here |

View File

@@ -50,3 +50,45 @@ MyValue g7(bool c)
DONOTHING
// BAD [the alert here is unfortunately placed]
}
typedef void MYVOID;
MYVOID g8()
{
// GOOD
}
template<class T, class U>
class TypePair
{
public:
typedef T first;
typedef U second;
};
TypePair<void, int>::first g9()
{
// GOOD (the return type amounts to void)
}
TypePair<void, int>::second g10()
{
// BAD (the return type amounts to int)
}
template<class T>
typename TypePair<void, T>::first g11()
{
// GOOD (the return type amounts to void) [FALSE POSITIVE]
}
template<class T>
typename TypePair<void, T>::second g12()
{
// BAD (the return type amounts to T / int)
}
void instantiate()
{
g11<int>();
g12<int>();
}