[PATCH] Support for address space casting in order to map these on the new 'addrspacecast' IR instruction

Michele Scandale michele.scandale at gmail.com
Fri Dec 6 14:40:18 PST 2013


On 12/06/2013 03:26 PM, Michele Scandale wrote:
>
>    I discover some failures in 'test/SemaCXX/address-space-conversion.cpp' about missing expected errors: in this test were checked errors reported on static upcast and downcast of a pointer to a struct type in different address spaces.
>
>    The expected error should be triggered because the two pointees do not have the same qualifiers, but the patch will still allow the conversion because as last chance to have a static_cast it checks if boh source and destination types are pointers with pointees in different address spaces.
>
>    Would it be semantically correct now to have a static upcast/downcast of pointers/references to struct/classes in different address spaces?

Hi John and Richard,

today I was thinking about the question I wrote this afternoon: I'm not so sure 
that it would be a good idea (at least for now) to allow static_casts with 
address space conversion for structs and classes.
In general I have a lot of doubts about address spaces within C++:

---------
void foo(struct A __attribute__((address_space(1))) *myA) {
   myA->bar();
}
---------

This code I think should be valid and compile, but in order to allow this we 
would require an implicit address space conversion. I don't know if it would be 
fine add such a conversion (using  addrspacecast instruction) only in the codegen.

What do you think about this?

Thanks in advance.

Regards,
-Michele

> http://llvm-reviews.chandlerc.com/D2241
>




More information about the cfe-commits mailing list