aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2017-07-09 12:07:40 +0200
committergrischka <grischka>2017-07-09 12:07:40 +0200
commit9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5 (patch)
tree2ed2cab29b41d9b17c434d4a15565fb3e8387345 /tccgen.c
parent6c468c10f70d74e962591a0584765e42ce1bcaf2 (diff)
downloadtinycc-9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5.tar.gz
tinycc-9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5.tar.bz2
unsorted adjustments
- configure * use aarch64 instead of arm64 - Makefile * rename the custom include file to "config-extra.mak" * Also avoid "rm -r /*" if $(tccdir) is empty - pp/Makefile * fix .expect generation with gcc - tcc.h * cleanup #defines for _MSC_VER - tccgen.c: * fix const-propagation for &,| * fix anonymous named struct (ms-extension) and enable -fms-extension by default - i386-gen.c * clear VT_DEFSIGN - x86_64-gen.c/win64: * fix passing structs in registers * fix alloca (need to keep "func_scratch" below each alloca area on stack) (This allows to compile a working gnu-make on win64) - tccpp.c * alternative approach to 37999a4fbf3487b363fd0c2f9b7ab622401b202a This is to avoid some slowdown with ## token pasting. * get_tok_str() : return <eof> for TOK_EOF * -funsigned-char: apply to "string" literals as well - tccpe/tools.c: -impdef: support both 32 and 64 bit dlls anyway
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tccgen.c b/tccgen.c
index af8d2a7..40bed59 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -1752,8 +1752,8 @@ static void gen_opic(int op)
vtop--;
} else if (!const_wanted &&
c2 && ((l2 == 0 && (op == '&' || op == '*')) ||
- (l2 == -1 && op == '|') ||
- (l2 == 0xffffffff && t2 != VT_LLONG && op == '|') ||
+ (op == '|' &&
+ (l2 == -1 || (l2 == 0xFFFFFFFF && t2 != VT_LLONG))) ||
(l2 == 1 && (op == '%' || op == TOK_UMOD)))) {
/* treat (x & 0), (x * 0), (x | -1) and (x % 1) as constant */
if (l2 == 1)
@@ -1767,7 +1767,7 @@ static void gen_opic(int op)
op == TOK_SHL || op == TOK_SHR || op == TOK_SAR) &&
l2 == 0) ||
(op == '&' &&
- l2 == -1))) {
+ (l2 == -1 || (l2 == 0xFFFFFFFF && t2 != VT_LLONG))))) {
/* filter out NOP operations like x*1, x-0, x&-1... */
vtop--;
} else if (c2 && (op == '*' || op == TOK_PDIV || op == TOK_UDIV)) {
@@ -1817,6 +1817,10 @@ static void gen_opif(int op)
{
int c1, c2;
SValue *v1, *v2;
+#if defined _MSC_VER && defined _AMD64_
+ /* avoid bad optimization with f1 -= f2 for f1:-0.0, f2:0.0 */
+ volatile
+#endif
long double f1, f2;
v1 = vtop - 1;
@@ -3497,7 +3501,7 @@ static void struct_decl(CType *type, AttributeDef *ad, int u)
if (v < TOK_IDENT)
expect("struct/union/enum name");
s = struct_find(v);
- if (s && (s->scope == local_scope || (tok != '{' && tok != ';'))) {
+ if (s && (s->scope == local_scope || tok != '{')) {
if (s->type.t != a)
tcc_error("redefinition of '%s'", get_tok_str(v, NULL));
goto do_decl;
@@ -4381,6 +4385,8 @@ ST_FUNC void unary(void)
case TOK_STR:
/* string parsing */
t = VT_BYTE;
+ if (tcc_state->char_is_unsigned)
+ t = VT_BYTE | VT_UNSIGNED;
str_init:
if (tcc_state->warn_write_strings)
t |= VT_CONSTANT;