From 64f1e8b7a262ebee08900bc2f7e88fe6ad7132e8 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Sat, 8 Oct 2022 14:55:20 +1100 Subject: [PATCH 1/4] Github CI: Add test case for issue 2113 --- .github/workflows/ci.yml | 8 ++++++++ tests/issues/run.bat | 16 ++++++++++++---- tests/issues/run.sh | 13 ++++++++----- tests/issues/test_issue_2113.odin | 13 +++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/issues/test_issue_2113.odin diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d8e10d59..5da70931f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,10 @@ jobs: cd tests/vendor make timeout-minutes: 10 + - name: Odin issues tests + run: | + cd tests/issues + ./run.sh - name: Odin check examples/all for Linux i386 run: ./odin check examples/all -vet -strict-style -target:linux_i386 timeout-minutes: 10 @@ -151,6 +155,10 @@ jobs: cd tests\vendor call build.bat timeout-minutes: 10 + - name: Odin issues tests + run: | + cd tests/issues + ./run.bat - name: core:math/big tests shell: cmd run: | diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 2ecd14d95..c526fd472 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -1,15 +1,23 @@ @echo off if not exist "build\" mkdir build +pushd build -set COMMON=-collection:tests=.. +set COMMON=-collection:tests=..\.. + +set ERROR_DID_OCCUR=0 @echo on -..\..\odin test test_issue_829.odin %COMMON% -file -..\..\odin test test_issue_1592.odin %COMMON% -file -..\..\odin test test_issue_2087.odin %COMMON% -file +..\..\..\odin test ..\test_issue_829.odin %COMMON% -file +..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file +..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file +..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug @echo off +if %ERRORLEVEL% NEQ 0 set ERROR_DID_OCCUR=1 + +popd rmdir /S /Q build +if %ERROR_DID_OCCUR% NEQ 0 EXIT /B 1 diff --git a/tests/issues/run.sh b/tests/issues/run.sh index f781c8278..440c953d9 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -2,15 +2,18 @@ set -eu mkdir -p build -ODIN=../../odin -COMMON="-collection:tests=.." +pushd build +ODIN=../../../odin +COMMON="-collection:tests=../.." set -x -$ODIN test test_issue_829.odin $COMMON -file -$ODIN test test_issue_1592.odin $COMMON -file -$ODIN test test_issue_2087.odin $COMMON -file +$ODIN test ../test_issue_829.odin $COMMON -file +$ODIN test ../test_issue_1592.odin $COMMON -file +$ODIN test ../test_issue_2087.odin $COMMON -file +$ODIN build ../test_issue_2113.odin $COMMON -file -debug set +x +popd rm -rf build diff --git a/tests/issues/test_issue_2113.odin b/tests/issues/test_issue_2113.odin new file mode 100644 index 000000000..dab9c7d07 --- /dev/null +++ b/tests/issues/test_issue_2113.odin @@ -0,0 +1,13 @@ +// Tests issue #2113 https://github.com/odin-lang/Odin/issues/2113 +// Causes a panic on compilation +package test_issues + +T :: struct { + a: int, +} + +main :: proc() { + array: #soa[1]T + a := &array[0] + _ = a +} From e188a542dae2268e62f7920f611f466759706347 Mon Sep 17 00:00:00 2001 From: Lucas Perlind Date: Sat, 8 Oct 2022 16:51:03 +1100 Subject: [PATCH 2/4] llvm_backend_debug: Add debug info for soa pointer This fixes issue #2113 --- src/llvm_backend_debug.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index ee2e03739..29b0ab488 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -293,6 +293,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Type_Named: GB_PANIC("Type_Named should be handled in lb_debug_type separately"); + case Type_SoaPointer: case Type_Pointer: return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->Pointer.elem), word_bits, word_bits, 0, nullptr, 0); case Type_MultiPointer: From ef0c6fc4b30a35678cc7190e56745770fbe553cc Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Sat, 8 Oct 2022 23:51:50 -0400 Subject: [PATCH 3/4] Fix signature for `shouldTerminateAfterLastWindowClosed` delegate proc --- vendor/darwin/Foundation/NSApplication.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index 2fc4e6356..d55a185f2 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -11,7 +11,7 @@ ActivationPolicy :: enum UInteger { ApplicationDelegate :: struct { willFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), didFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application), + shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> bool, user_data: rawptr, } @@ -34,9 +34,9 @@ Application_setDelegate :: proc(self: ^Application, delegate: ^ApplicationDelega del := (^ApplicationDelegate)(self->pointerValue()) del->didFinishLaunching(notification) } - shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) { + shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> bool { del := (^ApplicationDelegate)(self->pointerValue()) - del->shouldTerminateAfterLastWindowClosed(application) + return del->shouldTerminateAfterLastWindowClosed(application) } wrapper := Value.valueWithPointer(delegate) From 63086c7eaf3c0e97b1e8991fc94e146fb4efac38 Mon Sep 17 00:00:00 2001 From: Julian Ceipek Date: Sun, 9 Oct 2022 14:31:26 -0400 Subject: [PATCH 4/4] Use `NS.BOOL` instead of `bool` --- vendor/darwin/Foundation/NSApplication.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index d55a185f2..0b62687b7 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -11,7 +11,7 @@ ActivationPolicy :: enum UInteger { ApplicationDelegate :: struct { willFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), didFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> bool, + shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> BOOL, user_data: rawptr, } @@ -34,7 +34,7 @@ Application_setDelegate :: proc(self: ^Application, delegate: ^ApplicationDelega del := (^ApplicationDelegate)(self->pointerValue()) del->didFinishLaunching(notification) } - shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> bool { + shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> BOOL { del := (^ApplicationDelegate)(self->pointerValue()) return del->shouldTerminateAfterLastWindowClosed(application) }