From 366c33e5afc336986cd0c5848ddabb23a7c38e03 Mon Sep 17 00:00:00 2001 From: kalsprite Date: Sun, 23 Aug 2026 23:17:55 -0700 Subject: [PATCH] Delete dead code that crashed the checker on an asm template group with no parameters --- src/types.cpp | 8 ----- tests/issues/run.bat | 1 + tests/issues/run.sh | 10 +++++++ .../test_issue_asm_group_empty_params.odin | 29 +++++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 tests/issues/test_issue_asm_group_empty_params.odin diff --git a/src/types.cpp b/src/types.cpp index d12d8dbee..54481098b 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -3722,14 +3722,6 @@ gb_internal ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y) return ProcOverload_TargetFeatures; } - if (px.params != nullptr && py.params != nullptr) { - Entity *ex = px.params->Tuple.variables[0]; - Entity *ey = py.params->Tuple.variables[0]; - bool ok = are_types_identical(ex->type, ey->type); - if (ok) { - } - } - return ProcOverload_Identical; } diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 4cbb424b4..4978b146e 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -46,6 +46,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin check ..\test_issue_ellipsis_type_call.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "10" || exit /b ..\..\..\odin check ..\test_issue_foreign_redeclaration.odin -no-entry-point %COMMON% || exit /b ..\..\..\odin check ..\test_issue_foreign_redeclaration_mismatch.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b +..\..\..\odin check ..\test_issue_asm_group_empty_params.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b ..\..\..\odin build ..\test_issue_7037.odin %COMMON% -o:none || exit /b ..\..\..\odin build ..\test_issue_7188.odin %COMMON% || exit /b clang -c ..\test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 98c144d9c..3d3746339 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -110,6 +110,16 @@ else exit 1 fi +# `asm` templates are amd64-only, so this file is empty on every other architecture +if [[ "$(uname -m)" == "x86_64" || "$(uname -m)" == "amd64" ]]; then + if [[ $($ODIN check ../test_issue_asm_group_empty_params.odin -no-entry-point $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]]; then + echo "SUCCESSFUL 1/1" + else + echo "SUCCESSFUL 0/1" + exit 1 + fi +fi + if [[ $($ODIN build ../test_issue_7108.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then echo "SUCCESSFUL 1/1" else diff --git a/tests/issues/test_issue_asm_group_empty_params.odin b/tests/issues/test_issue_asm_group_empty_params.odin new file mode 100644 index 000000000..f35dcf0af --- /dev/null +++ b/tests/issues/test_issue_asm_group_empty_params.odin @@ -0,0 +1,29 @@ +#+build amd64 +// A zero-parameter asm template carries a non-null but empty parameter tuple, unlike a +// zero-parameter procedure, so dead code at the end of `are_proc_types_overload_safe` indexed +// `variables[0]` on it and tripped the bounds assertion. The duplicate-signature diagnostic the +// checker was about to print was lost, and the crash arrived with nothing else on stderr. +package test_issues + +nop_a :: asm() { nop; } +nop_b :: asm() { nop; } +dup_no_params :: asm { nop_a, nop_b } + +out_a :: asm() -> (r: u64) [r = %rax] { nop; } +out_b :: asm() -> (r: u64) [r = %rax] { nop; } +dup_result_only :: asm { out_a, out_b } + +three_a :: asm() { nop; } +three_b :: asm() { nop; } +three_c :: asm() { nop; } +dup_three :: asm { three_a, three_b, three_c } + +// a group whose members differ in their parameters has to keep resolving cleanly +add32 :: asm(a: u32, b: u32) -> (r: u32) { mov r, a; add r, b; } +add64 :: asm(a: u64, b: u64) -> (r: u64) { mov r, a; add r, b; } +add_ok :: asm { add32, add64 } + +use :: proc() { + _ = add_ok(u32(20), u32(22)) + _ = add_ok(u64(1), u64(2)) +}