Ticket #8640: Added regression test

This commit is contained in:
orbitcowboy 2021-12-19 17:43:32 +01:00
parent 0d7a3a8b26
commit b2d81f0870
1 changed files with 11 additions and 0 deletions

View File

@ -167,6 +167,17 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// #8640
check("int f (void)\n"
"{\n"
" constexpr const int a = 1;\n"
" constexpr const int shift[1] = {32};\n"
" constexpr const int ret = a << shift[0];\n" // shift too many bits
" return ret;\n"
"}");
ASSERT_EQUALS("[test.cpp:5]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n"
"[test.cpp:5]: (error) Signed integer overflow for expression 'a<<shift[0]'.\n", errout.str());
// #8885
check("int f(int k, int rm) {\n"
" if (k == 32)\n"