mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
User defined attributes.
This commit is contained in:
committed by
Christoffer Lerno
parent
b0c55ff777
commit
e09e5c06d3
17
test/test_suite/attributes/recursive_attributes.c3
Normal file
17
test/test_suite/attributes/recursive_attributes.c3
Normal file
@@ -0,0 +1,17 @@
|
||||
module test;
|
||||
|
||||
define @Align(y) = @Align16(y / 2);
|
||||
define @Align16(x) = @align(4), @Align(8 * x); // #error: Recursive declaration of attribute
|
||||
define @Test = @noinline;
|
||||
struct Foo
|
||||
{
|
||||
int z;
|
||||
int xy @Align16(8);
|
||||
}
|
||||
|
||||
Foo f;
|
||||
|
||||
fn void testme() @Test
|
||||
{
|
||||
int x;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
fn void test()
|
||||
{
|
||||
for (int a @align(16) @align(16) = 0 ; a < 10; a++) // #error: Repeat of attribute '@align'
|
||||
{
|
||||
}
|
||||
}
|
||||
45
test/test_suite/attributes/user_defined_attributes.c3t
Normal file
45
test/test_suite/attributes/user_defined_attributes.c3t
Normal file
@@ -0,0 +1,45 @@
|
||||
// #target: macos-x64
|
||||
|
||||
module test;
|
||||
|
||||
define @Align(y) = @align(y);
|
||||
define @Align16(x) = @Align(8 * x), @align(1024);
|
||||
define @Test = @noinline;
|
||||
define @TestZero;
|
||||
struct Foo
|
||||
{
|
||||
int z;
|
||||
int xy @Align16(8);
|
||||
}
|
||||
|
||||
Foo f;
|
||||
|
||||
fn void testme() @Test
|
||||
{
|
||||
int x;
|
||||
}
|
||||
|
||||
fn void main() @TestZero
|
||||
{
|
||||
testme();
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
%Foo = type { i32, [1020 x i8], i32, [1020 x i8] }
|
||||
|
||||
@introspect.Foo = linkonce constant i8 1
|
||||
@test.f = local_unnamed_addr global %Foo zeroinitializer, align 1024
|
||||
|
||||
define void @test.testme() #0 {
|
||||
entry:
|
||||
%x = alloca i32, align 4
|
||||
store i32 0, i32* %x, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @test.main() #1 {
|
||||
entry:
|
||||
call void @test.testme()
|
||||
ret void
|
||||
}
|
||||
Reference in New Issue
Block a user