X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=parser.cpp;h=9345760ad2d83b3e4825dbe7fb3d729e40f0cbcc;hp=ddde65469ec77e7cb596e58451dc88096c5ad8f1;hb=451873ae529289f4a22d8bbce6ebf0e074da8f2b;hpb=d9127bf28ad5c1f7626487bbc5f29e72e9912d67 diff --git a/parser.cpp b/parser.cpp index ddde654..9345760 100644 --- a/parser.cpp +++ b/parser.cpp @@ -156,7 +156,7 @@ static ast_expression* parser_find_var(parser_t *parser, const char *name) { bool dummy; ast_expression *v; - v = parser_find_local(parser, name, 0, &dummy); + v = parser_find_local(parser, name, PARSER_HT_LOCALS, &dummy); if (!v) v = parser_find_global(parser, name); return v; } @@ -296,7 +296,11 @@ static bool rotate_entfield_array_index_nodes(ast_expression **out) static int store_op_for(ast_expression* expr) { if (OPTS_FLAG(ADJUST_VECTOR_FIELDS) && expr->m_vtype == TYPE_FIELD && expr->m_next->m_vtype == TYPE_VECTOR) { - return type_storep_instr[TYPE_VECTOR]; + if (ast_istype(expr, ast_entfield)) { + return type_storep_instr[TYPE_VECTOR]; + } else { + return type_store_instr[TYPE_VECTOR]; + } } if (ast_istype(expr, ast_member) && ast_istype(((ast_member*)expr)->m_owner, ast_entfield)) { @@ -338,7 +342,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) const oper_info *op; lex_ctx_t ctx; ast_expression *out = nullptr; - ast_expression *exprs[3]; + ast_expression *exprs[3] = { 0, 0, 0 }; ast_block *blocks[3]; ast_binstore *asbinstore; size_t i, assignop, addop, subop; @@ -1184,6 +1188,12 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) static bool parser_close_call(parser_t *parser, shunt *sy) { + if (!parser->function) + { + parseerror(parser, "cannot call functions from global scope"); + return false; + } + /* was a function call */ ast_expression *fun; ast_value *funval = nullptr; @@ -2753,6 +2763,7 @@ static bool parse_qualifiers(parser_t *parser, bool with_local, int *cvq, bool * { "noreturn", AST_FLAG_NORETURN }, { "inline", AST_FLAG_INLINE }, { "eraseable", AST_FLAG_ERASEABLE }, + { "noerase", AST_FLAG_NOERASE }, { "accumulate", AST_FLAG_ACCUMULATE }, { "last", AST_FLAG_FINAL_DECL } }; @@ -2786,7 +2797,6 @@ static bool parse_qualifiers(parser_t *parser, bool with_local, int *cvq, bool * if (i != GMQCC_ARRAY_COUNT(attributes)) goto leave; - if (!strcmp(parser_tokval(parser), "noref")) { had_noref = true; if (!parser_next(parser) || parser->tok != TOKEN_ATTRIBUTE_CLOSE) { @@ -5187,8 +5197,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield * store the vstring back to var for alias and * deprecation messages. */ - if (var->m_flags & AST_FLAG_DEPRECATED || - var->m_flags & AST_FLAG_ALIAS) + if (var->m_flags & AST_FLAG_DEPRECATED || var->m_flags & AST_FLAG_ALIAS) var->m_desc = vstring; if (parser_find_global(parser, var->m_name) && var->m_flags & AST_FLAG_ALIAS) {