aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-07-01 16:21:32 +0100
committergingerBill <bill@gingerbill.org>2018-07-01 16:21:32 +0100
commit9bef5ec01abfffc01067d3ed1817f13b4918b315 (patch)
tree04c3ebc4d16bef4a69928abb0bdf182d332ff3bf
parent3a16f1e854d60059ab93efbf946c582138e95a66 (diff)
Fix anonymous procedures
-rw-r--r--build.bat2
-rw-r--r--core/bits/bits.odin32
-rw-r--r--src/ir.cpp2
-rw-r--r--src/parser.cpp3
4 files changed, 30 insertions, 9 deletions
diff --git a/build.bat b/build.bat
index fc1d2c881..bf52320e7 100644
--- a/build.bat
+++ b/build.bat
@@ -18,7 +18,7 @@ set compiler_warnings= ^
-W4 -WX ^
-wd4100 -wd4101 -wd4127 -wd4189 ^
-wd4201 -wd4204 ^
- -wd4456 -wd4457 ^
+ -wd4456 -wd4457 -wd4480 ^
-wd4512
set compiler_includes=
diff --git a/core/bits/bits.odin b/core/bits/bits.odin
index ff4d07e3a..a67813c53 100644
--- a/core/bits/bits.odin
+++ b/core/bits/bits.odin
@@ -43,21 +43,39 @@ foreign {
@(link_name="llvm.bitreverse.i32") reverse_bits32 :: proc(i: u32) -> u32 ---
@(link_name="llvm.bitreverse.i64") reverse_bits64 :: proc(i: u64) -> u64 ---
- @(link_name="llvm.bswap.i16") byte_swap16 :: proc(u16) -> u16 ---
- @(link_name="llvm.bswap.i32") byte_swap32 :: proc(u32) -> u32 ---
- @(link_name="llvm.bswap.i64") byte_swap64 :: proc(u64) -> u64 ---
+ @(link_name="llvm.bswap.i16") byte_swap_u16 :: proc(u16) -> u16 ---
+ @(link_name="llvm.bswap.i32") byte_swap_u32 :: proc(u32) -> u32 ---
+ @(link_name="llvm.bswap.i64") byte_swap_u64 :: proc(u64) -> u64 ---
+ @(link_name="llvm.bswap.i16") byte_swap_i16 :: proc(i16) -> i16 ---
+ @(link_name="llvm.bswap.i32") byte_swap_i32 :: proc(i32) -> i32 ---
+ @(link_name="llvm.bswap.i64") byte_swap_i64 :: proc(i64) -> i64 ---
}
byte_swap_uint :: proc(i: uint) -> uint {
when size_of(uint) == size_of(u32) {
- return uint(byte_swap32(u32(i)));
+ return uint(byte_swap_u32(u32(i)));
} else {
- return uint(byte_swap64(u64(i)));
+ return uint(byte_swap_u64(u64(i)));
+ }
+}
+byte_swap_int :: proc(i: int) -> int {
+ when size_of(int) == size_of(i32) {
+ return int(byte_swap_i32(i32(i)));
+ } else {
+ return int(byte_swap_i64(i64(i)));
}
}
-byte_swap :: proc[byte_swap16, byte_swap32, byte_swap64, byte_swap_uint];
-
+byte_swap :: proc[
+ byte_swap_u16,
+ byte_swap_u32,
+ byte_swap_u64,
+ byte_swap_i16,
+ byte_swap_i32,
+ byte_swap_i64,
+ byte_swap_uint,
+ byte_swap_int,
+];
count_zeros8 :: proc(i: u8) -> u8 { return 8 - count_ones8(i); }
count_zeros16 :: proc(i: u16) -> u16 { return 16 - count_ones16(i); }
diff --git a/src/ir.cpp b/src/ir.cpp
index 5b97a79d2..9103b5491 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1578,7 +1578,7 @@ void ir_emit_zero_init(irProcedure *p, irValue *address, Ast *expr) {
args[0] = ir_emit_conv(p, address, t_rawptr);
args[1] = ir_const_int(a, type_size_of(t));
AstPackage *pkg = get_core_package(p->module->info, str_lit("mem"));
- if (p->entity->token.string != "zero" && p->entity->pkg != pkg) {
+ if (p->entity != nullptr && p->entity->token.string != "zero" && p->entity->pkg != pkg) {
ir_emit_package_call(p, "mem", "zero", args, expr);
}
ir_emit(p, ir_instr_zero_init(p, address));
diff --git a/src/parser.cpp b/src/parser.cpp
index fe992eda8..600c35608 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -4292,6 +4292,9 @@ bool parse_file(Parser *p, AstFile *f) {
CommentGroup *docs = f->lead_comment;
f->package_token = expect_token(f, Token_package);
+ if (f->error_count > 0) {
+ return false;
+ }
Token package_name = expect_token_after(f, Token_Ident, "package");
if (package_name.kind == Token_Ident) {
if (package_name.string == "_") {