tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] 0.9.22 - Function name in conditional expression?


From: Dave Dodge
Subject: Re: [Tinycc-devel] 0.9.22 - Function name in conditional expression?
Date: Thu, 11 Nov 2004 03:21:21 -0500
User-agent: Mutt/1.4.2i

On Wed, Nov 10, 2004 at 11:11:35PM -0800, Charles Randall wrote:
> First, is this standard C construct?

Yes, at least according to the C99 draft.

> % tcc cond-expr-func.c
> cond-expr-func.c:21: function pointer expected

The problem is that tcc doesn't have any code to recognize function
pointers within a conditional expression, so it defaults to treating
them as integers.  The resulting expression then has integer type,
which of course isn't valid for a function call.  Here's a quick (but
somewhat imcomplete) workaround.

                                                  -Dave Dodge


--- tcc-0.9.22/tcc.c    2004-11-08 15:47:16.000000000 -0500
+++ tcc-0.9.22-fixed/tcc.c      2004-11-11 02:55:54.000000000 -0500
@@ -7598,6 +7598,9 @@
             } else if (bt1 == VT_PTR || bt2 == VT_PTR) {
                 /* XXX: test pointer compatibility */
                 type = type1;
+            } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
+                /* XXX: test function pointer compatibility */
+                type = type1;
             } else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) {
                 /* XXX: test structure compatibility */
                 type = type1;




reply via email to

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