Debian Codegraph @

clang/test/SemaHLSL/shader_type_attr.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -DFAIL -verify
3
4 // FileCheck test make sure HLSLShaderAttr is generated in AST.
5 // verify test make sure validation on shader type attribute works as expected.
6
7 #ifdef FAIL
8
9 // expected-warning@+1 {{'shader' attribute only applies to global functions}}
10 [shader("compute")]
11 struct Fido {
12 // expected-warning@+1 {{'shader' attribute only applies to global functions}}
13 [shader("pixel")]
14 void wag() {}
15 // expected-warning@+1 {{'shader' attribute only applies to global functions}}
16 [shader("vertex")]
17 static void oops() {}
18 };
19
20 // expected-warning@+1 {{'shader' attribute only applies to global functions}}
21 [shader("vertex")]
22 static void oops() {}
23
24 namespace spec {
25 // expected-warning@+1 {{'shader' attribute only applies to global functions}}
26 [shader("vertex")]
27 static void oops() {}
28 } // namespace spec
29
30 // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
31 [shader("pixel")]
32 // expected-note@+1 {{conflicting attribute is here}}
33 [shader("vertex")]
34 int doubledUp() : A {
35 return 1;
36 }
37
38 // expected-note@+1 {{conflicting attribute is here}}
39 [shader("vertex")]
40 void forwardDecl();
41
42 // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
43 [shader("compute")][numthreads(8,1,1)]
44 void forwardDecl() {
45 }
46
47 // expected-error@+1 {{'shader' attribute takes one argument}}
48 [shader()]
49 // expected-error@+1 {{expected string literal as argument of 'shader' attribute}}
50 [shader(1, 2)]
51 // expected-error@+1 {{expected string literal as argument of 'shader' attribute}}
52 [shader(1)]
53 // expected-warning@+1 {{'shader' attribute argument not supported: cs}}
54 [shader("cs")]
55 // expected-warning@+1 {{'shader' attribute argument not supported: library}}
56 [shader("library")]
57 #endif // END of FAIL
58
59 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:61:2, col:18> Compute
60 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
61 [shader("compute")][numthreads(8,1,1)]
62 void entry() {
63 }
64
65 // Because these two attributes match, they should both appear in the AST
66 [shader("compute")][numthreads(8,1,1)]
67 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:66:2, col:18> Compute
68 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
69 void secondFn();
70
71 [shader("compute")][numthreads(8,1,1)]
72 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:71:2, col:18> Compute
73 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
74 void secondFn() {
75 }