add test for i314

This commit is contained in:
Yashas 2018-07-29 16:33:34 +05:30
parent ad4ad64a8b
commit 1ca89fa864
2 changed files with 50 additions and 0 deletions

View File

@ -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 .*\\.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 # Crashers
# #
# These tests simply check that the compiler doesn't crash. # These tests simply check that the compiler doesn't crash.

View File

@ -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);
}