Yes, it's legal. In general, An if-else-if ladder is not a special case, it's just a bunch of
if else
where the braces after else
are omitted. It's easier to see if you indent the code like this: gcc.godbolt.org/z/hb8jddv9v