diff --git a/source/compiler/tests/CMakeLists.txt b/source/compiler/tests/CMakeLists.txt index 2cf5a31..b1538ce 100644 --- a/source/compiler/tests/CMakeLists.txt +++ b/source/compiler/tests/CMakeLists.txt @@ -70,6 +70,16 @@ set_tests_properties(const_array_args_and_literals_gh_276 PROPERTIES PASS_REGULA .*\\.pwn\\(41\\) : warning 239: literal array/string passed to a non-const parameter ") +add_compiler_test(md_array_size_chk_gh_314 ${CMAKE_CURRENT_SOURCE_DIR}/md_array_size_chk_gh_314.pwn) +set_tests_properties(md_array_size_chk_gh_314 PROPERTIES PASS_REGULAR_EXPRESSION +"*\\.pwn\\(1\\) : error 009: invalid array size \\(negative, zero or out of bounds\\) +.*\\.pwn\\(2\\) : error 009: invalid array size \\(negative, zero or out of bounds\\) +.*\\.pwn\\(3\\) : error 009: invalid array size \\(negative, zero or out of bounds\\) +.*\\.pwn\\(5\\) : error 009: invalid array size \\(negative, zero or out of bounds\\) +.*\\.pwn\\(30\\) : warning 224: indeterminate array size in \"sizeof\" expression \\(symbol \"\"\\) +") +set_tests_properties(md_array_size_chk_gh_314 PROPERTIES WILL_FAIL TRUE) + # Crashers # # These tests simply check that the compiler doesn't crash. diff --git a/source/compiler/tests/md_array_size_chk_gh_314.pwn b/source/compiler/tests/md_array_size_chk_gh_314.pwn new file mode 100644 index 0000000..368833d --- /dev/null +++ b/source/compiler/tests/md_array_size_chk_gh_314.pwn @@ -0,0 +1,40 @@ +new arr1[] = {}; +new arr2[5][]; +new arr3[5][][5]; +new arr4[5][5]; +new arr5[][]= { { } }; + +f1(arr[]) { + #pragma unused arr +} +f2(arr[5][]) { + #pragma unused arr +} +f3(arr[5][][5]) { + #pragma unused arr +} +f4(arr[5][5]) { + #pragma unused arr +} +f5(arr[][]) { + #pragma unused arr +} + +main () { + arr1[0] = 0; + arr2[0][0] = 0; + arr3[0][0][0] = 0; + arr4[0][0] = 0; + arr5[0][0] = 0; + + new a = sizeof(arr1); + a = sizeof(arr1[]); + a = sizeof(arr5[][]); + #pragma unused a + + f1(arr1); + f2(arr2); + f3(arr3); + f4(arr4); + f5(arr5); +}