1 // RUN: %clang_cc1 -fsyntax-only -verify -triple dxil-unknown-shadermodel6.3-library %s
3 // Note: As HLSL resource type are sizeless type, we don't exhaustively
4 // test for cases covered by sizeless-1.c and similar tests.
6 typedef int __hlsl_resource_t; // expected-error {{cannot combine with previous 'int' declaration specifier}} expected-warning {{typedef requires a name}}
7 typedef int __hlsl_resource_t[]; // expected-error {{cannot combine with previous 'int' declaration specifier}} expected-error {{expected unqualified-id}}
10 __hlsl_resource_t r2[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
11 __hlsl_resource_t r3[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
12 groupshared __hlsl_resource_t r11;
13 groupshared __hlsl_resource_t r12[10]; // expected-error {{array has sizeless element type 'groupshared __hlsl_resource_t'}}
14 groupshared __hlsl_resource_t r13[]; // expected-error {{array has sizeless element type 'groupshared __hlsl_resource_t'}}
16 static __hlsl_resource_t r21;
17 static __hlsl_resource_t r22[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
18 static __hlsl_resource_t r23[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
21 __hlsl_resource_t r31;
22 __hlsl_resource_t r32[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
23 __hlsl_resource_t r33[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
28 __hlsl_resource_t r2[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
29 __hlsl_resource_t r3[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
34 __hlsl_resource_t r2[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
35 __hlsl_resource_t r3[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
40 __hlsl_resource_t r2[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
41 __hlsl_resource_t r3[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
44 void f1(__hlsl_resource_t r1);
45 void f2(__hlsl_resource_t r2[10]); // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
46 void f3(__hlsl_resource_t r3[]); // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
48 __hlsl_resource_t f4();
50 void f(__hlsl_resource_t arg) {
52 __hlsl_resource_t r2[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
53 __hlsl_resource_t r3[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}
55 static __hlsl_resource_t r4;
57 __hlsl_resource_t foo = arg;
58 int a = arg; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__hlsl_resource_t'}}
59 int b = arg[0]; // expected-error {{subscripted value is not an array, pointer, or vector}}
61 foo == arg; // expected-error {{invalid operands to binary expression ('__hlsl_resource_t' and '__hlsl_resource_t')}}
62 foo + arg; // expected-error {{invalid operands to binary expression ('__hlsl_resource_t' and '__hlsl_resource_t')}}
63 foo && arg; // expected-error {{invalid operands to binary expression ('__hlsl_resource_t' and '__hlsl_resource_t')}} expected-error {{value of type '__hlsl_resource_t' is not contextually convertible to 'bool'}}
64 arg++; // expected-error {{cannot increment value of type '__hlsl_resource_t'}}