The short ansewer is that the Arduino IDE preprocessor is buggy, and it will often break completely valid code by preprocessing it into completely uncompilable garbage.
One trick is to put the code that confuses it into an include file; the Arduino IDE preprocessor won't touch anything in an included file.
The other is to put a dummy executable statement before the code that confuses it, as in the example above; that sometimes stops it messing things up after that point. But it is not as robust as the include file method.
You can see the exact error it has caused by looking at the munged .cpp output file in the temporary build directory. Sometimes the results are quite comical! I've seen attempts at extracting a prototype header that look like
else if (condition) {
Yes, it can get that confused... as I say, you have to see some of the stuff it produces to believe it.
The best trick is to simply avoid the Arduino IDE preprocessor altogether. That's what I do, anyway. I use emacs as editor, in combination with Martin Oldfield's makefiles for Arduino builds. And it means that you get normal C/C++ preprocessing working properly and predictably again, which is a significant bonus.