Files
c3c/test/test_suite/enumerations/const_enum_with_function_ptr.c3t
Christoffer Lerno acc4a900f5 - New const enum declaration syntax.
- New enum associated value syntax.
2026-02-12 14:43:56 +01:00

36 lines
595 B
Plaintext

// #target: macos-x64
module test;
import std;
fn int foo() => 0;
alias FooFn = fn int();
enum Foo : (FooFn f)
{
FOO { fn int() => 0 }, // allowed
BAR { &foo }, // allowed
}
const enum Bar : FooFn
{
FOO = fn int() => 0, // allowed
BAR = &foo, // Error: Expected an constant enum value.
}
fn int main()
{
Bar b = FOO;
Bar b2 = BAR;
var $c = &foo == &foo;
return 0;
}
/* #expect: test.ll
define i32 @main() #0 {
entry:
%b = alloca ptr, align 8
%b2 = alloca ptr, align 8
store ptr @"test.$global$lambda2", ptr %b, align 8
store ptr @test.foo, ptr %b2, align 8
ret i32 0
}