1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
// RUN: %not %wgslc | %check
fn testWrongNumberOfArguments()
{
// CHECK: bitcast expects a single argument, found 2
_ = bitcast<i32>(0, 0);
// CHECK: bitcast expects a single argument, found 0
_ = bitcast<i32>();
}
fn testWrongNumberOfTemplateArguments()
{
// CHECK: bitcast expects a single template argument, found 2
_ = bitcast<i32, i32>(0);
// CHECK: bitcast expects a single template argument, found 0
_ = bitcast(0);
}
fn testInvalidConversion()
{
// CHECK: cannot bitcast from 'i32' to 'vec2<i32>'
_ = bitcast<vec2<i32>>(0);
// CHECK: cannot bitcast from 'vec2<i32>' to 'i32'
_ = bitcast<i32>(vec2(0));
}
fn testI32Overflow()
{
// CHECK-L: value 4294967295 cannot be represented as 'i32'
{ const x: f32 = bitcast<f32>(4294967295); }
}
fn testFunctionAsValue()
{
// CHECK-L: cannot use function 'testI32Overflow' as value
{ const x: f32 = bitcast<f32>(testI32Overflow); }
}
@group(0) @binding(1) var s: sampler;
@group(0) @binding(2) var t: texture_depth_2d;
fn testTypeCannotBeConcretized()
{
// CHECK-L: cannot bitcast from 'sampler' to 'i32'
let x = bitcast<i32>(s);
// CHECK-L: cannot bitcast from 'texture_depth_2d' to 'i32'
let x = bitcast<i32>(t);
}
|