&&temp operator. Macro evaluation.

This commit is contained in:
Christoffer Lerno
2020-10-14 12:26:27 +02:00
committed by Christoffer Lerno
parent 8680ce0684
commit 4222f2731e
29 changed files with 1332 additions and 348 deletions

View File

@@ -1,19 +1,20 @@
const byte AA = ~0;
const byte BB = 200 ;
const uint CC = ~0;
const uint DD = $FOO;
const uint DD = FOO;
const $FOO = ~0;
const FOO = ~0;
uint x = AA;
uint z = CC;
byte w = $FOO;
ushort v = $FOO;
byte w = FOO;
ushort v = FOO;
uint z2 = DD;
func void test()
{
int xx = $FOO;
int xx = FOO;
int* yy = &&FOO;
}
// #expect: constants.ll
@@ -30,5 +31,9 @@ func void test()
entry:
%xx = alloca i32
%yy = alloca i32*
%taddr = alloca i32
store i32 -1, i32* %xx
store i32 -1, i32* %taddr
store i32* %taddr, i32** %yy
ret void

View File

@@ -11,8 +11,8 @@ func void test1()
test2(a); // #error: Cannot implicitly cast 'int' to 'char'.
test2(100 + a); // #error: Cannot implicitly cast 'int' to 'char'.
const int x = 120;
test2(x); // #error: Cannot implicitly cast 'int' to 'char'.
const int X = 120;
test2(X); // #error: Cannot implicitly cast 'int' to 'char'.
test2(100 + 100); // #error: Cannot fit '200' into type 'char'.
}

View File

@@ -1,6 +1,6 @@
const $FOO = 3;
$BAR = 4; // #error: Did you forget a 'const' before the name of this compile time constant?
const FOO = 3;
int BAR = 4; // #error: This looks like a constant variable, did you forget 'const'?
const $BAZ = "ofke";
const BAZ = "ofke";
$FOOBAR; // #error: Compile time constant unexpectedly found
FOOBAR; // #error: Expected a top level declaration here.

View File

@@ -60,15 +60,17 @@ func void test8()
func void test9()
{
const char a = 1; // TODO should be "A"
char b = a;
a = b; // #error: Expression is not assignable
const char A = 1;
char b = A;
A = b; // #error: Expression is not assignable
}
func void test10()
{
const char a = 1;
char* b = &a; // #error: address of values
const char B = 1;
char* c = &B;
const A = 1;
char* b = &A; // #error: To take the address of a temporary value, use '&&' instead of '&'
}
enum Enum : int
@@ -181,4 +183,16 @@ int[2][3] b123;
func void test24()
{
int a = b123; // #error: cast 'int[2][3]' to 'int'
}
}
func void test25()
{
const A = void; // #error: Constants cannot be undefined.
}
func void test26()
{
const int A = void; // #error: Constants cannot be undefined.
}