This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL][PR42031] Prevent deducing addr space in type alias.
ClosedPublic

Authored by Anastasia on May 29 2019, 6:57 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

Anastasia created this revision.May 29 2019, 6:57 AM
mantognini added inline comments.May 29 2019, 11:31 AM
lib/Sema/SemaType.cpp
7355 ↗(On Diff #201905)

I think this should also check for !IsPointee as it breaks the following example with error: cannot initialize a variable of type 'c_ptr' (aka 'c1 *') with an rvalue of type 'c1 *'.

struct c1 { int x; };
using c_ptr = c1*;

__kernel void test2() {
  c1 x = { 0 };
  c1* y = &x; // okay
  c_ptr z = &x; // fails
}
test/SemaOpenCLCXX/address-space-deduction.cl
1 ↗(On Diff #201905)

I guess it's an oversight from previous reviews, but FileCheck is not called here.

5 ↗(On Diff #201905)

The pattern should probably be:

//CHECK: |-VarDecl {{.*}} foo 'const __global int' constexpr cinit

(i.e. move the {{.*}} before foo).

10 ↗(On Diff #201905)

This check fails for me because inline is "missing" between static and constexpr. Not sure if it makes sense for foo2 to be inline or not, but that's a different story.

Anastasia updated this revision to Diff 202721.Jun 3 2019, 7:30 AM
  • Exclude pointee from early return in addr space deduction
  • Improved testing: added FileCheck and avoid testing unnecessary bits

@mantognini Good spot! Thanks!

This revision is now accepted and ready to land.Jun 4 2019, 4:58 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2019, 7:47 AM