From 061d662f81baeb8f2a90d3c7263614bfa1f04e01 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Tue, 11 Oct 2022 13:44:29 +0200 Subject: [PATCH] Fix reference to literal --- build.bat | 2 +- core_typechecking.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.bat b/build.bat index 2cffc7d..2ca6f08 100644 --- a/build.bat +++ b/build.bat @@ -3,5 +3,5 @@ pushd %~dp0 rem cl main.cpp -I.. user32.lib clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o main.exe -Wl,user32.lib -ubuntu run clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o core.out +rem ubuntu run clang core_main.cpp -O0 -Wall -Wno-unused-function -fno-exceptions -fdiagnostics-absolute-paths -g -o core.out popd diff --git a/core_typechecking.cpp b/core_typechecking.cpp index b91f187..db65b38 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -1344,13 +1344,16 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str rewrite_into_const(node, Ast_Array, value.value); } - node->resolved_type = type_pointer(value.type_val); return operand_type(node->resolved_type); } else{ compiler_error(node->pos, "Dereferencing expression %Q that is not a [Pointer] or [Type]", typestring(value.type)); return {}; } } else if(node->op == TK_Dereference){ + if(!value.is_lvalue){ + compiler_error(node->pos, "Can't take a pointer of this expression. It's not bound to anything so taking a pointer of it would be pretty silly."); + } + node->resolved_type = type_pointer(value.type); return operand_lvalue_set_flag_on_node(node->resolved_type, node); }