Debian Codegraph @

clang/test/SemaHLSL/Loops/unroll.hlsl

raw
1 // RUN: %clang_cc1 -O0 -finclude-default-header -fsyntax-only -triple dxil-pc-shadermodel6.6-library %s -verify
2 void unroll_no_vars() {
3 int I = 3;
4 [unroll(I)] // expected-error {{'unroll' attribute requires an integer constant}}
5 while (I--);
6 }
7
8 void unroll_arg_count() {
9 [unroll(2,4)] // expected-error {{'unroll' attribute takes no more than 1 argument}}
10 for(int i=0; i<100; i++);
11 }
12
13 void loop_arg_count() {
14 [loop(2)] // expected-error {{'loop' attribute takes no more than 0 argument}}
15 for(int i=0; i<100; i++);
16 }
17
18 void unroll_no_negative() {
19 [unroll(-1)] // expected-error {{invalid value '-1'; must be positive}}
20 for(int i=0; i<100; i++);
21 }
22
23 void unroll_no_zero() {
24 [unroll(0)] // expected-error {{invalid value '0'; must be positive}}
25 for(int i=0; i<100; i++);
26 }
27
28 void unroll_no_float() {
29 [unroll(2.1)] // expected-error {{invalid argument of type 'float'; expected an integer type}}
30 for(int i=0; i<100; i++);
31 }
32
33 void unroll_no_bool_false() {
34 [unroll(false)] // expected-error {{invalid argument of type 'bool'; expected an integer type}}
35 for(int i=0; i<100; i++);
36 }
37
38 void unroll_no_bool_true() {
39 [unroll(true)] // expected-error {{invalid argument of type 'bool'; expected an integer type}}
40 for(int i=0; i<100; i++);
41 }
42
43 void unroll_loop_enforcement() {
44 int x[10];
45 [unroll(4)] // expected-error {{'unroll' attribute only applies to 'for', 'while', and 'do' statements}}
46 if (x[0])
47 x[0] = 15;
48 }