mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Add float[<3>] x = { .xy = 1.2, .z = 3.3 } swizzle initialization for vectors. #2599
This commit is contained in:
8
test/test_suite/vector/vector_init_swizzle.c3
Normal file
8
test/test_suite/vector/vector_init_swizzle.c3
Normal file
@@ -0,0 +1,8 @@
|
||||
fn int test()
|
||||
{
|
||||
int[<2>] v = { .xyz = 2 }; // #error: The 'z' component is not present in a vector of length 2, did you assume a longer vector?
|
||||
int[<2>] v2 = { .z = 2 }; // #error: The 'z' component is not present in a vector of length 2, did you assume a longer vector?
|
||||
int[<2>] v3 = { .yx = 2 }; // #error: Designated initializers using swizzling must be a contiguous range, like '.xyz = 123'
|
||||
int[<3>] v4 = { .xyz = 2 };
|
||||
int[<3>] v5 = { .xz = 2 }; // #error: Designated initializers using swizzling must be a contiguous range, like '.xyz = 123'
|
||||
}
|
||||
22
test/test_suite/vector/vector_init_swizzle_ok.c3t
Normal file
22
test/test_suite/vector/vector_init_swizzle_ok.c3t
Normal file
@@ -0,0 +1,22 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
import std;
|
||||
fn int main()
|
||||
{
|
||||
int[<2>] v = { .xy = 2 };
|
||||
int[<2>] v2 = { .x = 2, .y = 3 };
|
||||
int[<3>] v3 = { .z = 4, .xy = 1 };
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
entry:
|
||||
%v = alloca <2 x i32>, align 8
|
||||
%v2 = alloca <2 x i32>, align 8
|
||||
%v3 = alloca <3 x i32>, align 16
|
||||
store <2 x i32>
|
||||
store <2 x i32> <i32 2, i32 3>, ptr %v2, align 8
|
||||
store <4 x i32> <i32 1, i32 1, i32 4, i32 undef>, ptr %v3, align 16
|
||||
ret i32 0
|
||||
}
|
||||
Reference in New Issue
Block a user