aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-02-25 21:04:23 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-02-25 21:04:23 -0700
commit0b58b617998b79a765b54f88fbe90ca2798b3d3e (patch)
treeca6cc4b6bcc2b93166d196049ee49416afe781ad /src/stage1/parser.cpp
parentdc325669e360f7a9dfa24f85a62fa386529dade6 (diff)
parentfd208d9d5913a0929e444deb97b91092c427bb14 (diff)
downloadzig-0b58b617998b79a765b54f88fbe90ca2798b3d3e.tar.gz
zig-0b58b617998b79a765b54f88fbe90ca2798b3d3e.zip
Merge remote-tracking branch 'origin/master' into llvm12
Conflicts: * src/clang.zig * src/llvm.zig - this file got moved to src/llvm/bindings.zig in master branch so I had to put the new LLVM arch/os enum tags into it. * lib/std/target.zig, src/stage1/target.cpp - haiku had an inconsistency with its default target ABI, gnu vs eabi. In this commit we make it gnu in both places to match the latest changes by @hoanga. * src/translate_c.zig
Diffstat (limited to 'src/stage1/parser.cpp')
-rw-r--r--src/stage1/parser.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/stage1/parser.cpp b/src/stage1/parser.cpp
index eab4ea0f77..c37b3ffefb 100644
--- a/src/stage1/parser.cpp
+++ b/src/stage1/parser.cpp
@@ -658,10 +658,10 @@ static AstNode *ast_parse_test_decl(ParseContext *pc) {
if (test == nullptr)
return nullptr;
- Token *name = expect_token(pc, TokenIdStringLiteral);
+ Token *name = eat_token_if(pc, TokenIdStringLiteral);
AstNode *block = ast_expect(pc, ast_parse_block);
AstNode *res = ast_create_node(pc, NodeTypeTestDecl, test);
- res->data.test_decl.name = token_buf(name);
+ res->data.test_decl.name = name ? token_buf(name) : nullptr;
res->data.test_decl.body = block;
return res;
}
@@ -694,15 +694,13 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
if (first == nullptr)
first = eat_token_if(pc, TokenIdKeywordExtern);
if (first == nullptr)
- first = eat_token_if(pc, TokenIdKeywordInline);
- if (first == nullptr)
first = eat_token_if(pc, TokenIdKeywordNoInline);
if (first != nullptr) {
Token *lib_name = nullptr;
if (first->id == TokenIdKeywordExtern)
lib_name = eat_token_if(pc, TokenIdStringLiteral);
- if (first->id != TokenIdKeywordInline && first->id != TokenIdKeywordNoInline) {
+ if (first->id != TokenIdKeywordNoInline) {
Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);
AstNode *var_decl = ast_parse_var_decl(pc);
if (var_decl != nullptr) {
@@ -739,17 +737,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
if (!fn_proto->data.fn_proto.is_extern)
fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
- switch (first->id) {
- case TokenIdKeywordInline:
- fn_proto->data.fn_proto.fn_inline = FnInlineAlways;
- break;
- case TokenIdKeywordNoInline:
- fn_proto->data.fn_proto.fn_inline = FnInlineNever;
- break;
- default:
- fn_proto->data.fn_proto.fn_inline = FnInlineAuto;
- break;
- }
+ if (first->id == TokenIdKeywordNoInline)
+ fn_proto->data.fn_proto.is_noinline = true;
fn_proto->data.fn_proto.lib_name = token_buf(lib_name);
AstNode *res = fn_proto;
@@ -2460,7 +2449,6 @@ static AstNode *ast_parse_assign_op(ParseContext *pc) {
// In C, we have `T arr[N] = {[i] = T{}};` but it doesn't
// seem to work in C++...
BinOpType table[TokenIdCount] = {};
- table[TokenIdBarBarEq] = BinOpTypeAssignMergeErrorSets;
table[TokenIdBitAndEq] = BinOpTypeAssignBitAnd;
table[TokenIdBitOrEq] = BinOpTypeAssignBitOr;
table[TokenIdBitShiftLeftEq] = BinOpTypeAssignBitShiftLeft;