brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · c94dc58 Raw
52 lines · plain
1// RUN: %clang_cc1 -O0 -finclude-default-header -fsyntax-only -triple dxil-pc-shadermodel6.6-library %s -verify2void 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 11void 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 16void 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 21void unroll_no_negative() {22  [unroll(-1)] // expected-error {{invalid value '-1'; must be positive}}23  for(int i=0; i<100; i++);24}25 26void unroll_no_zero() {27  [unroll(0)] // expected-error {{invalid value '0'; must be positive}}28  for(int i=0; i<100; i++);29}30 31void 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 36void 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 41void 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 46void 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}52