sem: Missing return statements in test cases
mewmew opened this issue · 1 comments
There are three test cases which have missing return statements. Should we add the missing return statements to these test cases, or simply return an error?
- testdata/quiet/mips/m01.c
- testdata/noisy/advanced/eval.c
At least one of the test cases is more involved, and it would be interesting to see if the later stages of the compiler are capable of handling it properly. Therefore, I would suggest we patch at least the expr.c
test case, to include the missing return statement. The rationale being that these semantic analysis test cases were never intended to check if a return statement was missing. It just so happens that our implementation is more strict than other C compilers.
Compiling "testdata/quiet/mips/m01.c"
(testdata/quiet/mips/m01.c:13) error: missing return at end of non-void function "mov"
}
^
Compiling "testdata/noisy/advanced/eval.c"
(testdata/noisy/advanced/eval.c:115) error: missing return at end of non-void function "expr"
}
^
The diff to fix these test cases is trivial:
@x1 ~/D/g/s/g/m/uc> git diff -w
diff --git a/testdata/noisy/advanced/eval.c b/testdata/noisy/advanced/eval.c
index 8533f0d..f86cd4e 100644
--- a/testdata/noisy/advanced/eval.c
+++ b/testdata/noisy/advanced/eval.c
@@ -112,6 +112,7 @@ int expr(int l) {
return a;
}
}
+ return 0;
}
int main(void) {
diff --git a/testdata/quiet/mips/m01.c b/testdata/quiet/mips/m01.c
index 4fce036..2748ab9 100644
--- a/testdata/quiet/mips/m01.c
+++ b/testdata/quiet/mips/m01.c
@@ -10,6 +10,7 @@ void jal(void) {
int mov(int lb) {
addi = lb;
+ return 0;
}
int main (void) {
What do you reckon @sangisos, should we leave the test cases be or include a missing return statement?