This is a slightly-modified version of Ed's patch from https://gcc.gnu.org/ml/gcc-patches/2015-01/msg02357.html which I plan to commit to CVS tomorrow.