66 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -triple dxil-unknown-shadermodel6.3-library %s2 3// Note: As HLSL resource type are sizeless type, we don't exhaustively4// test for cases covered by sizeless-1.c and similar tests.5 6typedef int __hlsl_resource_t; // expected-error {{cannot combine with previous 'int' declaration specifier}} expected-warning {{typedef requires a name}}7typedef int __hlsl_resource_t[]; // expected-error {{cannot combine with previous 'int' declaration specifier}} expected-error {{expected unqualified-id}}8 9__hlsl_resource_t r1;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'}}12groupshared __hlsl_resource_t r11;13groupshared __hlsl_resource_t r12[10]; // expected-error {{array has sizeless element type 'groupshared __hlsl_resource_t'}}14groupshared __hlsl_resource_t r13[]; // expected-error {{array has sizeless element type 'groupshared __hlsl_resource_t'}}15 16static __hlsl_resource_t r21;17static __hlsl_resource_t r22[10]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}18static __hlsl_resource_t r23[]; // expected-error {{array has sizeless element type '__hlsl_resource_t'}}19 20cbuffer CB {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'}}24}25 26struct S {27 __hlsl_resource_t r1;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'}}30};31 32class C {33 __hlsl_resource_t r1;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'}}36};37 38union U {39 __hlsl_resource_t r1;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'}}42};43 44void f1(__hlsl_resource_t r1);45void f2(__hlsl_resource_t r2[10]); // expected-error {{array has sizeless element type '__hlsl_resource_t'}}46void f3(__hlsl_resource_t r3[]); // expected-error {{array has sizeless element type '__hlsl_resource_t'}}47 48__hlsl_resource_t f4();49 50void f(__hlsl_resource_t arg) {51 __hlsl_resource_t r1;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'}}54 55 static __hlsl_resource_t r4;56 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}}60 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'}}65}66