Skip to content

Commit d4acd3c

Browse files
committed
More tests
1 parent 58b2781 commit d4acd3c

12 files changed

+80
-8
lines changed

lab1/test/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PRECIOUS: %.ll
22

3-
all: simple0.out simple1.out branch0.out input0.out
3+
all: simple0.out simple1.out simple2.out simple3.out simple4.out simple5.out simple6.out simple7.out simple8.out simple9.c simple10.out simple11.out
44

55
%.ll: %.c
66
clang -emit-llvm -S -fno-discard-value-names -c -o $@ $<

lab1/test/input0.c

-7
This file was deleted.
File renamed without changes.

lab1/test/simple11.c

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int x = 2 * fgetc(stdin) - 2;
5+
int y = 5 / x; // Divide byb zero
6+
return 0;
7+
}

lab1/test/simple2.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
void f() {
2+
int x = 0;
3+
int y = 2;
4+
int z;
5+
if (x < 1) {
6+
z = y / x; // divide-by-zero within branch
7+
} else {
8+
z = z / x; // divide-by-zero within branch
9+
}
10+
}

lab1/test/simple3.c

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int main() {
2+
int a = 0;
3+
int b = 0;
4+
int d = 5;
5+
int c = a == b;
6+
int e = d / (c * 0); // divide by zero
7+
return 0;
8+
}

lab1/test/simple4.c

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main() {
2+
int b = 0;
3+
int a = b / 5;
4+
return 0;
5+
}

lab1/test/simple5.c

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int y = 1, z = 1;
5+
int un;
6+
int x = un + 1;
7+
if (x == 0) {
8+
z = y / x; // Divide by zero
9+
}
10+
return 0;
11+
}

lab1/test/simple6.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int main() {
2+
int a, b;
3+
int c = 0;
4+
b = c;
5+
a = b;
6+
int d = a / c; // Divide by zero
7+
c = c + 1;
8+
int e = a / c;
9+
return 0;
10+
}

lab1/test/simple7.c

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int main() {
2+
int a, b;
3+
int c = 0;
4+
b = c;
5+
a = b;
6+
int d = a / c; // Divide by zero
7+
c = c + 1;
8+
c = c * 0;
9+
int e = a / c; // Divide by zero
10+
return 0;
11+
}

lab1/test/simple8.c

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main() {
2+
int a = 1;
3+
int b = a / 0; // Divide by zero
4+
return 0;
5+
}

lab1/test/simple9.c

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
int u1 = fgetc(stdin);
5+
int u2 = 4, d;
6+
if (u1 != 0) {
7+
d = u2 / u1; // Divide by zero
8+
} else {
9+
int d = u2 / (u1 + 1); // Divide by zero
10+
}
11+
return 0;
12+
}

0 commit comments

Comments
 (0)