diff --git a/libtcc.c b/libtcc.c
index 7e36ceac..36986328 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -221,6 +221,10 @@ PUB_FUNC char *tcc_fileextension (const char *name)
 /********************************************************/
 /* memory management */
 
+#undef free
+#undef malloc
+#undef realloc
+
 #ifndef MEM_DEBUG
 
 PUB_FUNC void tcc_free(void *ptr)
@@ -417,6 +421,10 @@ PUB_FUNC void tcc_memcheck(void)
 }
 #endif /* MEM_DEBUG */
 
+#define free(p) use_tcc_free(p)
+#define malloc(s) use_tcc_malloc(s)
+#define realloc(p, s) use_tcc_realloc(p, s)
+
 /********************************************************/
 /* dynarrays */
 
diff --git a/tcc.h b/tcc.h
index ec7860d7..ccb3b603 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1229,11 +1229,16 @@ PUB_FUNC void *tcc_realloc_debug(void *ptr, unsigned long size, const char *file
 PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line);
 #endif
 
+#define free(p) use_tcc_free(p)
+#define malloc(s) use_tcc_malloc(s)
+#define realloc(p, s) use_tcc_realloc(p, s)
+#undef strdup
+#define strdup(s) use_tcc_strdup(s)
 PUB_FUNC void _tcc_error_noabort(const char *fmt, ...) PRINTF_LIKE(1,2);
 PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...) PRINTF_LIKE(1,2);
 PUB_FUNC void _tcc_warning(const char *fmt, ...) PRINTF_LIKE(1,2);
 #define tcc_internal_error(msg) tcc_error("internal compiler error\n"\
-        "%s:%d: in %s(): " msg, __FILE__,__LINE__,__func__)
+        "%s:%d: in %s(): " msg, __FILE__,__LINE__,__FUNCTION__)
 
 /* other utilities */
 ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data);
