[fpc-devel] [Patch/RFC] Warnings for (in/over)complete case statements

Florian Klämpfl florian at freepascal.org
Wed Jan 2 11:30:50 CET 2019


Am 01.01.2019 um 22:10 schrieb Martok:

> 
> * Building the compiler itself cycles with -Sew, so it bails on the first
> occurrence of one of these issues - turns out they're all over the place.
> However... I think the warnings are correct and expose imperfect code here.
> Take this example (one of the first encountered):
> <https://github.com/graemeg/freepascal/blob/master/compiler/defutil.pas#L1630>
> stringtype is an enum and all values are used. There cannot be any other values
> (as we have established last year). Therefore, the else clause is just as wrong
> as an "if false then", which would be caught already.
> 
> * Adding to the previous, since it is now possible to discover forgotten items
> or later additions by the other warning, removing these 'safety' else-clauses
> would improve code quality.

The compiler is for speed reasons not compiled with $R+/$O+, so the safety else clause have its purpose, but they should
throw an internal error instead. Further, the advantage of an IE instead of a normal RTE is, that the IEs are pretty
unique so the source location of an IE can be identified very quickly, as the release compiler is not compiled with -gl.



More information about the fpc-devel mailing list