While working on a downstream project, I noticed some issues with the opencl_unroll_hint implementation. 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 patch address the issues by clarifying that opencl_unroll_hint is a statement attribute and handling 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.