Skip to content

OpenCL C++ attributes do not work for array variables/fields #60

Description

@ex-rzr

(tested on spirv-1.1 branch)

Here is a test file based on examples from OpenCL C++ specification:

struct foo1
{
    char a;
    int x[2] [[cl::packed]];
    int y [[cl::packed]];
};

struct foo2
{
    int x[2] [[cl::aligned(8)]];
    int y [[cl::aligned(8)]];
};

int x [[cl::aligned(16)]] = 0;
short array[3] [[cl::aligned]];

Output for clang -cc1 array-attribute-cpp.cl -triple spir-unknown-unknown -cl-std=c++:

array-attribute-cpp.cl:4:16: error: 'packed' attribute cannot be applied to types
    int x[2] [[cl::packed]];
               ^
array-attribute-cpp.cl:10:16: error: 'aligned' attribute cannot be applied to types
    int x[2] [[cl::aligned(8)]];
               ^
array-attribute-cpp.cl:15:18: error: 'aligned' attribute cannot be applied to types
short array[3] [[cl::aligned]];
                 ^
3 errors generated.

The same OpenCL C code (but using __attribute__) is compiled without errors:

struct foo1
{
    char a;
    int x[2] __attribute__ ((packed));
    int y __attribute__ ((packed));
};

struct foo2
{
    int x[2] __attribute__ ((aligned (8)));
    int y __attribute__ ((aligned (8)));
};

int x __attribute__((aligned (16))) = 0;
short array[3] __attribute__ ((aligned));

(Interesting that int z [[cl::aligned(8)]] [2]; is compiled, but int z __attribute__ ((aligned (8))) [2]; is not)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions