Restores r228382, which was reverted in r228406.
authorSameer Sahasrabuddhe <sameer@sbuddhe.net>
Wed, 25 Feb 2015 05:48:23 +0000 (05:48 +0000)
committerSameer Sahasrabuddhe <sameer@sbuddhe.net>
Wed, 25 Feb 2015 05:48:23 +0000 (05:48 +0000)
commita75db66eee43652d80e54e457ca2cc64c49c7bd4
treedf033752c3251f4804319439df6ca98732a6abe7
parente20ede26d2122ef22462ad6612c3db4039ccba08
Restores r228382, which was reverted in r228406.

The original commit failed to handle "shift assign" (<<=), which
broke the test mentioned in r228406. This is now fixed and the
test added to the lit tests under SemaOpenCL.

*** Original commit message from r228382 ***

OpenCL: handle shift operator with vector operands

Introduce a number of checks:
1. If LHS is a scalar, then RHS cannot be a vector.
2. Operands must be of integer type.
3. If both are vectors, then the number of elements must match.

Relax the requirement for "usual arithmetic conversions":
When LHS is a vector, a scalar RHS can simply be expanded into a
vector; OpenCL does not require that its rank be lower than the LHS.
For example, the following code is not an error even if the implicit
type of the constant literal is "int".

  char2 foo(char2 v) { return v << 1; }

Consolidate existing tests under CodeGenOpenCL, and add more tests
under SemaOpenCL.

llvm-svn: 230464
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGenOpenCL/shifts.cl
clang/test/SemaOpenCL/shifts.cl