]> granicus.if.org Git - clang/commit
[OpenCL] Disallow negative attribute arguments
authorAndrew Savonichev <andrew.savonichev@intel.com>
Thu, 6 Sep 2018 11:54:09 +0000 (11:54 +0000)
committerAndrew Savonichev <andrew.savonichev@intel.com>
Thu, 6 Sep 2018 11:54:09 +0000 (11:54 +0000)
commit23a0e9ffba00bb559554d64e2cfc17aed71a5fea
tree296d31651019a7a3d6ff94a1d1717b1b9e0ffb4d
parent84c42fee1b534471a71da9cb41b6efe9e61894a4
[OpenCL] Disallow negative attribute arguments

Summary:
Negative arguments in kernel attributes are silently bitcast'ed to
unsigned, for example:

    __attribute__((reqd_work_group_size(1, -1, 1)))
    __kernel void k() {}

is a complete equivalent of:

    __attribute__((reqd_work_group_size(1, 4294967294, 1)))
    __kernel void k() {}

This is likely an error, so the patch forbids negative arguments in
several OpenCL attributes. Users who really want 4294967294 can still
use it as an unsigned representation.

Reviewers: Anastasia, yaxunl, bader

Reviewed By: Anastasia, yaxunl, bader

Subscribers: bader, cfe-commits

Differential Revision: https://reviews.llvm.org/D50259

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341539 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/SemaOpenCL/invalid-kernel-attrs.cl