CPP: Move the AV Rule 97 test.

This commit is contained in:
Geoffrey White
2018-11-12 15:17:26 +00:00
parent 2d665e51d0
commit 03cad6c084
3 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
| jsf97.cpp:6:12:6:15 | bad1 | Raw arrays should not be used in interfaces. A container class should be used instead. |
| jsf97.cpp:11:12:11:15 | bad2 | Raw arrays should not be used in interfaces. A container class should be used instead. |
| jsf97.cpp:16:12:16:15 | bad3 | Raw arrays should not be used in interfaces. A container class should be used instead. |
| jsf97.cpp:21:12:21:15 | bad4 | Raw arrays should not be used in interfaces. A container class should be used instead. |
| jsf97.cpp:40:13:40:23 | bad_longjmp | Raw arrays should not be used in interfaces. A container class should be used instead. |

View File

@@ -0,0 +1 @@
jsf/4.10 Classes/AV Rule 97.ql

View File

@@ -0,0 +1,62 @@
typedef char chars[10];
typedef int jmp_buf[16];
class C { public:
static int bad1(char xs[10])
{
return sizeof(xs);
}
static int bad2(char xs[])
{
return sizeof(xs);
}
static int bad3(chars xs)
{
return sizeof(xs);
}
static int bad4(chars const xs)
{
return sizeof(xs);
}
static int good1(char (&xs)[10])
{
return sizeof(xs);
}
static int good2(chars& xs)
{
return sizeof(xs);
}
static void good_longjmp(jmp_buf j)
{
}
static void bad_longjmp(int j[16])
{
}
template <typename T, unsigned N>
static unsigned array_size(T(&)[N])
{
return N;
}
template <typename T>
static void no_op(T&& arg)
{
}
};
int main()
{
chars c;
C::no_op(c);
return C::array_size(c);
}