[Sema] Support implicit scalar to vector conversions
authorSimon Dardis <simon.dardis@imgtec.com>
Fri, 12 May 2017 19:11:06 +0000 (19:11 +0000)
committerSimon Dardis <simon.dardis@imgtec.com>
Fri, 12 May 2017 19:11:06 +0000 (19:11 +0000)
commit7cd5876e6031851ba033059f9ef3a3c238abcc82
treea4b1d787cc057360362abd89d9b26ef534615876
parenta9231af7dd54378c0ab85c86f751e042e7664d56
[Sema] Support implicit scalar to vector conversions

This patch teaches clang to perform implicit scalar to vector conversions
when one of the operands of a binary vector expression is a scalar which
can be converted to the element type of the vector without truncation
following GCC's implementation.

If the (constant) scalar is can be casted safely, it is implicitly casted to the
vector elements type and splatted to produce a vector of the same type.

Contributions from: Petar Jovanovic

Reviewers: bruno, vkalintiris

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

llvm-svn: 302935
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/Sema/vector-cast.c
clang/test/Sema/vector-gcc-compat.c [new file with mode: 0644]
clang/test/Sema/vector-gcc-compat.cpp [new file with mode: 0644]
clang/test/Sema/vector-ops.c
clang/test/Sema/zvector.c
clang/test/SemaCXX/vector-no-lax.cpp