This is an archive of the discontinued LLVM Phabricator instance.

Treat opencl_unroll_hint subject errors as semantic rather than parse errors
ClosedPublic

Authored by aaron.ballman on Feb 4 2021, 8:16 AM.

Details

Reviewers
Anastasia
Summary

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.

Diff Detail

Event Timeline

aaron.ballman created this revision.Feb 4 2021, 8:16 AM
aaron.ballman requested review of this revision.Feb 4 2021, 8:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2021, 8:16 AM
Anastasia accepted this revision.Feb 5 2021, 2:39 AM

LGTM! Thanks for fixing this.

This revision is now accepted and ready to land.Feb 5 2021, 2:39 AM
aaron.ballman closed this revision.Feb 5 2021, 4:21 AM

Thanks for the review! I've commit in 45ccfd9c9d0311371a8217c15c2ef3ba969a0aff