Handle TreatWarningsAsErrors a bit better

This fixes a bug I introduced where some warnings were still getting reported as warnings, even when treatWarningsAsErrors was on.