[cfe-commits] [OpenCL patch] Clang fails on nested vector literals

Eli Friedman eli.friedman at gmail.com
Tue Sep 27 11:15:45 PDT 2011


On Tue, Sep 27, 2011 at 4:17 AM, Anton Lokhmotov
<Anton.Lokhmotov at arm.com> wrote:
> Hi Eli,
>
> Thanks for your prompt review.
>
>> It looks like you included some diffs you didn't mean to include?
>> (The changes to lib/AST/Expr.cpp and the first set of changes to
>> lib/AST/ExprConstant.cpp.)
> This code is necessary for Clang to recognise that a vector literal with a
> nested constant initializer is constant.

All of your tests pass without those changes... are they necessary for
some other reason I'm missing?

>> I follow the concept of your patch, but it looks like you're deleting
>> a bunch of necessary code from lib/AST/ExprConstant.cpp.  Do we really
>> not have proper tests for those cases?
> The removed code only works when the number of initializers is 1 or exactly
> equal to the number of vector elements.  Our code is more generic, as it
> allows nested vector initializers (see OpenCL 6.1.6).  The added tests cover
> all possible uses.

Your patch breaks the following:

typedef int i4 __attribute((vector_size(16)));
i4 x = (i4){1,2};

It takes out the code that would otherwise pad the vector with zeros.

-Eli




More information about the cfe-commits mailing list