tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [patch] Segmentation fault compiling broken 1-liner


From: Marcelo Jimenez
Subject: Re: [Tinycc-devel] [patch] Segmentation fault compiling broken 1-liner
Date: Wed, 31 Aug 2005 02:01:17 -0300

On 8/31/05, Antti-Juhani Kaijanaho <address@hidden> 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)

Attachment: unexpected-token.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]