diff --git a/tccgen.c b/tccgen.c
index 681fa192..26e9f53e 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -5591,7 +5591,9 @@ ST_FUNC void unary(void)
         } else if (tok == '{') {
 	    int saved_nocode_wanted = nocode_wanted;
             if (const_wanted && !(nocode_wanted & unevalmask))
-                tcc_error("expected constant");
+                expect("constant");
+            if (0 == local_scope)
+                tcc_error("statement expression outside of function");
             /* save all registers */
             save_regs(0);
             /* statement expression : we do not accept break/continue
@@ -6950,7 +6952,12 @@ static void block(int is_expr)
     }
 
 again:
-    t = tok, next();
+    t = tok;
+    /* If the token carries a value, next() might destroy it. Only with
+       invalid code such as f(){"123"4;} */
+    if (TOK_HAS_VALUE(t))
+        goto expr;
+    next();
 
     if (t == TOK_IF) {
         skip('(');
@@ -7253,6 +7260,7 @@ again:
             /* expression case */
             if (t != ';') {
                 unget_tok(t);
+    expr:
                 if (is_expr) {
                     vpop();
                     gexpr();
@@ -8281,7 +8289,7 @@ static void free_inline_functions(TCCState *s)
    if parsing old style parameter decl list (and FUNC_SYM is set then) */
 static int decl0(int l, int is_for_loop_init, Sym *func_sym)
 {
-    int v, has_init, r;
+    int v, has_init, r, oldint;
     CType type, btype;
     Sym *sym;
     AttributeDef ad, adbase;
@@ -8312,6 +8320,8 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
             skip(';');
 	    continue;
 	}
+
+        oldint = 0;
         if (!parse_btype(&btype, &adbase)) {
             if (is_for_loop_init)
                 return 0;
@@ -8331,15 +8341,17 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
                /* special test for old K&R protos without explicit int
                   type. Only accepted when defining global data */
                 btype.t = VT_INT;
+                oldint = 1;
             } else {
                 if (tok != TOK_EOF)
                     expect("declaration");
                 break;
             }
         }
+
         if (tok == ';') {
 	    if ((btype.t & VT_BTYPE) == VT_STRUCT) {
-		int v = btype.ref->v;
+		v = btype.ref->v;
 		if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)
         	    tcc_warning("unnamed struct/union that defines no instances");
                 next();
@@ -8350,6 +8362,7 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
                 continue;
             }
         }
+
         while (1) { /* iterate thru each declaration */
             type = btype;
 	    ad = adbase;
@@ -8384,6 +8397,9 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
                 /* always compile 'extern inline' */
                 if (type.t & VT_EXTERN)
                     type.t &= ~VT_INLINE;
+
+            } else if (oldint) {
+                tcc_warning("type defaults to int");
             }
 
             if (gnu_ext && (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3)) {
diff --git a/tccpe.c b/tccpe.c
index d2e2f7da..c7dcf1a8 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -922,9 +922,7 @@ static void pe_build_exports(struct pe_info *pe)
     for (sym_index = 1; sym_index < sym_end; ++sym_index) {
         sym = (ElfW(Sym)*)symtab_section->data + sym_index;
         name = pe_export_name(pe->s1, sym);
-        if ((sym->st_other & ST_PE_EXPORT)
-            /* export only symbols from actually written sections */
-            && pe->s1->sections[sym->st_shndx]->sh_addr) {
+        if (sym->st_other & ST_PE_EXPORT) {
             p = tcc_malloc(sizeof *p);
             p->index = sym_index;
             p->name = name;
diff --git a/tests/tests2/102_alignas.expect b/tests/tests2/102_alignas.expect
index ac6474af..b458e074 100644
--- a/tests/tests2/102_alignas.expect
+++ b/tests/tests2/102_alignas.expect
@@ -1 +1,2 @@
+102_alignas.c:4: warning: type defaults to int
 1 1 1 1
diff --git a/tests/tests2/60_errors_and_warnings.c b/tests/tests2/60_errors_and_warnings.c
index ede00186..d6571e90 100644
--- a/tests/tests2/60_errors_and_warnings.c
+++ b/tests/tests2/60_errors_and_warnings.c
@@ -354,5 +354,16 @@ struct c1 c1 = { 1, { 2, 3, 4 } };
 struct c2 { int c; struct c1 c1; };
 struct c2 c2 = { 1, { 2, { 3, 4, 5 }}};
 
+/******************************************************************/
+#elif defined test_default_int_type
+n; // warn
+f(); // don't warn
+
+#elif defined test_invalid_global_stmtexpr
+n[sizeof({3;})]; // crashed in block() due to missing local scope
+
+#elif defined test_invalid_tokckill
+f(){"12"3;} // second const token killed the value of the first
+
 /******************************************************************/
 #endif
diff --git a/tests/tests2/60_errors_and_warnings.expect b/tests/tests2/60_errors_and_warnings.expect
index 8705f40b..24a5d5ea 100644
--- a/tests/tests2/60_errors_and_warnings.expect
+++ b/tests/tests2/60_errors_and_warnings.expect
@@ -165,3 +165,12 @@ bar  : 3 ; 3
 
 [test_var_array2]
 60_errors_and_warnings.c:355: error: flexible array has zero size in this context
+
+[test_default_int_type]
+60_errors_and_warnings.c:359: warning: type defaults to int
+
+[test_invalid_global_stmtexpr]
+60_errors_and_warnings.c:363: error: statement expression outside of function
+
+[test_invalid_tokckill]
+60_errors_and_warnings.c:366: error: ';' expected (got "3")
diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat
index e3ec5b7f..8fc51472 100644
--- a/win32/build-tcc.bat
+++ b/win32/build-tcc.bat
@@ -124,7 +124,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f
 %CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
 %CC% -o %PX%-tcc.exe ..\tcc.c %DX%
 
-@if (%EXES_ONLY%)==(yes) goto :files-done
+@if (%EXES_ONLY%)==(yes) goto :files_done
 
 if not exist libtcc mkdir libtcc
 if not exist doc mkdir doc
@@ -174,7 +174,7 @@ echo>..\config.texi @set VERSION %VERSION%
 cmd /c makeinfo --html --no-split ../tcc-doc.texi -o doc/tcc-doc.html
 :doc-done
 
-:files-done
+:files_done
 for %%f in (*.o *.def) do @del %%f
 
 :copy-install