From b875baea08dd45e23fd5c60138b80ca9dfd39286 Mon Sep 17 00:00:00 2001 From: kalsprite Date: Mon, 24 Aug 2026 00:55:16 -0700 Subject: [PATCH] asm template doc category --- src/docs.cpp | 9 +++++++-- src/main.cpp | 1 + tests/issues/run.bat | 1 + tests/issues/run.sh | 10 ++++++++++ tests/issues/test_issue_asm_doc_category.odin | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/issues/test_issue_asm_doc_category.odin diff --git a/src/docs.cpp b/src/docs.cpp index 1d8886edb..5c3c13104 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -1,6 +1,6 @@ // Generates Documentation -gb_global int print_entity_kind_ordering[Entity_Count] = { +gb_global int print_entity_kind_ordering[] = { /*Invalid*/ -1, /*Constant*/ 0, /*Variable*/ 1, @@ -12,8 +12,10 @@ gb_global int print_entity_kind_ordering[Entity_Count] = { /*LibraryName*/ -1, /*Nil*/ -1, /*Label*/ -1, + /*AsmTemplate*/ 5, }; -gb_global char const *print_entity_names[Entity_Count] = { +GB_STATIC_ASSERT(gb_count_of(print_entity_kind_ordering) == Entity_Count); +gb_global char const *print_entity_names[] = { /*Invalid*/ "", /*Constant*/ "constants", /*Variable*/ "variables", @@ -25,7 +27,9 @@ gb_global char const *print_entity_names[Entity_Count] = { /*LibraryName*/ "library names", /*Nil*/ "", /*Label*/ "", + /*AsmTemplate*/ "asm templates", }; +GB_STATIC_ASSERT(gb_count_of(print_entity_names) == Entity_Count); gb_internal GB_COMPARE_PROC(cmp_entities_for_printing) { @@ -257,6 +261,7 @@ gb_internal void print_doc_package(CheckerInfo *info, AstPackage *pkg) { case Entity_ProcGroup: case Entity_ImportName: case Entity_LibraryName: + case Entity_AsmTemplate: // Fine break; } diff --git a/src/main.cpp b/src/main.cpp index 84ec22bdf..c5fb9ba1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3463,6 +3463,7 @@ gb_internal void print_show_unused(Checker *c) { case Entity_ProcGroup: case Entity_ImportName: case Entity_LibraryName: + case Entity_AsmTemplate: // Fine break; } diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 4cbb424b4..e793a9e84 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 doc ..\test_issue_asm_doc_category.odin -file 2>&1 | find /c "asm templates" | findstr /x "1" || 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..d4a653cdb 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 doc ../test_issue_asm_doc_category.odin -file 2>&1 | grep -c "asm templates") -eq 1 ]]; 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_doc_category.odin b/tests/issues/test_issue_asm_doc_category.odin new file mode 100644 index 000000000..ddf330d25 --- /dev/null +++ b/tests/issues/test_issue_asm_doc_category.odin @@ -0,0 +1,16 @@ +#+build amd64 +// `Entity_AsmTemplate` was added to `ENTITY_KINDS` but not to the two `[Entity_Count]` tables in +// `src/docs.cpp`, so its slot was zero-filled: ordering `0` and a null name. `odin doc` and +// `odin check -show-unused` printed an `asm` template under an empty category header, and passed +// the null name to a `%s`. +package test_issues + +DOC_CONST :: 1 + +doc_proc :: proc() {} + +doc_asm :: asm() { nop; } + +doc_asm_32 :: asm(a: i32) -> (v: i32) { mov v, a; } +doc_asm_64 :: asm(a: i64) -> (v: i64) { mov v, a; } +doc_asm_group :: asm { doc_asm_32, doc_asm_64 }