<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Ok… I bit.<div class=""><br class=""></div><div class="">Alex’s proposal here is really compelling to me because it means that the required changes to make this work would be more limited. Specifically a clang attribute could give us all the benefits of #ifdefs throughout the code without the maintenance burden. So, being the silly person I am, I wrote the patches for clang.</div><div class=""><br class=""></div><div class="">I’ve never done any frontend hacking before, so take these with giant cellars of salt, but the concept seems sound to me.</div><div class=""><br class=""></div><div class="">The patches do the following:</div><div class="">(1) Add a new C++11-style [[impossible_enum]] attribute</div><div class="">(2) Any case statement that has [[impossible_enum]] applied to it is not emitted during IRGen - the bodies are always emitted so as not to interfere with fall through, but blocks that cannot be entered are optimized away</div><div class="">(3) Equality comparison against [[impossible_enum]] values are always false, all other comparisons are always true</div><div class=""><br class=""></div><div class="">There was some discussion on IRC today whether or not this was the right way to do this, but I thought I’d send these patches out anyways so people can take a look.</div><div class=""><br class=""></div><div class="">The attached diffs are for clang, I’ve also attached a c++ test file.</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""></div></body></html>