fixed: end of file diagnostics

This commit is contained in:
Sven Vogel 2024-06-12 12:47:50 +02:00
parent b23ce945ea
commit 439126af87
2 changed files with 10 additions and 2 deletions

View File

@ -76,6 +76,11 @@ void delete_files(ModuleFileStack *stack) {
// behaves like fgets except that it has defined behavior when n == 1 // behaves like fgets except that it has defined behavior when n == 1
static void custom_fgets(char *buffer, size_t n, FILE *stream) { static void custom_fgets(char *buffer, size_t n, FILE *stream) {
if (feof(stream)) {
buffer[0] = '\n';
buffer[1] = 0;
return;
}
if (n == 1) { if (n == 1) {
buffer[0] = (char) fgetc(stream); buffer[0] = (char) fgetc(stream);
buffer[1] = 0; buffer[1] = 0;

View File

@ -372,10 +372,13 @@ BackendError impl_variable_load(LLVMBackendCompileUnit *unit, LLVMLocalScope *sc
} else { } else {
type = variable->impl.declaration.type; type = variable->impl.declaration.type;
} }
get_type_impl(unit, scope->func_scope->global_scope, type, &llvm_type); get_type_impl(unit, scope->func_scope->global_scope, type, &llvm_type);
if (LLVMGetTypeKind(LLVMTypeOf(llvm_variable)) == LLVMPointerTypeKind) {
*llvm_result = LLVMBuildLoad2(builder, llvm_type, llvm_variable, ""); *llvm_result = LLVMBuildLoad2(builder, llvm_type, llvm_variable, "");
} else {
*llvm_result = llvm_variable;
}
} }
return SUCCESS; return SUCCESS;