Added regression test for #8332.
This commit is contained in:
parent
4fde7f8b18
commit
64a7ba3c4c
|
@ -134,6 +134,16 @@ private:
|
||||||
" abc[0] = 'a';\n"
|
" abc[0] = 'a';\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (error) Modifying string literal u\"abc\" directly or indirectly is undefined behaviour.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (error) Modifying string literal u\"abc\" directly or indirectly is undefined behaviour.\n", errout.str());
|
||||||
|
|
||||||
|
check("void foo() {\n" // #8332
|
||||||
|
" int i;\n"
|
||||||
|
" char *p = \"string literal\";\n"
|
||||||
|
" for( i = 0; i < strlen(p); i++) {\n"
|
||||||
|
" p[i] = \'X\';\n" // <<
|
||||||
|
" }\n"
|
||||||
|
" printf(\"%s\\n\", p);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (error) Modifying string literal \"string literal\" directly or indirectly is undefined behaviour.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void alwaysTrueFalseStringCompare() {
|
void alwaysTrueFalseStringCompare() {
|
||||||
|
|
Loading…
Reference in New Issue