[cfe-dev] [OpenCL patch] Vector literals are rvalues

John McCall rjmccall at apple.com
Wed Sep 21 10:01:07 PDT 2011


On Sep 21, 2011, at 7:30 AM, Peter Collingbourne wrote:

> On Wed, Sep 21, 2011 at 02:16:26PM +0100, Anton Lokhmotov wrote:
>> Clang currently accepts taking the address of a vector literal in the OpenCL
>> mode, e.g.
>> 
>>   return &((int4)(3,2,1,0)); // expected-error{{address expression must be
>> an lvalue}}
>> 
>> which is wrong (http://llvm.org/bugs/show_bug.cgi?id=10966).
>> 
>> Please review the attached patch that fixes this problem.
> 
> Hi Anton,
> 
> What about compound literals which are not of vector type?  The OpenCL
> specification is silent on these, which means we should defer to C99,
> which states that they are lvalues.

Right.  Ideally, this should just apply to OpenCL vector literals,
i.e. this should be an r-value:
  (int4) (3,2,1,0)
and this should be an l-value:
  (int4) {3,2,10}

John.



More information about the cfe-dev mailing list