Earlier quoted context omitted.
It is allowable only in circumstances where it is a "bona fide occupational qualification reasonably necessary to the normal operation of that particular business or enterprise". A gentlemans club can get away with it. Someone who simply wants to change their gender ratio can't. Discriminating against accountants is legal in all circumstances.
I haven't seen the case law which prohibits hiring for diversity. Could you direct me to some which demonstrates your assertion?
They may be justified in taking diversity into account in the hiring process, but they cannot exclude candidates based solely on sex. In Regents of the University of California v. Bakke, SCOTUS held that candidates can not be excluded exclusively because of race. In Grutter v. Bollinger, they decided that it was legal to take it into account, but only on an individual basis, not to exclude candidates altogether. These both deal with race, but I see no evidence that sex would be treated differently since the same law applies to both.