To summarise the comments for anyone coming this way in the future:
This is clearly a compiler bug in Visual Studio 2012 and 2013. The error message given by Visual Studio is clearly bogus, and other compilers work as expected.
The simplest workaround for me is to just put braces around the whole do-while loop like so:
int main(int argc, char* argv[])
{
int xs[1];
for (auto x : xs)
{
do
;
while (0);
}
return 0;
}
Thanks to everyone for your help.