mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-13 12:36:36 -04:00
A procedure with `@(disabled=true)` adds no dependency where it is used, so that the calls to it, which are removed, do not pull it in. Taking its value, e.g. `rawptr(assert)` with `-disable-assert`, then referenced a procedure that was never generated, and LLVM asserted "missing procedure 'assert'". Add the dependency for every use that is not the callee of a call.
27 lines
629 B
Odin
27 lines
629 B
Odin
// Calls to a `@(disabled=true)` procedure are removed, but its value can still be taken.
|
|
// Built with `-disable-assert`, `rawptr(assert)` used to fail with "missing procedure 'assert'".
|
|
|
|
package test_issues
|
|
|
|
import "base:runtime"
|
|
import "core:testing"
|
|
|
|
@(disabled=true)
|
|
disabled_proc :: proc(n: ^int) { n^ += 1 }
|
|
|
|
global_assert := rawptr(assert)
|
|
|
|
@(test)
|
|
test_disabled_proc_value :: proc(t: ^testing.T) {
|
|
testing.expect(t, rawptr(assert) != nil)
|
|
testing.expect(t, rawptr(runtime.assert) == global_assert)
|
|
|
|
n := 0
|
|
disabled_proc(&n)
|
|
testing.expect_value(t, n, 0)
|
|
|
|
p := disabled_proc
|
|
p(&n)
|
|
testing.expect_value(t, n, 1)
|
|
}
|