Skip to content

Commit d7703f6

Browse files
committed
Add tests of alloca declaration validation
1 parent f85650c commit d7703f6

12 files changed

+143
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stddef.h>
3+
4+
void *alloca();
5+
6+
int main()
7+
{
8+
int n;
9+
__CPROVER_assume(5 <= n && n < 10);
10+
int *c = alloca();
11+
assert(c);
12+
return 0;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
missing_parameters.c
3+
4+
file missing_parameters\.c line 10 function main: 'alloca' function called, but 'alloca' has not been declared with expected single 'size_t' parameter\.
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This is a test for C front end to confirm an appropriate error message is
11+
generated if `alloca` is called when it is declared without parameters.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stddef.h>
3+
4+
void *alloca(size_t a, size_t b);
5+
6+
int main()
7+
{
8+
int n;
9+
__CPROVER_assume(5 <= n && n < 10);
10+
int *c = alloca(n * sizeof(int), 42);
11+
assert(c);
12+
return 0;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
too_many_parameters.c
3+
4+
file too_many_parameters\.c line 10 function main: 'alloca' function called, but 'alloca' has not been declared with expected single 'size_t' parameter\.
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This is a test for C front end to confirm an appropriate error message is
11+
generated if `alloca` is called when it is declared with too many parameters.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
#include <stddef.h>
3+
4+
int main()
5+
{
6+
int n;
7+
__CPROVER_assume(5 <= n && n < 10);
8+
int *c = alloca(n * sizeof(int));
9+
assert(c);
10+
return 0;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
undeclared.c
3+
4+
file undeclared\.c line 8 function main: 'alloca' function called, but 'alloca' has not been declared with expected 'void \*' return type\.
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This is a test for C front end to confirm an appropriate error message is
11+
generated if `alloca` is called when it is not declared.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stddef.h>
3+
4+
void *alloca(size_t alloca_size);
5+
6+
int main()
7+
{
8+
int n;
9+
__CPROVER_assume(5 <= n && n < 10);
10+
int *c = alloca(n * sizeof(int));
11+
assert(c);
12+
return 0;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
valid_declaration.c
3+
4+
^VERIFICATION SUCCESSFUL
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This is a test for C front end to confirm that if `alloca` is declared as
11+
expected then no error is generated.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stddef.h>
3+
4+
void *alloca(char);
5+
6+
int main()
7+
{
8+
int n;
9+
__CPROVER_assume(5 <= n && n < 10);
10+
int *c = alloca(n * sizeof(int));
11+
assert(c);
12+
return 0;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
wrong_parameter_type.c
3+
4+
file wrong_parameter_type\.c line 10 function main: 'alloca' function called, but 'alloca' has not been declared with expected single 'size_t' parameter\.
5+
^EXIT=6$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This is a test for C front end to confirm an appropriate error message is
11+
generated if `alloca` is called when it is declared with too many parameters.

0 commit comments

Comments
 (0)