diff --git a/src/IRBuilder.cpp b/src/IRBuilder.cpp index d0df9ec..ceb7b72 100644 --- a/src/IRBuilder.cpp +++ b/src/IRBuilder.cpp @@ -37,6 +37,11 @@ void IRBuilder::create_program(std::shared_ptr program) { Error::throw_error_without_location(format_string("Missing entry point: %s", Arguments::values["entry"])); } + if (module->getFunction(Arguments::values["entry"])->empty()) + { + Error::throw_error_without_location( + format_string("Entry point %s has no body", Arguments::values["entry"])); + } } } diff --git a/tests/declare-main.json b/tests/declare-main.json index 7b86ff5..4781f95 100644 --- a/tests/declare-main.json +++ b/tests/declare-main.json @@ -2,8 +2,8 @@ "file": "declare-main.sp", "compile": { "flags": [], - "exit-code": 0, + "exit-code": 1, "stdout": "", - "stderr": "" + "stderr": "\u001b[1;1m\u001b[31;49merror: \u001b[0;0mEntry point main has no body\n" } } \ No newline at end of file