Question about type checking of vector type operand on Sema

Hi all,

I have a question about type checking of vector type operand on Sema.

I tested a code and clang generated error as following:

source code:
typedef float float2 __attribute__((ext_vector_type(2)));

void test(float2 a, float2 b) {
   float2 t0 = (a + b) / 2;
}

error: can't convert between vector values of different size
       ('float __attribute__((ext_vector_type(2)))' and 'float')
   float2 t0 = (a + b) / 2;
                  ~~~~~~~ ^ ~

The problem is that "Sema::CheckVectorOperands()" function does not consider about the case of float vector and integer scalar. Does someone let me know why clang prevents this case? I couldn't find some information. I think clang need to support this case. Given this case, I send a simple patch to process this case.

Thanks,
JinGu Kang

clang.patch (1.27 KB)

This looks good overall, but please add test cases for the new behavior.

John.

2013-06-08 오전 7:50, John McCall 쓴 글:

Look for an existing file in test/ that seems to be testing similar features and add some code to it that exercises the cases that you now expect to work.

In particular, I would suggest adding something to test/CodeGen/ext-vector.c that verifies that IR-generation will produce reasonable LLVM IR for your test cases.

John.

2013-06-08 오전 8:10, John McCall 쓴 글: