[PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

Tim Northover via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 1 14:36:44 PDT 2017


On 26 May 2017 at 11:29, Richard Smith <richard at metafoo.co.uk> wrote:
> If we generally think that distinction is a good thing, then (because this
> is a conforming extension) consistency weakly suggests that it should not be
> controlled by GNU mode. But I don't find that argument decisive; the
> important thing is that we don't enable non-conforming extensions by default
> in non-GNU (and non-MS-compat) modes, not that GNU mode consists of /only/
> non-conforming extensions.

I'm pretty convinced by the conforming/non-conforming distinction and
consistency argument. And think that the Microsoft way seems even
better for the future.

Making the libc++ test pass is pretty ugly, but I've managed to get it
working by building with "-Werror=gnu-imaginary-constant".

Marshall, I know this really isn't your preferred solution but can you
stomach it if I also make sure we do the extra diagnostics so it's
difficult to misuse?

> Looking at the
>
>   std::complex<float> x = 1.0if;
>
> case again, I think there's another problem here: we support an implicit
> conversion from _Complex float to float in C++ (without even a warning).
> This conversion is valid in C, but at least GCC disallows it in its C++
> mode. We should probably at least warn on that.

Definitely. I think the error from G++ is probably the right choice.
I'll get cracking on that, it's a good idea regardless of what happens
here.

Cheers.

Tim.


More information about the cfe-commits mailing list