On 8/31/05, Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> wrote:
> > The missing () on main does however make it very invalid C.
> 
> That's just a syntax violation.
> 
> --
> Antti-Juhani

I have found out that this is indeed the cause of the crash. The fact
that it worked with gcc32 -O0 was in fact a gcc32 bug :)

This patch fixes the issue.

Index: tcc.c
===================================================================
RCS file: /cvsroot/tinycc/tinycc/tcc.c,v
retrieving revision 1.172
diff -u -r1.172 tcc.c
--- tcc.c       17 Jun 2005 22:05:58 -0000      1.172
+++ tcc.c       31 Aug 2005 04:23:30 -0000
@@ -1423,6 +1420,11 @@
     error("%s expected", msg);
 }
 
+void unexpected_token(void)
+{
+    error("unexpected token: '%c'", tok);
+}
+
 void warning(const char *fmt, ...)
 {
     TCCState *s1 = tcc_state;
@@ -6953,6 +6960,9 @@
                 expect("identifier");
             *v = 0;
         }
+    }
+    if (tok == '{') {
+        unexpected_token();
     }
     post_type(type, ad);
     if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
Index: tcc.c
===================================================================
RCS file: /cvsroot/tinycc/tinycc/tcc.c,v
retrieving revision 1.172
diff -u -r1.172 tcc.c
--- tcc.c	17 Jun 2005 22:05:58 -0000	1.172
+++ tcc.c	31 Aug 2005 04:23:30 -0000
@@ -1423,6 +1420,11 @@
     error("%s expected", msg);
 }
 
+void unexpected_token(void)
+{
+    error("unexpected token: '%c'", tok);
+}
+
 void warning(const char *fmt, ...)
 {
     TCCState *s1 = tcc_state;
@@ -6953,6 +6960,9 @@
                 expect("identifier");
             *v = 0;
         }
+    }
+    if (tok == '{') {
+        unexpected_token();
     }
     post_type(type, ad);
     if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to