This is an archive of the discontinued LLVM Phabricator instance.

[C++4OpenCL] Fix qualifiers check on binding references to temporaries
ClosedPublic

Authored by olestrohm on Jun 9 2021, 6:07 AM.

Details

Summary

Fixing the qualifiers check from PR49733.

It would be great to add some test, to increase the coverage, and because the erroneous check doesn't seem to trigger in any tests.
However I couldn't come up with a case that did trigger it, so it may be that it can't happen, or at least is very unlikely.

Fixes: PR49733

Diff Detail

Event Timeline

olestrohm created this revision.Jun 9 2021, 6:07 AM
olestrohm requested review of this revision.Jun 9 2021, 6:07 AM
Anastasia accepted this revision.Jun 17 2021, 8:27 AM

LGTM! Yes it seems the only situation where the check would evaluate to a different value with and without your patch is when we have RefRelationship == Sema::Ref_Related as false while the address space is not a superset then we would get an incorrect diagnostic. But I feel this would be diagnosed elsewhere before we end up in this check.

FYI I was trying the following test case:

void square(int num) {
  private int i = 0;
  private const float &ref = ++i;
}

but it also fails with your patch which makes me feel there is a bug elsewhere too:

error: reference of type 'const __private float &__private' cannot bind to a temporary object because of address space mismatch

However I do believe that the fix makes sense because that particular check was intended for when RefRelationship == Sema::Ref_Related evaluates to true.

This revision is now accepted and ready to land.Jun 17 2021, 8:27 AM
This revision was landed with ongoing or failed builds.Jun 29 2021, 2:04 AM
This revision was automatically updated to reflect the committed changes.