From: Wolfgang (Blub) Bumiller Date: Wed, 19 Dec 2012 21:15:38 +0000 (+0100) Subject: Revert "Fix FTFBS stuff" X-Git-Tag: 0.1.9~35 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=57aaf57dfc77c3c660fbb97c18ee0edcda5a8662;p=xonotic%2Fgmqcc.git Revert "Fix FTFBS stuff" This reverts commit 2cc51b8eb060e6efab5b56cf471594911a79c5c1. --- diff --git a/gmqcc.h b/gmqcc.h index 9223e4f..b1e0cde 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -175,7 +175,13 @@ typedef struct { char _fail : 0; } int64_t; typedef struct { char _fail : 0; } uint64_t; #endif - +#ifdef _LP64 /* long pointer == 64 */ + typedef unsigned long uintptr_t; + typedef long intptr_t; +#else + typedef unsigned int uintptr_t; + typedef int intptr_t; +#endif /* Ensure type sizes are correct: */ typedef char uint8_size_is_correct [sizeof(uint8_t) == 1?1:-1]; typedef char uint16_size_is_correct [sizeof(uint16_t) == 2?1:-1]; @@ -184,6 +190,10 @@ typedef char uint64_size_is_correct [sizeof(uint64_t) == 8?1:-1]; typedef char int16_size_if_correct [sizeof(int16_t) == 2?1:-1]; typedef char int32_size_is_correct [sizeof(int32_t) == 4?1:-1]; typedef char int64_size_is_correct [sizeof(int64_t) >= 8?1:-1]; +/* intptr_t / uintptr_t correct size check */ +typedef char uintptr_size_is_correct[sizeof(intptr_t) == sizeof(int*)?1:-1]; +typedef char intptr_size_is_correct [sizeof(uintptr_t)== sizeof(int*)?1:-1]; + /*===================================================================*/ /*=========================== util.c ================================*/ /*===================================================================*/ diff --git a/ir.c b/ir.c index ea7476b..48cc067 100644 --- a/ir.c +++ b/ir.c @@ -3542,8 +3542,8 @@ bool ir_builder_generate(ir_builder *self, const char *filename) #define IND_BUFSZ 1024 -#ifdef _MSC_VER -# define strncat(dst, src, sz) strncat_s(dst, sz, src, _TRUNCATE) +#ifdef WIN32 +# define strncat(dst, src, sz) strncat_s(dst, sz, src, _TRUNCATE) #endif const char *qc_opname(int op) diff --git a/opts.def b/opts.def index f1adc7a..157f80f 100644 --- a/opts.def +++ b/opts.def @@ -39,6 +39,7 @@ GMQCC_DEFINE_FLAG(ASSIGN_FUNCTION_TYPES) GMQCC_DEFINE_FLAG(LNO) GMQCC_DEFINE_FLAG(CORRECT_TERNARY) + GMQCC_DEFINE_FLAG(SINGLE_VECTOR_DEFS) #endif /* warning flags */ diff --git a/parser.c b/parser.c index 852da53..6f2ddd8 100644 --- a/parser.c +++ b/parser.c @@ -98,6 +98,8 @@ typedef struct { bool noref; } parser_t; +static const ast_expression *intrinsic_debug_typestring = (ast_expression*)0x10; + static void parser_enterblock(parser_t *parser); static bool parser_leaveblock(parser_t *parser); static void parser_addlocal(parser_t *parser, const char *name, ast_expression *e); @@ -835,13 +837,19 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) return false; } #endif - if (opts.standard == COMPILER_GMQCC) - con_out("TODO: early out logic\n"); if (CanConstFold(exprs[0], exprs[1])) out = (ast_expression*)parser_const_float(parser, (generated_op == INSTR_OR ? (ConstF(0) || ConstF(1)) : (ConstF(0) && ConstF(1)))); else + { + if (OPTS_FLAG(PERL_LOGIC) && !ast_compare_type(exprs[0], exprs[1])) { + ast_type_to_string(exprs[0], ty1, sizeof(ty1)); + ast_type_to_string(exprs[1], ty2, sizeof(ty2)); + parseerror(parser, "invalid types for logical operation with -fperl-logic: %s and %s", ty1, ty2); + return false; + } out = (ast_expression*)ast_binary_new(ctx, generated_op, exprs[0], exprs[1]); + } break; case opid2('?',':'): @@ -1192,9 +1200,25 @@ static bool parser_close_call(parser_t *parser, shunt *sy) fun = sy->out[fid].out; + if (fun == intrinsic_debug_typestring) { + char ty[1024]; + if (fid+2 != vec_size(sy->out) || + vec_last(sy->out).block) + { + parseerror(parser, "intrinsic __builtin_debug_typestring requires exactly 1 parameter"); + return false; + } + ast_type_to_string(vec_last(sy->out).out, ty, sizeof(ty)); + ast_unref(vec_last(sy->out).out); + sy->out[fid] = syexp(ast_ctx(vec_last(sy->out).out), + (ast_expression*)parser_const_string(parser, ty, false)); + vec_shrinkby(sy->out, 1); + return true; + } + call = ast_call_new(sy->ops[vec_size(sy->ops)].ctx, fun); if (!call) { - parseerror(parser, "out of memory"); + parseerror(parser, "internal error: failed to create ast_call node"); return false; } @@ -1251,9 +1275,9 @@ static bool parser_close_call(parser_t *parser, shunt *sy) fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line); else parseerror(parser, "too %s parameters for function call: expected %i, got %i\n" - " -> `%s` has been declared here: %s:%i", - fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount, - fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line); + " -> it has been declared here: %s:%i", + fewmany, (int)vec_size(fun->expression.params), (int)paramcount, + ast_ctx(fun).file, (int)ast_ctx(fun).line); return false; } else @@ -1267,9 +1291,9 @@ static bool parser_close_call(parser_t *parser, shunt *sy) else return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS, "too %s parameters for function call: expected %i, got %i\n" - " -> `%s` has been declared here: %s:%i", - fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount, - fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line); + " -> it has been declared here: %s:%i", + fewmany, (int)vec_size(fun->expression.params), (int)paramcount, + ast_ctx(fun).file, (int)ast_ctx(fun).line); } } } @@ -1432,16 +1456,27 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma var = parser_find_field(parser, parser_tokval(parser)); } if (!var) { - parseerror(parser, "unexpected ident: %s", parser_tokval(parser)); - goto onerr; - } - if (ast_istype(var, ast_value)) { - ((ast_value*)var)->uses++; + /* intrinsics */ + if (!strcmp(parser_tokval(parser), "__builtin_debug_typestring")) { + var = (ast_expression*)intrinsic_debug_typestring; + + } + else + { + parseerror(parser, "unexpected ident: %s", parser_tokval(parser)); + goto onerr; + } } - else if (ast_istype(var, ast_member)) { - ast_member *mem = (ast_member*)var; - if (ast_istype(mem->owner, ast_value)) - ((ast_value*)(mem->owner))->uses++; + else + { + if (ast_istype(var, ast_value)) { + ((ast_value*)var)->uses++; + } + else if (ast_istype(var, ast_member)) { + ast_member *mem = (ast_member*)var; + if (ast_istype(mem->owner, ast_value)) + ((ast_value*)(mem->owner))->uses++; + } } vec_push(sy.out, syexp(parser_ctx(parser), var)); DEBUGSHUNTDO(con_out("push %s\n", parser_tokval(parser))); @@ -1663,7 +1698,6 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma vec_push(sy.ops, syparen(parser_ctx(parser), SY_PAREN_INDEX, 0)); wantop = false; } else if (op->id == opid2('?',':')) { - wantop = false; vec_push(sy.ops, syop(parser_ctx(parser), op)); vec_push(sy.ops, syparen(parser_ctx(parser), SY_PAREN_TERNARY, 0)); wantop = false; @@ -2308,8 +2342,7 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou return false; } if (!OPTS_FLAG(RELAXED_SWITCH)) { - opval = (ast_value*)swcase.value; - if (!ast_istype(swcase.value, ast_value)) { /* || opval->cvq != CV_CONST) { */ + if (!ast_istype(swcase.value, ast_value)) { /* || ((ast_value*)swcase.value)->cvq != CV_CONST) { */ parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch"); ast_unref(operand); return false; diff --git a/util.c b/util.c index 2ad2880..15db97c 100644 --- a/util.c +++ b/util.c @@ -495,7 +495,7 @@ size_t util_strtononcmd(const char *in, char *out, size_t outsz) { FILE *util_fopen(const char *filename, const char *mode) { -#ifdef _MSC_VER +#ifdef WIN32 FILE *out; if (fopen_s(&out, filename, mode) != 0) return NULL;