[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 19 10:01:15 PST 2018

Anastasia added inline comments.

Comment at: lib/Parse/ParseDecl.cpp:6162
+        }
+      }
rjmccall wrote:
> This is enforcing a restriction that users write `const __private`, which seems unreasonable.  It looks like `ParseTypeQualifierList` takes a flag saying not to parse attributes; try adding a new option to that enum allowing address-space attributes.
> Collecting the attributes on the type-qualifiers `DeclSpec` rather than adding them as function attributes seems correct.
Do you mean `ParseTypeQualifierListOpt`? That already parses the address spaces unconditionally. The problem is however that we are using local `DeclSpec` - `DS` variable here during the function qualifiers parsing because the `DeclSpec` member of the `Declarator` corresponds to the return type as far as I understand it. Therefore I am propagating missing address space attributes from the local `DS` variable into `FnAttrs` to be used in the function type info.

With current patch both of the following two forms:
  struct C {
    void foo() __local const;
  struct C {
    void foo() const __local;
would be parsed correctly generating identical IR
  declare void @_ZNU3AS3K1C3fooEv(%struct.C addrspace(3)*)



More information about the cfe-commits mailing list