mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-22 13:05:52 -04:00

This change adds a new diagnostic for mismatching address spaces to be used for C++ casts (only enabled in C style cast for now, the rest will follow!). The change extends C-style cast rules to account for address spaces. It also adds a separate function for address space cast checking that can be used to map from a separate address space cast operator addrspace_cast (to be added as a follow up patch). Note, that after this change clang will no longer allows arbitrary address space conversions in reinterpret_casts because they can lead to accidental errors. The implicit safe conversions would still be allowed. Differential Revision: https://reviews.llvm.org/D58346 llvm-svn: 355609
15 lines
562 B
C++
15 lines
562 B
C++
// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
|
|
|
|
void test_reinterpret_cast(){
|
|
__private float x;
|
|
__private float& y = x;
|
|
// We don't need bitcast to cast pointer type and
|
|
// address space at the same time.
|
|
//CHECK: addrspacecast float* %x to i32 addrspace(4)*
|
|
//CHECK: [[REG:%[0-9]+]] = load float*, float** %y
|
|
//CHECK: addrspacecast float* [[REG]] to i32 addrspace(4)*
|
|
//CHECK-NOT: bitcast
|
|
__generic int& rc1 = reinterpret_cast<__generic int&>(x);
|
|
__generic int& rc2 = reinterpret_cast<__generic int&>(y);
|
|
}
|