This is an archive of the discontinued LLVM Phabricator instance.

19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
Needs ReviewPublic

Authored by ichesnokov on Jan 28 2016, 5:39 AM.

Details

Summary

Test cases moved to SemaOpenCL folder.

Diff Detail

Event Timeline

ichesnokov retitled this revision from to 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator.
ichesnokov updated this object.
ichesnokov added a reviewer: asl.
ichesnokov set the repository for this revision to rL LLVM.

Please hold of working on this bug. Unit test have to be corrected.

asl added inline comments.Jan 28 2016, 2:33 PM
test/CodeGenOpenCL/ternary-implicit-casts-fail.cl
2 ↗(On Diff #46275)

Don't do XFAIL tests - they will be "ok" regardless of the failure type. Make sure you're checking the exact error message, etc.

test/CodeGenOpenCL/ternary-implicit-casts-succ.cl
5 ↗(On Diff #46275)

What we're checking here? If this is codegen test, then you need to check for generated IR. It looks like a sema bug / test.

test/CodeGenOpenCL/ternary-implicit-casts-fail.cl
2 ↗(On Diff #46275)

Unable to use expected-error {{}}.
Compiler gives error: initializing 'local int *' with an expression of type 'void *' changes address space of pointer
Using
expected-error {{initializing 'local int *' with an expression of type 'void *' changes address space of pointer}} does not work.
Thus I used XFAIL.

test/CodeGenOpenCL/ternary-implicit-casts-succ.cl
5 ↗(On Diff #46275)

Here we checking assignment operator. Variable 'ptr' is in generic address space and should take both global and local values.
In previous "XFAIL" test there's assignment to "local ptr*" has to fail.

ichesnokov updated this object.

Anton, answers to your questions are in Diff 2 46275

asl added inline comments.Jan 29 2016, 1:11 AM
test/CodeGenOpenCL/ternary-implicit-casts-fail.cl
2 ↗(On Diff #46275)

This is either bug in expected-error stuff (which I honestly doubt) or you did something wrong.

test/CodeGenOpenCL/ternary-implicit-casts-fail.cl
2 ↗(On Diff #46275)

I'll send the patch to llvm-dev to find out what's the reason of expected-error fail.

BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=19957.

I'll hold off working on this bug, until expected-result {{ }} question will be solved.

Please review and commit.
There's no patch, but only unit tests.

Please review and commit.
There's no patch, but only unit tests.

ichesnokov removed rL LLVM as the repository for this revision.

Test cases moved to single file.
Please review and accept.

ichesnokov added inline comments.Feb 2 2016, 8:06 AM
test/CodeGenOpenCL/ternary-implicit-casts-fail.cl
2 ↗(On Diff #46275)

It was my error: I forgot add -verify parameter.

Anastasia added inline comments.Feb 5 2016, 10:37 AM
test/SemaOpenCL/ternary-implicit-casts.cl
6

Again, I am not quite clear about the purpose of this change.

We have similar testing in test/SemaOpenCL/address-spaces-conversions-cl2.0.cl.

However, the diagnostics, that Clang currently gives, seem wrong to me. We might need to investigate that.

ichesnokov added inline comments.Feb 5 2016, 10:46 AM
test/SemaOpenCL/ternary-implicit-casts.cl
6

This test point is the ternary operator. It displays that ternary operator may return not only in different values, but also different address spaces. I do not see such check in address-spaces-conversions-cl2.0.cl.

bader added a subscriber: bader.Feb 5 2016, 10:54 AM
bader added inline comments.
test/SemaOpenCL/ternary-implicit-casts.cl
10–11

Note that test doesn't specify OpenCL version. By default it's 1.0, so ptr points to private AS and it's illegal to cast pointers from different address spaces in OpenCL v1.x.

It looks like there's more todo to close this bug.
Let's go back to bug discussion at: https://llvm.org/bugs/show_bug.cgi?id=19957

ichesnokov added inline comments.Feb 7 2016, 6:00 AM
test/SemaOpenCL/ternary-implicit-casts.cl
10–11
arsenm edited edge metadata.Mar 30 2017, 10:40 AM

Is this still necessary? The bug is marked fixed

arsenm resigned from this revision.Feb 21 2019, 6:54 PM