[cfe-dev] Question about type checking of vector type operand on Sema

John McCall rjmccall at apple.com
Fri Jun 7 16:10:10 PDT 2013


On Jun 7, 2013, at 3:54 PM, jingu <jingu at codeplay.com> wrote:
> 2013-06-08 오전 7:50, John McCall 쓴 글:
>> On Jun 7, 2013, at 8:16 AM, JinGu Kang <jingu at codeplay.com> wrote:
>>> 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.
>> This looks good overall, but please add test cases for the new behavior.
> 
> Thanks for your response. Could let me know how to add test cases? I did not have experience to do that.

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.



More information about the cfe-dev mailing list