[M3devel] thouhts on -Wall with C backend output

Rodney M. Bates rodney_bates at lcwb.coop
Sun Dec 16 17:24:06 CET 2012


You know, here is my view on the whole subject.

A compiler, used in the usual way, has two functions: help to find a lot of programming
errors that are statically detectable, and translate to machine code.  When you feed a
compiler with mechanically produced source code, the former function is not really that
important.  Ideally, the translator (including its own front end, in this case, the
M3 front end) should take care of all the static error checking and just produce
code that will translate properly.

So once the translator is stable, it makes sense for ordinary users to ignore warnings
from the back end compiler.  They may still be very useful for testing the translator.

I know this is a bit idealistic, and it takes more work for the translator developer
to do it this way.  But it's best for the user.  Trying to correlate a warning (or
error) issued by the back end compiler back to the original problem (if there is one)
in the original source code can be exasperating for a user.

So I'd say put the effort into making sure anything a user should care about is detected
by the M3 front end and/or M3C.  Then tell your users not to worry about messages from
gcc.

Yeah, I know this ignores the question of a user's wondering of messages from gcc are
actually evidence of bugs in M3front/M3C.

On 12/16/2012 03:58 AM, Jay K wrote:
> I've tried to generate "very good C".
> I've fixed some of what gcc -Wall complains about.
> For default gcc on my old MacBook -- old enough that it can still emulate PowerPC, gcc is 4.0.1.
> (at least one of what I deal with, I think anything newer won't complain..)
>
>
>
> do-cm3-all with -Wall -Werror gets very far, to:
>
> == package /Users/jay/dev2/cm3/m3-db/stablegen ==
>
>   +++ /cm3/bin/cm3    -build -DROOT=/Users/jay/dev2/cm3 +++
> --- building in AMD64_DARWIN ---
>
> ignoring ../src/m3overrides
>
> w source -> compiling GenCode.m3
> cc1: warnings being treated as errors
> GenCode.mc.c: In function ‘GenCode__BuildMethods__Search’:
> GenCode.mc.c:3505: warning: control reaches end of non-void function
>    m3_backend => 1
>
>    PROCEDURE Search (    type    : Type.Reference;
>                      VAR count   : INTEGER;
>                      VAR top     : CARDINAL;
>                          umethods: AtomList.T   ):
>      ImportList.MethodList RAISES {StablegenError.E} =
>      VAR methods: ImportList.MethodList;
>      BEGIN
>        IF (type = Type.root) OR (type = NIL) THEN (* base of
>                                                      recursion *)
>          RETURN NEW(ImportList.MethodList, ABS(count))
>        ELSE
>      TYPECASE type OF
>            Type.Object (ob) =>
>            IF count <= 0 THEN
>              count:= count - NUMBER(ob.methods^)
>            END;
>            methods := Search(ob.super, count, top, umethods);
>            FOR i := 0 TO LAST(ob.methods^) DO
>              IF umethods = NIL
>                OR AtomList.Member(
>                       umethods, ob.methods[i].name) THEN
>                IF AtomList.Member(reserved, ob.methods[i].name) THEN
>                  RAISE StablegenError.E(Atom.ToText(ob.methods[i].name)
>                  &" is a reserved method name in stable objects. "
>                  &"Must not be an update method.")
>                END;
>                methods[top].name := ob.methods[i].name;
>                methods[top].sig := ob.methods[i].sig;
>                INC(top)
>              END
>            END;
>            RETURN methods
>          | Type.Opaque (op) =>
>            RETURN Search(op.revealedSuperType, count, top, umethods)
>          | Type.Reference => <*ASSERT FALSE*>
>          END
>        END
>      END Search;
>
> I think we can't expect gcc -Wall -Werror to pass.
> I really wanted it to, and I tried, and I fixed stuff.
> But I don't think it is viable.
> Ok?
>
>
>    - Jay




More information about the M3devel mailing list