Path: utzoo!utgpu!water!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.lang.c Subject: Re: How do you document breakless cases Keywords: break,case,switch Message-ID: <19743@watmath.waterloo.edu> Date: 5 Jul 88 16:53:50 GMT References: <16607@tut.cis.ohio-state.edu> <739@vsi.UUCP> Organization: U of Waterloo, Ontario Lines: 49 In article <739@vsi.UUCP>, sullivan@vsi.UUCP (Michael T Sullivan) writes: > In article <16607@tut.cis.ohio-state.edu>, lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: > > > 1 /* fallthrough */ > > if the last statement before a case isn't one of > > return > > exit > > abort > > etc. > > return is different that exit and abort. Lint knows that return isn't coming > back, wheras exit and abort are just functions. I ran into this the other > day where my switch had all cases and default that returned and one that exited. > Lint complained about the one that exited with a "function has return and > return(e)" type of message. I put a /*NOTREACHED*/ after the exit and lint > was much happier. Our version of lint has both a /*FALLTHROUGH*/ directive for the switch statement, and a /*GOTO*/ directive for external declarations. e.g.should contain: extern /*GOTO*/ exit(); then any program that includes will lint correctly and never need /*NOTREACHED*/. The following lints cleanly: extern /*GOTO*/ exit(); extern /*GOTO*/ abort(); main(argc) { switch (argc) { case -3: case -2: case -1: abort(); case 0: return 0; case 1: ++argc; /*FALLTHROUGH*/ case 2: ++argc; exit(argc); default: return 42; } } If anyone else implements these, it would be nice if they used the same keywords instead of inventing yet another name.