xref: /llvm-project/clang/test/Parser/opencl-unroll-hint.cl (revision 45ccfd9c9d0311371a8217c15c2ef3ba969a0aff)
1//RUN: %clang_cc1 -cl-std=CL2.0 -fsyntax-only -verify %s
2
3kernel void B (global int *x) {
4  __attribute__((opencl_unroll_hint(42))) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
5  if (x[0])
6    x[0] = 15;
7}
8
9void parse_order_error() {
10  // Ensure we properly diagnose OpenCL loop attributes on the incorrect
11  // subject in the presence of other attributes.
12  int i = 1000;
13  __attribute__((nomerge, opencl_unroll_hint(8))) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
14  if (i) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
15
16  __attribute__((opencl_unroll_hint(8), nomerge)) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
17  if (i) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
18
19  __attribute__((nomerge, opencl_unroll_hint(8))) // OK
20  while (1) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
21}
22