<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">thanks for the clarification Richard, it helped.<br>
<br>
I consider the question here by answered.<br>
<br>
<div>
<div style="font-size:13px; font-family:Tahoma">
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">.......................................................................................................................</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:black" lang="EN-US"><br>
Per Viberg </span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">Senior Engineer</span><span style="font-size:8.5pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"><br>
Evidente ES East</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"> AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
</span><span style="font-size:10pt; font-family:'Tahoma','sans-serif'; color:black" lang="EN-US"></span></p>
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-GB">Phone: +46 (0)8 402 79 00<br>
Mobile: +46 (0)70 912 42 52<br>
E-mail: <a href="mailto:Per.Viberg@evidente.se" target="_blank"><font color="#0000ff">Per.Viberg@evidente.se</font></a>
</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:black" lang="EN-GB"><br>
<br>
<a href="http://www.evidente.se" target="_blank"><font color="#0000ff">www.evidente.se</font></a></span></p>
<p class="MsoNormal"><span style="font-size:6pt; font-family:'Arial','sans-serif'" lang="EN-GB">This e-mail, which might contain confidential information, is addressed to the above stated person/company. If you are not the correct addressee, employee or in
any other way the person concerned, please notify the sender immediately. At the same time, please delete this e-mail and destroy any prints. Thank You.</span></p>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF547654"><font color="#000000" face="Tahoma" size="2"><b>Från:</b> metafoo@gmail.com [metafoo@gmail.com] för Richard Smith [richard@metafoo.co.uk]<br>
<b>Skickat:</b> den 10 mars 2014 18:24<br>
<b>Till:</b> Per Viberg<br>
<b>Cc:</b> Jordan Rose; cfe-dev Developers<br>
<b>Ämne:</b> Re: [cfe-dev] SwitchStmt bug?<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Mon, Mar 10, 2014 at 10:13 AM, Per Viberg <span dir="ltr">
<<a href="mailto:Per.Viberg@evidente.se" target="_blank">Per.Viberg@evidente.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div style="word-wrap:break-word">
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">thanks guys for the quick reply,<br>
<br>
yeah, I suspected something like that. The only thing I was surprised about was that there is a Stmt at all inside a switch "label". I mean, if they are just like goto labels, then no statement at all would seem more intuitive. </div>
</div>
</blockquote>
<div><br>
</div>
<div>Consider this:</div>
<div><br>
</div>
<div>switch (x) {</div>
<div> if (a)</div>
<div> case 1: b;</div>
<div> c;</div>
<div>}</div>
<div><br>
</div>
<div>An 'if' statement can only have one substatement, so the case label *must* have 'b' as its child or we'd have no way to represent this code. And the case label must *not* have 'c' as its child, or we'd be representing this incorrectly.</div>
<div><br>
</div>
<div>Also, the relevant language standards say that labels have a single statement as a child, and we try to make our representations faithful to the relevant standards as far as is reasonably possible.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div style="word-wrap:break-word">
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">
<div class="">
<div>
<div style="font-size:13px; font-family:Tahoma">
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">.......................................................................................................................</span><span style="font-size:8pt; font-family:'Arial','sans-serif'" lang="EN-US"><br>
Per Viberg </span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">Senior Engineer</span><span style="font-size:8.5pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"><br>
Evidente ES East</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"> AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
</span><span style="font-size:10pt; font-family:'Tahoma','sans-serif'" lang="EN-US"></span></p>
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-GB">Phone:
<a href="tel:%2B46%20%280%298%20402%2079%2000" value="+4684027900" target="_blank">
+46 (0)8 402 79 00</a><br>
Mobile: <a href="tel:%2B46%20%280%2970%C2%A0912%2042%2052" value="+46709124252" target="_blank">
+46 (0)70 912 42 52</a><br>
E-mail: <a href="mailto:Per.Viberg@evidente.se" target="_blank"><font color="#0000ff">Per.Viberg@evidente.se</font></a>
</span><span style="font-size:8pt; font-family:'Arial','sans-serif'" lang="EN-GB"><br>
<br>
<a href="http://www.evidente.se" target="_blank"><font color="#0000ff">www.evidente.se</font></a></span></p>
<p class="MsoNormal"><span style="font-size:6pt; font-family:'Arial','sans-serif'" lang="EN-GB">This e-mail, which might contain confidential information, is addressed to the above stated person/company. If you are not the correct addressee, employee or in
any other way the person concerned, please notify the sender immediately. At the same time, please delete this e-mail and destroy any prints. Thank You.</span></p>
</div>
</div>
</div>
<div style="font-size:16px; font-family:Times New Roman">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>Från:</b> Jordan Rose [<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>]<br>
<b>Skickat:</b> den 10 mars 2014 17:20<br>
<b>Till:</b> Per Viberg<br>
<b>Cc:</b> cfe-dev Developers; Tom Honermann<br>
<b>Ämne:</b> Re: [cfe-dev] SwitchStmt bug?<br>
</font><br>
</div>
<div>
<div class="h5">
<div></div>
<div><br>
<div>
<div>On Mar 10, 2014, at 7:49 , Tom Honermann <<a href="mailto:thonermann@coverity.com" target="_blank">thonermann@coverity.com</a>> wrote:</div>
<br>
<blockquote type="cite">On 03/10/2014 10:23 AM, Per Viberg wrote:<br>
<blockquote type="cite"><br>
Hi all,<br>
<br>
I was inspecting the AST dump of this switch:<br>
<br>
void test_switch(int t) {<br>
switch(t)<br>
{<br>
case 1:<br>
y = 11;<br>
case 2:<br>
y = 9;<br>
x = 12;<br>
break;<br>
default:<br>
break;<br>
}<br>
}<br>
<br>
and I got something I didn't expect. The second CaseStmt does only<br>
contain the first statement that is under it's label. The "x=12;" gets<br>
its own Stmt outside the CaseStmt but inside the CompoundStmt inside the<br>
SwitchStmt. I would anticipate that all statements under a label either<br>
are: inside the CaseStmt or: outside but inside the CompoundStmt. Any<br>
reason for this?.<br>
</blockquote>
<br>
This is expected. Case statements have just one sub statement.<br>
</blockquote>
</div>
<br>
<div>More generally, case statements are just labels, and have the same basic rules as regular old goto labels. Having case statements "just" be labels is what allows things like <a href="http://en.wikipedia.org/wiki/Duff's_device" target="_blank">Duff's Device</a> in
C:</div>
<div><br>
</div>
<div>switch(count % 8) {<span style="white-space:pre-wrap"> </span><br>
case 0:<span style="white-space:pre-wrap"> </span>do {<span style="white-space:pre-wrap">
</span>*to = *from++;<br>
case 7:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 6:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 5:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 4:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 3:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 2:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
case 1:<span style="white-space:pre-wrap"> </span>*to = *from++;<br>
<span style="white-space:pre-wrap"></span>} while(--n > 0);<br>
}</div>
<div><br>
</div>
<div>This is the opposite situation, really, because here we need cases <i>inside</i> the loop that's inside the switch. But once you're supporting this, the representation as a simple label is just easier to work with.</div>
<div><br>
</div>
<div>Jordan<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>