mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
42 lines
908 B
Plaintext
42 lines
908 B
Plaintext
module foo;
|
|
|
|
public func void test1(int* x)
|
|
{
|
|
int a = x[0];
|
|
int b = *x;
|
|
int c = x[1];
|
|
int d = x[-1];
|
|
}
|
|
|
|
public func void test2(char* x)
|
|
{
|
|
char a = x[0];
|
|
char b = *x;
|
|
char c = x[1];
|
|
}
|
|
|
|
public 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 |