<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
drat, these are worse:<br><br>"../src/Macro.m3", line 949: warning: unreachable ELSE in TYPECASE<br><br><br>== package /Users/jay/dev2/cm3/m3-ui/formsvbt ==<br><br> +++ /cm3/bin/cm3 -build -DROOT=/Users/jay/dev2/cm3 +++<br>--- building in AMD64_DARWIN ---<br><br>ignoring ../src/m3overrides<br><br>new source -> compiling Macro.m3<br>cc1plus: warnings being treated as errors<br>Macro.mc.c: In function ‘char* Macro__EvalLength(char*, char*)’:<br>Macro.mc.c:5271: warning: control reaches end of non-void function<br>Macro.mc.c: In function ‘char* Macro__EvalPlus(char*, char*)’:<br>Macro.mc.c:9004: warning: control reaches end of non-void function<br>Macro.mc.c: In function ‘char* Macro__EvalMinus(char*, char*)’:<br>Macro.mc.c:9468: warning: control reaches end of non-void function<br><br><br>If I put in the somewhat obvious:<br><br><br> ELSE <* ASSERT FALSE *><br><br><br>then:<br><br>new source -> compiling Macro.m3<br>"../src/Macro.m3", line 949: warning: unreachable ELSE in TYPECASE<br>1 warning encountered<br>cc1plus: warnings being treated as errors<br>Macro.mc.c: In function ‘char* Macro__EvalLength(char*, char*)’:<br>Macro.mc.c:5271: warning: control reaches end of non-void function<br>Macro.mc.c: In function ‘char* Macro__EvalPlus(char*, char*)’:<br>Macro.mc.c:9004: warning: control reaches end of non-void function<br><br><br><br>For stablegen, I am inclined to put in that ELSE <* ASSERT FALSE *>.<br><br><br>I might might might be able to put in C assert(false) in these places.<br><br> - Jay<br><br><br><div><div id="SkyDrivePlaceholder"></div>> To: hendrik@topoi.pooq.com<br>> Date: Sun, 16 Dec 2012 10:55:29 -0800<br>> From: mika@async.caltech.edu<br>> CC: m3devel@elegosoft.com<br>> Subject: Re: [M3devel] thouhts on -Wall with C backend output<br>> <br>> Can you have an option to add an assertion in the output for these cases?<br>> <br>> Here either<br>> <br>> 1. gcc has found a bug in the C code generator and/or front end, in that<br>> there's no default (abortion) case<br>> <br>> or<br>> <br>> 2. the front end has deduced there is no need for abortion because it can<br>> see that the missing ELSE is never going to be exercised, based on the<br>> already existing type information<br>> <br>> What I'm proposing is two modes for the compiler:<br>> <br>> -- ignore the errors<br>> <br>> or<br>> <br>> -- add proper assertions to the C code, e.g., <br>> <br>> assert(false, "front-end deduced this cant happen by inspecting type information")<br>> <br>> which, when enabled, should make gcc shut up, and instead turn into<br>> runtime checks on the compiler<br>> <br>> Mika<br>> <br>> Hendrik Boom writes:<br>> >On Sun, Dec 16, 2012 at 09:58:10AM +0000, Jay K wrote:<br>> >> <br>> >> I've tried to generate "very good C".<br>> >> I've fixed some of what gcc -Wall complains about.<br>> >> For default gcc on my old MacBook -- old enough that it can still emulate PowerPC, gcc is 4.0.1.<br>> >> (at least one of what I deal with, I think anything newer won't complain..)<br>> >> <br>> >> <br>> >> <br>> >> do-cm3-all with -Wall -Werror gets very far, to:<br>> >> <br>> >> == package /Users/jay/dev2/cm3/m3-db/stablegen ==<br>> >> <br>> >> +++ /cm3/bin/cm3 -build -DROOT=/Users/jay/dev2/cm3 +++<br>> >> --- building in AMD64_DARWIN ---<br>> >> <br>> >> ignoring ../src/m3overrides<br>> >> <br>> >> w source -> compiling GenCode.m3<br>> >> cc1: warnings being treated as errors<br>> >> GenCode.mc.c: In function ‘GenCode__BuildMethods__Search’:<br>> >> GenCode.mc.c:3505: warning: control reaches end of non-void function<br>> >> m3_backend => 1<br>> >> <br>> >> PROCEDURE Search ( type : Type.Reference;<br>> >> VAR count : INTEGER;<br>> >> VAR top : CARDINAL;<br>> >> umethods: AtomList.T ):<br>> >> ImportList.MethodList RAISES {StablegenError.E} =<br>> >> VAR methods: ImportList.MethodList;<br>> >> BEGIN<br>> >> IF (type = Type.root) OR (type = NIL) THEN (* base of<br>> >> recursion *)<br>> >> RETURN NEW(ImportList.MethodList, ABS(count))<br>> >> ELSE<br>> >> TYPECASE type OF<br>> >> Type.Object (ob) => <br>> >> IF count <= 0 THEN<br>> >> count:= count - NUMBER(ob.methods^)<br>> >> END;<br>> >> methods := Search(ob.super, count, top, umethods);<br>> >> FOR i := 0 TO LAST(ob.methods^) DO<br>> >> IF umethods = NIL<br>> >> OR AtomList.Member(<br>> >> umethods, ob.methods[i].name) THEN<br>> >> IF AtomList.Member(reserved, ob.methods[i].name) THEN<br>> >> RAISE StablegenError.E(Atom.ToText(ob.methods[i].name)<br>> >> &" is a reserved method name in stable objects. "<br>> >> &"Must not be an update method.")<br>> >> END;<br>> >> methods[top].name := ob.methods[i].name;<br>> >> methods[top].sig := ob.methods[i].sig;<br>> >> INC(top)<br>> >> END<br>> >> END;<br>> >> RETURN methods<br>> >> | Type.Opaque (op) =><br>> >> RETURN Search(op.revealedSuperType, count, top, umethods)<br>> >> | Type.Reference => <*ASSERT FALSE*><br>> >> END<br>> >> END<br>> >> END Search;<br>> >> <br>> >> I think we can't expect gcc -Wall -Werror to pass.<br>> >> I really wanted it to, and I tried, and I fixed stuff.<br>> >> But I don't think it is viable.<br>> >> Ok?<br>> ><br>> >Could it be that the TYPECASE doesn't have an ELSE clause, possibly<br>> >translated to a switch withouy a default: label? This would give the<br>> >C code an apparent path to the end of the function. M3 may know that<br>> >the TYPECASE exhausts all the possibilities, but C will not.<br>> ><br>> >-- hendrik<br></div> </div></body>
</html>