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 // expected-note@+1 {{declared here}}
4 int I = 3;
5 // expected-error@+2 {{expression is not an integral constant expression}}
6 // expected-note@+1 {{read of non-const variable 'I' is not allowed in a constant expression}}
7 [unroll(I)]
8 while (I--);
9 }
10
11 void unroll_arg_count() {
12 [unroll(2,4)] // expected-error {{'unroll' attribute takes no more than 1 argument}}
13 for(int i=0; i<100; i++);
14 }
15
16 void loop_arg_count() {
17 [loop(2)] // expected-error {{'loop' attribute takes no more than 0 argument}}
18 for(int i=0; i<100; i++);
19 }
20
21 void unroll_no_negative() {
22 [unroll(-1)] // expected-error {{invalid value '-1'; must be positive}}
23 for(int i=0; i<100; i++);
24 }
25
26 void unroll_no_zero() {
27 [unroll(0)] // expected-error {{invalid value '0'; must be positive}}
28 for(int i=0; i<100; i++);
29 }
30
31 void unroll_no_float() {
32 [unroll(2.1)] // expected-error {{invalid argument of type 'float'; expected an integer type}}
33 for(int i=0; i<100; i++);
34 }
35
36 void unroll_no_bool_false() {
37 [unroll(false)] // expected-error {{invalid argument of type 'bool'; expected an integer type}}
38 for(int i=0; i<100; i++);
39 }
40
41 void unroll_no_bool_true() {
42 [unroll(true)] // expected-error {{invalid argument of type 'bool'; expected an integer type}}
43 for(int i=0; i<100; i++);
44 }
45
46 void unroll_loop_enforcement() {
47 int x[10];
48 [unroll(4)] // expected-error {{'unroll' attribute only applies to 'for', 'while', and 'do' statements}}
49 if (x[0])
50 x[0] = 15;
51 }