
The attribute definition claimed the attribute was inheritable (which only applies to declaration attributes) and not a statement attribute. Further, it treats subject appertainment errors as being parse errors rather than semantic errors, which leads to us accepting invalid code. For instance, we currently fail to reject: void foo() { int i = 1000; __attribute__((nomerge, opencl_unroll_hint(8))) if (i) { foo(); } } This addresses the issues by clarifying that opencl_unroll_hint is a statement attribute and handles its appertainment checks in the semantic layer instead of the parsing layer. This changes the output of the diagnostic text to be more consistent with other appertainment errors.
22 lines
1.1 KiB
Common Lisp
22 lines
1.1 KiB
Common Lisp
//RUN: %clang_cc1 -cl-std=CL2.0 -fsyntax-only -verify %s
|
|
|
|
kernel void B (global int *x) {
|
|
__attribute__((opencl_unroll_hint(42))) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
|
|
if (x[0])
|
|
x[0] = 15;
|
|
}
|
|
|
|
void parse_order_error() {
|
|
// Ensure we properly diagnose OpenCL loop attributes on the incorrect
|
|
// subject in the presence of other attributes.
|
|
int i = 1000;
|
|
__attribute__((nomerge, opencl_unroll_hint(8))) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
|
|
if (i) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
|
|
|
|
__attribute__((opencl_unroll_hint(8), nomerge)) // expected-error {{'opencl_unroll_hint' attribute only applies to 'for', 'while', and 'do' statements}}
|
|
if (i) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
|
|
|
|
__attribute__((nomerge, opencl_unroll_hint(8))) // OK
|
|
while (1) { parse_order_error(); } // Recursive call silences unrelated diagnostic about nomerge.
|
|
}
|