[M3devel] thouhts on -Wall with C backend output

Jay K jay.krell at cornell.edu
Sun Dec 16 10:58:10 CET 2012

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;
      IF (type = Type.root) OR (type = NIL) THEN (* base of
                                                    recursion *)
        RETURN NEW(ImportList.MethodList, ABS(count))
    TYPECASE type OF
          Type.Object (ob) => 
          IF count <= 0 THEN
            count:= count - NUMBER(ob.methods^)
          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.")
              methods[top].name := ob.methods[i].name;
              methods[top].sig := ob.methods[i].sig;
          RETURN methods
        | Type.Opaque (op) =>
          RETURN Search(op.revealedSuperType, count, top, umethods)
        | Type.Reference => <*ASSERT FALSE*>
    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.

  - Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121216/cbfd0b9e/attachment-0001.html>

More information about the M3devel mailing list