[Top][All Lists]

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

Re: [bug-mes] MesCC assigns incorrect types to arithmetic expressions

From: Jan Nieuwenhuizen
Subject: Re: [bug-mes] MesCC assigns incorrect types to arithmetic expressions
Date: Thu, 18 Jul 2019 20:19:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Mark H Weaver writes:

> Currently, if I understand the code correctly, MesCC simply assigns the
> type of the first operand as the type of most (all?) binary expressions.
> For example, the type of (a + b) is the type of a, with no regard to b.
> Ditto for the relational operators.  In particular, I'm looking at
> 'ast->type' in compile.scm.

Ah, that could be; good catch.

Do you have a suggestion for a failing test (as this was something
you're aware of?).

> From an admittedly quick search, I didn't see anything about the usual
> arithmetic conversions, or the integer promotions.  Did I miss them?

I'm not sure what is usual; this is my first C compiler and I never
thought it would work so well.  As you have seen, it could do with
some refactoring; as soon as MesCC procuded a working tcc I paused
development and started on integrating mes/mescc into the guix

Promotion-wise, I think that is handled in some individual cases,
like here

--8<---------------cut here---------------start------------->8---
        ((ge ,a ,b)
         (let* ((type-a (ast->type a info))
                (type-b (ast->type b info))
                (info ((binop->r info) a b 'r0-r1))
                (test->r (if (or (unsigned? type-a) (unsigned? type-b)) 'ae?->r 
                (info (append-text info (wrap-as (as info test->r))))
                (info (append-text info (wrap-as (as info 'test-r)))))
--8<---------------cut here---------------end--------------->8---

These tests (WIP branch) currently fail

--8<---------------cut here---------------start------------->8---
--8<---------------cut here---------------end--------------->8---

which may be what you're aiming at?

Thanks a lot for looking at this!


Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com

reply via email to

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