32 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s2 3typedef float float2 __attribute__((ext_vector_type(2)));4typedef float float3 __attribute__((ext_vector_type(3)));5 6struct S { float f; };7struct S2 { float f; int i; };8 9[numthreads(1,1,1)]10void entry() {11 float2 LilVec = float2(1.0, 2.0);12 float2 BrokenVec = float2(1.0, 2.0, 3.0); // expected-error{{too many initializers in list for type 'float2' (vector of 2 'float' values) (expected 2 but found 3)}}13 float3 NormieVec = float3(LilVec, 3.0, 4.0); // expected-error{{too many initializers in list for type 'float3' (vector of 3 'float' values) (expected 3 but found 4)}}14 float3 BrokenNormie = float3(3.0, 4.0); // expected-error{{too few initializers in list for type 'float3' (vector of 3 'float' values) (expected 3 but found 2)}}15 float3 OverwhemledNormie = float3(3.0, 4.0, 5.0, 6.0); // expected-error{{too many initializers in list for type 'float3' (vector of 3 'float' values) (expected 3 but found 4)}}16 17 // These next two are a bit strange, but are consistent with HLSL today.18 S s;19 float2 GettingStrange = float2(s, s);20 S2 s2 = {1.0f, 2};21 float2 AlsoStrange = float2(s2);22 23 float2 TooManyStruts = float2(s2, s); // expected-error{{too many initializers in list for type 'float2' (vector of 2 'float' values) (expected 2 but found 3)}}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 float2 foo5 = float2(t, t); // expected-error{{too few initializers in list for type 'float2' (vector of 2 'float' values) (expected 2 but found 0)}}31}32