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() {
35 return 1;
36 }
37
38 // expected-note@+1 {{conflicting attribute is here}}
39 [shader("vertex")]
40 int forwardDecl();
41
42 // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
43 [shader("compute")][numthreads(8,1,1)]
44 int forwardDecl() {
45 return 1;
46 }
47
48 // expected-error@+1 {{'shader' attribute takes one argument}}
49 [shader()]
50 // expected-error@+1 {{expected string literal as argument of 'shader' attribute}}
51 [shader(1, 2)]
52 // expected-error@+1 {{expected string literal as argument of 'shader' attribute}}
53 [shader(1)]
54 // expected-warning@+1 {{'shader' attribute argument not supported: cs}}
55 [shader("cs")]
56 // expected-warning@+1 {{'shader' attribute argument not supported: library}}
57 [shader("library")]
58 #endif // END of FAIL
59
60 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:62:2, col:18> Compute
61 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
62 [shader("compute")][numthreads(8,1,1)]
63 int entry() {
64 return 1;
65 }
66
67 // Because these two attributes match, they should both appear in the AST
68 [shader("compute")][numthreads(8,1,1)]
69 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:68:2, col:18> Compute
70 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
71 int secondFn();
72
73 [shader("compute")][numthreads(8,1,1)]
74 // CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}} <line:73:2, col:18> Compute
75 // CHECK:HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <col:21, col:37> 8 1 1
76 int secondFn() {
77 return 1;
78 }