This fixes an error in type checking of shift of vector values.
Details
Diff Detail
Event Timeline
llvm/tools/clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
8597 | Why does this drop the mention of OpenCL in the function name? | |
8638 | It's good to keep language references in the comments, so I would leave the reference in even though this is being expanded for non-OpenCL vector types (unless the reference is incorrect). | |
8681–8683 | Why is it correct to remove semantic checking for vector operands? | |
llvm/tools/clang/test/Sema/shift.c | ||
75 | Please clang-format the test case. |
llvm/tools/clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
8597 | This routine has common applying rather than for OpenCL only. | |
8638 | I'll restore the language reference. | |
8681–8683 | This routine targets for checking operands of operations like plus, mul ..., but not shifts. The tests vect_shift_1 and vect_shift_2 (I added) are examples which were compiled with error. | |
llvm/tools/clang/test/Sema/shift.c | ||
75 | Ok. |
llvm/tools/clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
8681–8683 | Are you saying that calling CheckVectorOperands was always incorrect? Or that it's no longer required because it should be fully covered by checkVectorShift? Because the two methods do considerably different checking, and I would have expected there to be more behavioral differences in the tests by removing the call to CheckVectorOperands that suggests there are tests missing. |
llvm/tools/clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
8681–8683 | Yes, calling CheckVectorOperands is not correct here because it compares operand types to be the same. For shift it is not true. |
@uweigand Ulrich, any objections here? If not, I will commit this patch tomorrow (as the author, Vladimir, doesn't have commit access yet).
Andrey
This patch causes clang to error out on the following code, which used to compile fine:
$ cat f2.c
typedef __attribute__((__ext_vector_type__(8))) unsigned short vector_ushort8; vector_ushort8 foo1(void) { return 1 << (vector_ushort8){7,6,5,4,3,2,1,0}; }
$ clang f2.c -c
clang used to transform the scaler operand to a vector operand (similar to the way gcc's vector is handled) when compiling for normal c/c++ (but printed an error message when compiling for opencl), but this patch dropped the check for LangOpts added in r230464 and changed that behavior. I don't think this was intentional?
an vector -> a vector