Skip to content

Commit

Permalink
[LValue Generalization] Update tests for validating member bounds (#455)
Browse files Browse the repository at this point in the history
* Add dynamic bounds casts to prevent compile-time errors from checking member bounds

* Add expected errors for checking member bounds
  • Loading branch information
kkjeer authored Jun 10, 2021
1 parent 69b7f2b commit 251cf68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions tests/dynamic_checking/bounds/bounds-safe-interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ void write_driver(int failure_point, int *a1 : count(10),
break;
// Vary structure lengths.
case 13:
s1->len = 0;
s1->len = 0, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
write_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
case 14:
s1->len = 1;
s1->len = 1, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
write_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
case 15:
s1->len = 2;
s1->len = 2, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
write_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
// Vary write position for a3 (7th parameter)
Expand Down Expand Up @@ -405,15 +405,15 @@ void read_driver(int failure_point, int *a1 : count(10),
break;
// Vary structure lengths.
case 13:
s1->len = 0;
s1->len = 0, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
read_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
case 14:
s1->len = 1;
s1->len = 1, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
read_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
case 15:
s1->len = 2;
s1->len = 2, s1->f = _Dynamic_bounds_cast<_Array_ptr<int>>(s1->f, bounds(s1->f, s1->f + s1->len));
read_test(failure_point, a1, 10, a2, 10, a3, 2, b1, 10, b2, 0, s1);
break;
// Vary read position for a3 (7th parameter)
Expand Down
6 changes: 3 additions & 3 deletions tests/static_checking/bounds_decl_checking.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ extern void check_exprs_nullterm(nt_array_ptr<int> arg1 : bounds(unknown),
s.f1 = t2;
s.f1 = t3;

s.f2 = t1; // expected-error {{expression has unknown bounds}}
s.f2 = t1; // expected-error {{inferred bounds for 's.f2' are unknown after assignment}}
s.f2 = t2;
s.f2 = t3;

s.f3 = t1; // expected-error {{expression has unknown bounds}}
s.f3 = t2; // expected-error {{declared bounds for s.f3 are invalid after assignment}}
s.f3 = t1; // expected-error {{inferred bounds for 's.f3' are unknown after assignment}}
s.f3 = t2; // expected-error {{declared bounds for 's.f3' are invalid after assignment}}
s.f3 = t3;

t1 = s.f1;
Expand Down

0 comments on commit 251cf68

Please sign in to comment.