Well, as I was saying, it is a tricky feature. One will have come up with a smart algorithm. A rough crack at it would be, when trying to match paren on Line 9, and scanning back to find the match, the algorithm would have to keep track, that Line 3 and Line 5 are duplicated ( as far as the closing paren - '{', is considered), as the '{' is in #ifdef / #else / #endif clause. Basically, while scannign back for matching paren, not just look at the char '{', but also take into account it's context (if that '}' is within an #ifdef....). I am sure there are holes in my algorithm above, but with some improvement, and taking use cases into account, one can come up with a decent algorithm.
Regards,
Aha.