Clang error: vector operands do not have the same elements sizes (A and B) [-Wvec-elem-size] (warn_typecheck_vector_element_sizes_not_equal)
Jump to navigation
Jump to search
Text | error: vector operands do not have the same elements sizes (A and B) |
---|---|
Type | Downgradable Error |
Category | Semantic Issue |
Internal Id | warn_typecheck_vector_element_sizes_not_equal |
Active by Default | Yes |
Flags | -Wno-vec-elem-size (1 element) |
Internal Message | vector operands do not have the same elements sizes (%0 and %1)
|
Regular Expression | (?:error|warning|fatal error)\: vector operands do not have the same elements sizes \((.*?) and (.*?)\) \[[^\]]*\-Wvec\-elem\-size[^\]]*\]
|
First Commit | 2016-10-19 9941ca8af6b4 [Sema] Gcc compatibility of vector shift |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
int main() {
// Define a vector of 4 ints
typedef int v4si __attribute__((vector_size (16)));
// Define a vector of 4 shorts
typedef short v4hi __attribute__((vector_size (8)));
v4si a;
v4hi b;
// Attempt to shift a by b; different element sizes
a = a >> b;
return 0;
}
| |
Compiler Output |
<source>:9:9: error: vector operands do not have the same elements sizes ('v4si' (vector of 4 'int' values) and 'v4hi' (vector of 4 'short' values)) [-Wvec-elem-size] |
Clang Internals (17.0.6)
Git Commit Message
[Sema] Gcc compatibility of vector shift Gcc prints error if elements of left and right parts of a shift have different sizes. This patch is provided the GCC compatibility. Patch by Vladimir Yakovlev. Differential Revision: https://reviews.llvm.org/D24669 llvm-svn: 284579
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaExpr.cpp (line 12191)
/// Return the resulting type when a vector is shifted
/// by a scalar or vector shift amount.
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign) {
// ...
if (!LHSVecTy) {
// ...
} else if (RHSVecTy) {
// ...
if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
// ...
if (LHSBT != RHSBT && S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) {
S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal) << LHS.get()->getType() << RHS.get()->getType() << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CodeGen/vecshift.c
- clang/test/CodeGen/vecshift.c:113:13: warning: vector operands do not have the same elements sizes ('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 'unsigned char' values)) [-Wvec-elem-size]
- clang/test/CodeGen/vecshift.c:118:15: warning: vector operands do not have the same elements sizes ('vector_uchar8' (vector of 8 'unsigned char' values) and 'vector_int8' (vector of 8 'int' values)) [-Wvec-elem-size]
- clang/test/CodeGen/vecshift.c:123:15: warning: vector operands do not have the same elements sizes ('vector_ushort8' (vector of 8 'unsigned short' values) and 'vector_uint8' (vector of 8 'unsigned int' values)) [-Wvec-elem-size]
- clang/test/CodeGen/vecshift.c:128:15: warning: vector operands do not have the same elements sizes ('vector_uint8' (vector of 8 'unsigned int' values) and 'vector_short8' (vector of 8 'short' values)) [-Wvec-elem-size]