From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4HzVBBtVEGfvSAAA62LTzQ:P1 (envelope-from ) for ; Thu, 17 Oct 2024 02:06:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 4HzVBBtVEGfvSAAA62LTzQ (envelope-from ) for ; Thu, 17 Oct 2024 02:06:51 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; none Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EC99D5B349 for ; Thu, 17 Oct 2024 02:06:50 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=mHrFPFc+H3vAbDa1zRbhcpDwz8p3Ws071HXEgsqP0sg=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1729123610; v=1; b=JOpmdUeO1UVb3YyMZgDuywkdgJr4WbnlArr6P8456JpBhlY9ZNqfokecvFR6WkZ4S4pGFqrd NBEGzHYsLBindbHxtxt4pwFqJCueePZskHN4WkaXwT2xRBy8z8vX97J7UTAhJhE1jnbyODM2E8E OtTlbs4Pcyn1mL+leAMC5nzsn9V5td34afo/GVtHT1TSem6VkIsA+YaLCUf+OBNRzbte3kl59wr N6tvqwhVVjK0wBR5W3IAv2ycl+k8KXfLAUUGjrf6lm064uf1Y36S1ODYbQFx7WJx/1qcj7FruFr 65vgVh8fSIeRHIlprVHLmSlzK5oszfVZTVduEeNHBa25Q== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 9CBD8202D5 for ; Thu, 17 Oct 2024 00:06:50 +0000 (UTC) Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) by mail-a.sr.ht (Postfix) with ESMTPS id EC83F202B2 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 17 Oct 2024 00:06:49 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1729123609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X4b8x/Pi6Q44sAeYE5a2XWVwEFJecrML7wV98W16qwc=; b=V7Hr/tFkBfw0Ddsvl4/eDc2ax52W343MsRV5WHRYD0So4+5b3ClGiz/n/PRGjONQsJz1vw 7+g1CIHYqj/tCxWcZm4dtVkakbfJ/AoDZhmErkEXd539FjYVvc+DVvsaRy2W+V3/JlqvCD 81lAweO9zBEqWRjP5J9Pcu/TsoeI/cgJcXTMboVDLJTx+ZHx0hkajTBM074pXqc9OPD31t tsj7+uwQTYCE63Q+4P2kMpwcWAWY79vKk4YbFoOulSsss/b8zxpLoNRLO3o1QWKUpqYRI2 zczGuYlzVAIRZeZa4wP3ClEE7U+I3iSaycdtYbctlQFQDFNIWtPdycv8sDqlNA== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v1 3/3] codegen: x64: compile extern function definition Date: Thu, 17 Oct 2024 04:04:44 +0200 Message-ID: <20241017020603.551431-4-johnny@johnnyrichard.com> In-Reply-To: <20241017020603.551431-1-johnny@johnnyrichard.com> References: <20241017020603.551431-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Sourcehut-Patchset-Status: UNKNOWN List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -4.00 X-Spam-Score: -4.00 X-Migadu-Queue-Id: EC99D5B349 X-Migadu-Scanner: mx13.migadu.com X-TUID: zR6UkPTu+4+m Signed-off-by: Johnny Richard --- src/checker.c | 4 +++- src/codegen_x86_64.c | 4 ++++ tests/olc/0037_variable_overflow.ol | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/checker.c b/src/checker.c index 0acab13..02341cc 100644 --- a/src/checker.c +++ b/src/checker.c @@ -141,7 +141,9 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) item = list_next(item); } - populate_scope(checker, fn_def->scope, ast->as_fn_def.block); + if (ast->as_fn_def.block != NULL) { + populate_scope(checker, fn_def->scope, ast->as_fn_def.block); + } return; } diff --git a/src/codegen_x86_64.c b/src/codegen_x86_64.c index 6758fc1..1951365 100644 --- a/src/codegen_x86_64.c +++ b/src/codegen_x86_64.c @@ -887,6 +887,10 @@ static void codegen_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn_def) { + if (fn_def->_extern) { + return; + } + fprintf(codegen->out, ".globl " SV_FMT "\n", SV_ARG(fn_def->id)); codegen->base_offset = 0; diff --git a/tests/olc/0037_variable_overflow.ol b/tests/olc/0037_variable_overflow.ol index 2b7c8c2..be36e77 100644 --- a/tests/olc/0037_variable_overflow.ol +++ b/tests/olc/0037_variable_overflow.ol @@ -19,9 +19,9 @@ fn main(): u32 { return putchar(111) } -# XTEST test_compile(exit_code=0) +# TEST test_compile(exit_code=0) # -# XTEST test_run_binary(exit_code=0) +# TEST test_run_binary(exit_code=111) # # TEST test_ast WITH # Translation_Unit -- 2.46.0