| author | |
| committer | |
| log | f17e20d5fefeb9ce30a08e85c10b9449cf672112 |
| tree | 2907eae05aca64bbab1e7ca0c9c526c1f204848d |
| parent | 7dd29291853a30973c19867385514b6d807cb644 |
closes #3314 files changed, 62 insertions(+), 53 deletions(-)
doc/langref.md+2-2| ... | ... | @@ -60,7 +60,7 @@ ParamDecl : token(Symbol) token(Colon) Type | token(Ellipsis) |
| 60 | 60 | |
| 61 | 61 | Type : token(Symbol) | token(Unreachable) | token(Void) | PointerType | ArrayType |
| 62 | 62 | |
| 63 | PointerType : token(Star) (token(Const) | token(Mut)) Type | |
| 63 | PointerType : token(Ampersand) option(token(Const)) Type | |
| 64 | 64 | |
| 65 | 65 | ArrayType : token(LBracket) Type token(Semicolon) Expression token(RBracket) |
| 66 | 66 | |
| ... | ... | @@ -114,7 +114,7 @@ BinaryOrExpression : BinaryXorExpression token(BinOr) BinaryOrExpression | Binar |
| 114 | 114 | |
| 115 | 115 | BinaryXorExpression : BinaryAndExpression token(BinXor) BinaryXorExpression | BinaryAndExpression |
| 116 | 116 | |
| 117 | BinaryAndExpression : BitShiftExpression token(BinAnd) BinaryAndExpression | BitShiftExpression | |
| 117 | BinaryAndExpression : BitShiftExpression token(Ampersand) BinaryAndExpression | BitShiftExpression | |
| 118 | 118 | |
| 119 | 119 | BitShiftExpression : AdditionExpression BitShiftOperator BitShiftExpression | AdditionExpression |
| 120 | 120 |
example/arrays/arrays.zig+2-2| ... | ... | @@ -2,7 +2,7 @@ export executable "arrays"; |
| 2 | 2 | |
| 3 | 3 | use "std.zig"; |
| 4 | 4 | |
| 5 | export fn main(argc: isize, argv: *mut *mut u8, env: *mut *mut u8) -> i32 { | |
| 5 | export fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { | |
| 6 | 6 | let mut array : [i32; 5]; |
| 7 | 7 | |
| 8 | 8 | let mut i : i32 = 0; |
| ... | ... | @@ -30,7 +30,7 @@ loop_2_start: |
| 30 | 30 | loop_2_end: |
| 31 | 31 | |
| 32 | 32 | if accumulator == 15 { |
| 33 | print_str("OK" as string); | |
| 33 | print_str("OK\n" as string); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 |
example/expressions/expressions.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ export executable "expressions"; |
| 2 | 2 | |
| 3 | 3 | #link("c") |
| 4 | 4 | extern { |
| 5 | fn puts(s: *const u8) -> i32; | |
| 5 | fn puts(s: &const u8) -> i32; | |
| 6 | 6 | fn exit(code: i32) -> unreachable; |
| 7 | 7 | } |
| 8 | 8 |
example/hello_world/hello.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ export executable "hello"; |
| 2 | 2 | |
| 3 | 3 | use "std.zig"; |
| 4 | 4 | |
| 5 | export fn main(argc: isize, argv: *mut *mut u8, env: *mut *mut u8) -> i32 { | |
| 5 | export fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { | |
| 6 | 6 | // TODO implicit coercion from array to string |
| 7 | 7 | print_str("Hello, world!\n" as string); |
| 8 | 8 | return 0; |
example/hello_world/hello_libc.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ export executable "hello"; |
| 2 | 2 | |
| 3 | 3 | #link("c") |
| 4 | 4 | extern { |
| 5 | fn printf(__format: *const u8, ...) -> i32; | |
| 5 | fn printf(__format: &const u8, ...) -> i32; | |
| 6 | 6 | fn exit(__status: i32) -> unreachable; |
| 7 | 7 | } |
| 8 | 8 |
example/multiple_files/libc.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | #link("c") |
| 2 | 2 | extern { |
| 3 | pub fn puts(s: *const u8) -> i32; | |
| 3 | pub fn puts(s: &const u8) -> i32; | |
| 4 | 4 | pub fn exit(code: i32) -> unreachable; |
| 5 | 5 | } |
example/structs/structs.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ export executable "structs"; |
| 2 | 2 | |
| 3 | 3 | use "std.zig"; |
| 4 | 4 | |
| 5 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 5 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 6 | 6 | let mut foo : Foo; |
| 7 | 7 | |
| 8 | 8 | foo.a = foo.a + 1; |
src/analyze.cpp+1-1| ... | ... | @@ -111,7 +111,7 @@ TypeTableEntry *get_pointer_to_type(CodeGen *g, TypeTableEntry *child_type, bool |
| 111 | 111 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPointer); |
| 112 | 112 | entry->type_ref = LLVMPointerType(child_type->type_ref, 0); |
| 113 | 113 | buf_resize(&entry->name, 0); |
| 114 | buf_appendf(&entry->name, "*%s %s", is_const ? "const" : "mut", buf_ptr(&child_type->name)); | |
| 114 | buf_appendf(&entry->name, "&%s%s", is_const ? "const " : "", buf_ptr(&child_type->name)); | |
| 115 | 115 | entry->size_in_bits = g->pointer_size_bytes * 8; |
| 116 | 116 | entry->align_in_bits = g->pointer_size_bytes * 8; |
| 117 | 117 | entry->di_type = LLVMZigCreateDebugPointerType(g->dbuilder, child_type->di_type, |
src/parseh.cpp+4-4| ... | ... | @@ -250,9 +250,9 @@ static Buf *to_zig_type(ParseH *p, CXType raw_type) { |
| 250 | 250 | CXType pointee_type = clang_getArrayElementType(raw_type); |
| 251 | 251 | Buf *pointee_buf = to_zig_type(p, pointee_type); |
| 252 | 252 | if (clang_isConstQualifiedType(pointee_type)) { |
| 253 | return buf_sprintf("*const %s", buf_ptr(pointee_buf)); | |
| 253 | return buf_sprintf("&const %s", buf_ptr(pointee_buf)); | |
| 254 | 254 | } else { |
| 255 | return buf_sprintf("*mut %s", buf_ptr(pointee_buf)); | |
| 255 | return buf_sprintf("&%s", buf_ptr(pointee_buf)); | |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | case CXType_Pointer: |
| ... | ... | @@ -265,9 +265,9 @@ static Buf *to_zig_type(ParseH *p, CXType raw_type) { |
| 265 | 265 | pointee_buf = to_zig_type(p, pointee_type); |
| 266 | 266 | } |
| 267 | 267 | if (clang_isConstQualifiedType(pointee_type)) { |
| 268 | return buf_sprintf("*const %s", buf_ptr(pointee_buf)); | |
| 268 | return buf_sprintf("&const %s", buf_ptr(pointee_buf)); | |
| 269 | 269 | } else { |
| 270 | return buf_sprintf("*mut %s", buf_ptr(pointee_buf)); | |
| 270 | return buf_sprintf("&%s", buf_ptr(pointee_buf)); | |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | case CXType_Record: |
src/parser.cpp+24-14| ... | ... | @@ -781,6 +781,7 @@ static AstNode *ast_parse_expression(ParseContext *pc, int *token_index, bool ma |
| 781 | 781 | static AstNode *ast_parse_block(ParseContext *pc, int *token_index, bool mandatory); |
| 782 | 782 | static AstNode *ast_parse_if_expr(ParseContext *pc, int *token_index, bool mandatory); |
| 783 | 783 | static AstNode *ast_parse_block_expr(ParseContext *pc, int *token_index, bool mandatory); |
| 784 | static AstNode *ast_parse_type(ParseContext *pc, int *token_index); | |
| 784 | 785 | |
| 785 | 786 | static void ast_expect_token(ParseContext *pc, Token *token, TokenId token_id) { |
| 786 | 787 | if (token->id != token_id) { |
| ... | ... | @@ -841,10 +842,21 @@ static void ast_parse_directives(ParseContext *pc, int *token_index, |
| 841 | 842 | zig_unreachable(); |
| 842 | 843 | } |
| 843 | 844 | |
| 845 | static void ast_parse_type_assume_amp(ParseContext *pc, int *token_index, AstNode *node) { | |
| 846 | node->data.type.type = AstNodeTypeTypePointer; | |
| 847 | Token *first_type_token = &pc->tokens->at(*token_index); | |
| 848 | if (first_type_token->id == TokenIdKeywordConst) { | |
| 849 | node->data.type.is_const = true; | |
| 850 | *token_index += 1; | |
| 851 | first_type_token = &pc->tokens->at(*token_index); | |
| 852 | } | |
| 853 | ||
| 854 | node->data.type.child_type = ast_parse_type(pc, token_index); | |
| 855 | } | |
| 844 | 856 | |
| 845 | 857 | /* |
| 846 | 858 | Type : token(Symbol) | token(Unreachable) | token(Void) | PointerType | ArrayType |
| 847 | PointerType : token(Star) (token(Const) | token(Mut)) Type | |
| 859 | PointerType : token(Ampersand) option(token(Const)) Type | |
| 848 | 860 | ArrayType : token(LBracket) Type token(Semicolon) token(Number) token(RBracket) |
| 849 | 861 | */ |
| 850 | 862 | static AstNode *ast_parse_type(ParseContext *pc, int *token_index) { |
| ... | ... | @@ -862,19 +874,17 @@ static AstNode *ast_parse_type(ParseContext *pc, int *token_index) { |
| 862 | 874 | } else if (token->id == TokenIdSymbol) { |
| 863 | 875 | node->data.type.type = AstNodeTypeTypePrimitive; |
| 864 | 876 | ast_buf_from_token(pc, token, &node->data.type.primitive_name); |
| 865 | } else if (token->id == TokenIdStar) { | |
| 877 | } else if (token->id == TokenIdAmpersand) { | |
| 878 | ast_parse_type_assume_amp(pc, token_index, node); | |
| 879 | } else if (token->id == TokenIdBoolAnd) { | |
| 880 | // Pretend that we got 2 ampersand tokens | |
| 866 | 881 | node->data.type.type = AstNodeTypeTypePointer; |
| 867 | Token *const_or_mut = &pc->tokens->at(*token_index); | |
| 868 | *token_index += 1; | |
| 869 | if (const_or_mut->id == TokenIdKeywordMut) { | |
| 870 | node->data.type.is_const = false; | |
| 871 | } else if (const_or_mut->id == TokenIdKeywordConst) { | |
| 872 | node->data.type.is_const = true; | |
| 873 | } else { | |
| 874 | ast_invalid_token_error(pc, const_or_mut); | |
| 875 | } | |
| 876 | 882 | |
| 877 | node->data.type.child_type = ast_parse_type(pc, token_index); | |
| 883 | node->data.type.child_type = ast_create_node_no_line_info(pc, NodeTypeType); | |
| 884 | node->data.type.child_type->line = token->start_line; | |
| 885 | node->data.type.child_type->column = token->start_column + 1; | |
| 886 | ||
| 887 | ast_parse_type_assume_amp(pc, token_index, node->data.type.child_type); | |
| 878 | 888 | } else if (token->id == TokenIdLBracket) { |
| 879 | 889 | node->data.type.type = AstNodeTypeTypeArray; |
| 880 | 890 | |
| ... | ... | @@ -1341,7 +1351,7 @@ static AstNode *ast_parse_bit_shift_expr(ParseContext *pc, int *token_index, boo |
| 1341 | 1351 | |
| 1342 | 1352 | |
| 1343 | 1353 | /* |
| 1344 | BinaryAndExpression : BitShiftExpression token(BinAnd) BinaryAndExpression | BitShiftExpression | |
| 1354 | BinaryAndExpression : BitShiftExpression token(Ampersand) BinaryAndExpression | BitShiftExpression | |
| 1345 | 1355 | */ |
| 1346 | 1356 | static AstNode *ast_parse_bin_and_expr(ParseContext *pc, int *token_index, bool mandatory) { |
| 1347 | 1357 | AstNode *operand_1 = ast_parse_bit_shift_expr(pc, token_index, mandatory); |
| ... | ... | @@ -1350,7 +1360,7 @@ static AstNode *ast_parse_bin_and_expr(ParseContext *pc, int *token_index, bool |
| 1350 | 1360 | |
| 1351 | 1361 | while (true) { |
| 1352 | 1362 | Token *token = &pc->tokens->at(*token_index); |
| 1353 | if (token->id != TokenIdBinAnd) | |
| 1363 | if (token->id != TokenIdAmpersand) | |
| 1354 | 1364 | return operand_1; |
| 1355 | 1365 | *token_index += 1; |
| 1356 | 1366 |
src/tokenizer.cpp+2-2| ... | ... | @@ -320,7 +320,7 @@ void tokenize(Buf *buf, Tokenization *out) { |
| 320 | 320 | t.state = TokenizeStateSawDash; |
| 321 | 321 | break; |
| 322 | 322 | case '&': |
| 323 | begin_token(&t, TokenIdBinAnd); | |
| 323 | begin_token(&t, TokenIdAmpersand); | |
| 324 | 324 | t.state = TokenizeStateSawAmpersand; |
| 325 | 325 | break; |
| 326 | 326 | case '^': |
| ... | ... | @@ -832,7 +832,7 @@ static const char * token_name(Token *token) { |
| 832 | 832 | case TokenIdDash: return "Dash"; |
| 833 | 833 | case TokenIdNumberSign: return "NumberSign"; |
| 834 | 834 | case TokenIdBinOr: return "BinOr"; |
| 835 | case TokenIdBinAnd: return "BinAnd"; | |
| 835 | case TokenIdAmpersand: return "Ampersand"; | |
| 836 | 836 | case TokenIdBinXor: return "BinXor"; |
| 837 | 837 | case TokenIdBoolOr: return "BoolOr"; |
| 838 | 838 | case TokenIdBoolAnd: return "BoolAnd"; |
src/tokenizer.hpp+1-1| ... | ... | @@ -52,7 +52,7 @@ enum TokenId { |
| 52 | 52 | TokenIdBoolOr, |
| 53 | 53 | TokenIdBoolAnd, |
| 54 | 54 | TokenIdBinOr, |
| 55 | TokenIdBinAnd, | |
| 55 | TokenIdAmpersand, | |
| 56 | 56 | TokenIdBinXor, |
| 57 | 57 | TokenIdEq, |
| 58 | 58 | TokenIdTimesEq, |
std/std.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ fn syscall3(number: isize, arg1: isize, arg2: isize, arg3: isize) -> isize { |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // TODO constants for SYS_write and stdout_fileno |
| 17 | pub fn write(fd: isize, buf: *const u8, count: usize) -> isize { | |
| 17 | pub fn write(fd: isize, buf: &const u8, count: usize) -> isize { | |
| 18 | 18 | let SYS_write : isize = 1; |
| 19 | 19 | return syscall3(SYS_write, fd, buf as isize, count as isize); |
| 20 | 20 | } |
test/run_tests.cpp+20-21| ... | ... | @@ -99,7 +99,7 @@ static void add_compiling_test_cases(void) { |
| 99 | 99 | add_simple_case("hello world with libc", R"SOURCE( |
| 100 | 100 | #link("c") |
| 101 | 101 | extern { |
| 102 | fn puts(s: *const u8) -> i32; | |
| 102 | fn puts(s: &const u8) -> i32; | |
| 103 | 103 | fn exit(code: i32) -> unreachable; |
| 104 | 104 | } |
| 105 | 105 | |
| ... | ... | @@ -112,7 +112,7 @@ static void add_compiling_test_cases(void) { |
| 112 | 112 | add_simple_case("function call", R"SOURCE( |
| 113 | 113 | #link("c") |
| 114 | 114 | extern { |
| 115 | fn puts(s: *const u8) -> i32; | |
| 115 | fn puts(s: &const u8) -> i32; | |
| 116 | 116 | fn exit(code: i32) -> unreachable; |
| 117 | 117 | } |
| 118 | 118 | |
| ... | ... | @@ -134,7 +134,7 @@ static void add_compiling_test_cases(void) { |
| 134 | 134 | add_simple_case("comments", R"SOURCE( |
| 135 | 135 | #link("c") |
| 136 | 136 | extern { |
| 137 | fn puts(s: *const u8) -> i32; | |
| 137 | fn puts(s: &const u8) -> i32; | |
| 138 | 138 | fn exit(code: i32) -> unreachable; |
| 139 | 139 | } |
| 140 | 140 | |
| ... | ... | @@ -169,7 +169,7 @@ static void add_compiling_test_cases(void) { |
| 169 | 169 | add_source_file(tc, "libc.zig", R"SOURCE( |
| 170 | 170 | #link("c") |
| 171 | 171 | extern { |
| 172 | pub fn puts(s: *const u8) -> i32; | |
| 172 | pub fn puts(s: &const u8) -> i32; | |
| 173 | 173 | pub fn exit(code: i32) -> unreachable; |
| 174 | 174 | } |
| 175 | 175 | )SOURCE"); |
| ... | ... | @@ -192,7 +192,7 @@ static void add_compiling_test_cases(void) { |
| 192 | 192 | add_simple_case("if statements", R"SOURCE( |
| 193 | 193 | #link("c") |
| 194 | 194 | extern { |
| 195 | fn puts(s: *const u8) -> i32; | |
| 195 | fn puts(s: &const u8) -> i32; | |
| 196 | 196 | fn exit(code: i32) -> unreachable; |
| 197 | 197 | } |
| 198 | 198 | |
| ... | ... | @@ -217,7 +217,7 @@ static void add_compiling_test_cases(void) { |
| 217 | 217 | add_simple_case("params", R"SOURCE( |
| 218 | 218 | #link("c") |
| 219 | 219 | extern { |
| 220 | fn puts(s: *const u8) -> i32; | |
| 220 | fn puts(s: &const u8) -> i32; | |
| 221 | 221 | fn exit(code: i32) -> unreachable; |
| 222 | 222 | } |
| 223 | 223 | |
| ... | ... | @@ -236,7 +236,7 @@ static void add_compiling_test_cases(void) { |
| 236 | 236 | add_simple_case("goto", R"SOURCE( |
| 237 | 237 | #link("c") |
| 238 | 238 | extern { |
| 239 | fn puts(s: *const u8) -> i32; | |
| 239 | fn puts(s: &const u8) -> i32; | |
| 240 | 240 | fn exit(code: i32) -> unreachable; |
| 241 | 241 | } |
| 242 | 242 | |
| ... | ... | @@ -260,7 +260,7 @@ static void add_compiling_test_cases(void) { |
| 260 | 260 | add_simple_case("local variables", R"SOURCE( |
| 261 | 261 | #link("c") |
| 262 | 262 | extern { |
| 263 | fn puts(s: *const u8) -> i32; | |
| 263 | fn puts(s: &const u8) -> i32; | |
| 264 | 264 | fn exit(code: i32) -> unreachable; |
| 265 | 265 | } |
| 266 | 266 | |
| ... | ... | @@ -277,7 +277,7 @@ export fn _start() -> unreachable { |
| 277 | 277 | add_simple_case("bool literals", R"SOURCE( |
| 278 | 278 | #link("c") |
| 279 | 279 | extern { |
| 280 | fn puts(s: *const u8) -> i32; | |
| 280 | fn puts(s: &const u8) -> i32; | |
| 281 | 281 | fn exit(code: i32) -> unreachable; |
| 282 | 282 | } |
| 283 | 283 | |
| ... | ... | @@ -293,7 +293,7 @@ export fn _start() -> unreachable { |
| 293 | 293 | add_simple_case("separate block scopes", R"SOURCE( |
| 294 | 294 | #link("c") |
| 295 | 295 | extern { |
| 296 | fn puts(s: *const u8) -> i32; | |
| 296 | fn puts(s: &const u8) -> i32; | |
| 297 | 297 | fn exit(code: i32) -> unreachable; |
| 298 | 298 | } |
| 299 | 299 | |
| ... | ... | @@ -315,7 +315,7 @@ export fn _start() -> unreachable { |
| 315 | 315 | add_simple_case("void parameters", R"SOURCE( |
| 316 | 316 | #link("c") |
| 317 | 317 | extern { |
| 318 | fn puts(s: *const u8) -> i32; | |
| 318 | fn puts(s: &const u8) -> i32; | |
| 319 | 319 | fn exit(code: i32) -> unreachable; |
| 320 | 320 | } |
| 321 | 321 | |
| ... | ... | @@ -335,7 +335,7 @@ fn void_fun(a : i32, b : void, c : i32) { |
| 335 | 335 | add_simple_case("mutable local variables", R"SOURCE( |
| 336 | 336 | #link("c") |
| 337 | 337 | extern { |
| 338 | fn puts(s: *const u8) -> i32; | |
| 338 | fn puts(s: &const u8) -> i32; | |
| 339 | 339 | fn exit(code: i32) -> unreachable; |
| 340 | 340 | } |
| 341 | 341 | |
| ... | ... | @@ -359,7 +359,7 @@ done: |
| 359 | 359 | add_simple_case("arrays", R"SOURCE( |
| 360 | 360 | #link("c") |
| 361 | 361 | extern { |
| 362 | fn puts(s: *const u8) -> i32; | |
| 362 | fn puts(s: &const u8) -> i32; | |
| 363 | 363 | fn exit(code: i32) -> unreachable; |
| 364 | 364 | } |
| 365 | 365 | |
| ... | ... | @@ -402,7 +402,7 @@ loop_2_end: |
| 402 | 402 | add_simple_case("hello world without libc", R"SOURCE( |
| 403 | 403 | use "std.zig"; |
| 404 | 404 | |
| 405 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 405 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 406 | 406 | print_str("Hello, world!\n" as string); |
| 407 | 407 | return 0; |
| 408 | 408 | } |
| ... | ... | @@ -412,7 +412,7 @@ export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { |
| 412 | 412 | add_simple_case("a + b + c", R"SOURCE( |
| 413 | 413 | use "std.zig"; |
| 414 | 414 | |
| 415 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 415 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 416 | 416 | if false || false || false { print_str("BAD 1\n" as string); } |
| 417 | 417 | if true && true && false { print_str("BAD 2\n" as string); } |
| 418 | 418 | if 1 | 2 | 4 != 7 { print_str("BAD 3\n" as string); } |
| ... | ... | @@ -434,7 +434,7 @@ export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { |
| 434 | 434 | add_simple_case("short circuit", R"SOURCE( |
| 435 | 435 | use "std.zig"; |
| 436 | 436 | |
| 437 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 437 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 438 | 438 | if true || { print_str("BAD 1\n" as string); false } { |
| 439 | 439 | print_str("OK 1\n" as string); |
| 440 | 440 | } |
| ... | ... | @@ -457,7 +457,7 @@ export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { |
| 457 | 457 | add_simple_case("modify operators", R"SOURCE( |
| 458 | 458 | use "std.zig"; |
| 459 | 459 | |
| 460 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 460 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 461 | 461 | let mut i : i32 = 0; |
| 462 | 462 | i += 5; if i != 5 { print_str("BAD +=\n" as string); } |
| 463 | 463 | i -= 2; if i != 3 { print_str("BAD -=\n" as string); } |
| ... | ... | @@ -480,7 +480,7 @@ export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { |
| 480 | 480 | add_simple_case("structs", R"SOURCE( |
| 481 | 481 | use "std.zig"; |
| 482 | 482 | |
| 483 | export fn main(argc : isize, argv : *mut *mut u8, env : *mut *mut u8) -> i32 { | |
| 483 | export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { | |
| 484 | 484 | let mut foo : Foo; |
| 485 | 485 | foo.a = foo.a + 1; |
| 486 | 486 | foo.b = foo.a == 1; |
| ... | ... | @@ -542,7 +542,7 @@ fn a() -> bogus {} |
| 542 | 542 | )SOURCE", 1, ".tmp_source.zig:2:11: error: invalid type name: 'bogus'"); |
| 543 | 543 | |
| 544 | 544 | add_compile_fail_case("pointer to unreachable", R"SOURCE( |
| 545 | fn a() -> *mut unreachable {} | |
| 545 | fn a() -> &unreachable {} | |
| 546 | 546 | )SOURCE", 1, ".tmp_source.zig:2:11: error: pointer to unreachable not allowed"); |
| 547 | 547 | |
| 548 | 548 | add_compile_fail_case("unreachable code", R"SOURCE( |
| ... | ... | @@ -605,7 +605,7 @@ fn f() -> i32 { |
| 605 | 605 | let a = c"a"; |
| 606 | 606 | a |
| 607 | 607 | } |
| 608 | )SOURCE", 1, ".tmp_source.zig:2:15: error: expected type 'i32', got '*const u8'"); | |
| 608 | )SOURCE", 1, ".tmp_source.zig:2:15: error: expected type 'i32', got '&const u8'"); | |
| 609 | 609 | |
| 610 | 610 | add_compile_fail_case("if condition is bool, not int", R"SOURCE( |
| 611 | 611 | fn f() { |
| ... | ... | @@ -682,7 +682,6 @@ fn f() { |
| 682 | 682 | add_compile_fail_case("variadic functions only allowed in extern", R"SOURCE( |
| 683 | 683 | fn f(...) {} |
| 684 | 684 | )SOURCE", 1, ".tmp_source.zig:2:1: error: variadic arguments only allowed in extern functions"); |
| 685 | ||
| 686 | 685 | } |
| 687 | 686 | |
| 688 | 687 | static void print_compiler_invocation(TestCase *test_case) { |