From a1953f0964271fe850ddfa39a84bedf516b9cc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 5 Jul 2011 19:57:07 +0200 Subject: [PATCH] TestCharVar::pointer: Added one more test case to see that error message disappears when code is fixed --- test/testcharvar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testcharvar.cpp b/test/testcharvar.cpp index dbfa5b927..f94420f29 100644 --- a/test/testcharvar.cpp +++ b/test/testcharvar.cpp @@ -148,12 +148,21 @@ private: void pointer() { + // ticket #2866 check("void f(char *p) {\n" " int ret = 0;\n" " ret |= *p;\n" " return ret;\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (warning) When using char variables in bit operations, sign extension can generate unexpected results.\n", errout.str()); + + // fixed code + check("void f(char *p) {\n" + " int ret = 0;\n" + " ret |= (unsigned char)*p;\n" + " return ret;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } };