Files
c3c/test/test_suite/pointers/pointer_index.c3t
Christoffer Lerno 97ac957cb7 "Public by default"
2021-05-30 16:30:16 +02:00

42 lines
897 B
Plaintext

module pointer_index;
func void test1(int* x)
{
int a = x[0];
int b = *x;
int c = x[1];
int d = x[-1];
}
func void test2(char* x)
{
char a = x[0];
char b = *x;
char c = x[1];
}
func void test3(long* x)
{
long a = x[0];
long b = *x;
long c = x[1];
}
// #expect: pointer_index.ll
%x = alloca i64*, align 8
%a = alloca i64, align 8
%b = alloca i64, align 8
%c = alloca i64, align 8
store i64* %0, i64** %x, align 8
%1 = load i64*, i64** %x, align 8
%ptridx = getelementptr inbounds i64, i64* %1, i64 0
%2 = load i64, i64* %ptridx, align 8
store i64 %2, i64* %a, align 8
%3 = load i64*, i64** %x, align 8
%4 = load i64, i64* %3, align 8
store i64 %4, i64* %b, align 8
%5 = load i64*, i64** %x, align 8
%ptridx1 = getelementptr inbounds i64, i64* %5, i64 1
%6 = load i64, i64* %ptridx1, align 8
store i64 %6, i64* %c, align 8