[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.

Marco Antognini via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 11:36:10 PDT 2019


mantognini added inline comments.


================
Comment at: lib/Sema/SemaType.cpp:7355
+      // object.
+      (D.getContext() == DeclaratorContext::AliasDeclContext) ||
       // Do not deduce addr space for types used to define a typedef and the
----------------
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
}
```


================
Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:1
 //RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
 
----------------
I guess it's an oversight from previous reviews, but FileCheck is not called here.


================
Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:5
 
 //CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
 constexpr int foo = 0;
----------------
The pattern should probably be:

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

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


================
Comment at: test/SemaOpenCLCXX/address-space-deduction.cl:10
 public:
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
   static constexpr int foo2 = 0;
----------------
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.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62591/new/

https://reviews.llvm.org/D62591





More information about the cfe-commits mailing list