From 764df4dd568f32d35536be436c4a73b9ffec06c9 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 30 May 2015 22:57:54 +0200 Subject: [PATCH] Ticket #6588: Added test cases since the initial issue is fixed by some past commit. --- test/testbool.cpp | 10 ++++++++++ test/testother.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/test/testbool.cpp b/test/testbool.cpp index b85c2201d..0d09f6597 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -135,6 +135,16 @@ private: " X *p = new ::std::pair[rSize];\n" "}"); ASSERT_EQUALS("", errout.str()); + + // ticket #6588 + check("struct MpegEncContext { int *q_intra_matrix, *q_chroma_intra_matrix; };\n" + "void dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int n, int qscale) {\n" + " const int *qmat = n < 4;\n" /* KO */ + " const int *rmat = n < 4 ? " /* OK */ + " ctx->q_intra_matrix :" + " ctx->q_chroma_intra_matrix;\n" + "}"); + ASSERT_EQUALS("[test.cpp:3]: (error) Boolean value assigned to pointer.\n", errout.str()); } void assignBoolToFloat() { diff --git a/test/testother.cpp b/test/testother.cpp index 2898f268e..a8507cbc1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -587,6 +587,12 @@ private: invalidFunctionUsage("int f() { memset(a,b,sizeof(a)!=0); }"); ASSERT_EQUALS("[test.cpp:1]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str()); + invalidFunctionUsage("void record(char* buf, int n) {\n" + " memset(buf, 0, n < 255);\n" /* KO */ + " memset(buf, 0, n < 255 ? n : 255);\n" /* OK */ + "}"); + ASSERT_EQUALS("[test.cpp:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str()); + invalidFunctionUsage("int f() { strtol(a,b,sizeof(a)!=12); }"); ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (comparison result) but the valid values are '0,2:36'.\n", errout.str());