<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello Clang Community,<div class=""><br class=""></div><div class="">Why is the first statement after a “case” label the child of the case label, but every other statement (including the break) after that its sibling? It seems like either all should be children or all should be siblings.</div><div class=""><br class=""></div><div class="">Suppose you have the following code snippet (f<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">ull source files for any snippets below are included with this mail).</span></div><div class=""><br class=""></div><div class="">switch(expr) {<br class=""> case 1:<br class=""> func1();<br class=""> func2();<br class=""> break;<br class=""> case 2:<br class=""> func1();<br class=""> break;</div><div class="">}<br class=""><br class=""></div><div class="">Which when fed to clang with </div><div class=""><br class=""></div><div class="">$ clang -Xclang -ast-dump -fsyntax-only test.c</div><div class=""><br class=""></div><div class="">produces the following AST (edited for clarity):</div><div class=""><br class=""></div><div class="">| SwitchStmt <line:7:3, line:15:3><br class=""> | `-CompoundStmt <col:15, line:15:3><br class=""> | |-CaseStmt <line:8:3, line:9:11><br class=""> | | `-CallExpr <line:9:5, col:11> —————————— func1() here is child to case 1<br class=""> | |-CallExpr <line:10:5, col:11> —————————— func2() here is sibling to case 1<br class=""> | |-BreakStmt <line:11:5><br class=""> | |-CaseStmt <line:12:3, line:13:11><br class=""> | | `-CallExpr <line:13:5, col:11> ————————— func1() here again is child to case 2<br class=""> | `-BreakStmt <line:14:5></div><div class=""><br class=""></div><div class="">My clang version and install info:</div><div class=""><br class=""></div><div class="">Apple clang version 12.0.5 (clang-1205.0.22.9)<br class="">Target: x86_64-apple-darwin20.4.0<br class="">Thread model: posix<br class="">InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin</div><div class=""><br class=""></div><div class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class=""></div></div></div>
</div>
</div></body></html>