brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · e60a865 Raw
32 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s2 3typedef float float2x1 __attribute__((matrix_type(2,1)));4typedef float float2x2 __attribute__((matrix_type(2,2)));5typedef float float2 __attribute__((ext_vector_type(2)));6 7struct S { float f; };8struct S2 { float2 f;};9 10[numthreads(1,1,1)]11void entry() {12 float2x1 LilMat = float2x1(1.0, 2.0);13 float2x1 BrokenMat = float2x1(1.0, 2.0, 3.0); // expected-error{{too many initializers in list for type 'float2x1' (aka 'matrix<float, 2, 1>') (expected 2 but found 3)}}14 float2x2 NormieMat = float2x2(LilMat, 3.0, 4.0, 5.0); // expected-error{{too many initializers in list for type 'float2x2' (aka 'matrix<float, 2, 2>') (expected 4 but found 5)}}15 float2x2 BrokenNormie = float2x2(3.0, 4.0); // expected-error{{too few initializers in list for type 'float2x2' (aka 'matrix<float, 2, 2>') (expected 4 but found 2)}}16 float2x1 OverwhemledNormie = float2x1(3.0, 4.0, 5.0, 6.0); // expected-error{{too many initializers in list for type 'float2x1' (aka 'matrix<float, 2, 1>') (expected 2 but found 4)}}17 18  // These should work in HLSL and not error19  S s;20  float2x1 GettingStrange = float2x1(s, s); 21 22  S2 s2;23  float2x2 GettingStrange2 = float2x2(s2, s2); 24 25  // HLSL does not yet allow user-defined conversions.26  struct T {27    operator float() const { return 1.0f; }28  } t;29  // TODO: Should this work? Today HLSL doesn't resolve user-defined conversions here, but we maybe should...30  float2x1 foo5 = float2x1(t, t); // expected-error{{too few initializers in list for type 'float2x1' (aka 'matrix<float, 2, 1>') (expected 2 but found 0)}}31}32