Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not present.
authorTim Northover <tnorthover@apple.com>
Wed, 9 Aug 2017 14:56:48 +0000 (14:56 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 9 Aug 2017 14:56:48 +0000 (14:56 +0000)
commit9710338a5699a48b26807693371d277b1acb3387
treee97f8396124bb954de3a321dbc7ea61e95a5f0ca
parent922ca2345d29f3c6bd089afedbb06b7d88bd4d99
Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not present.

C++14 added user-defined literal support for complex numbers so that you
can write something like "complex<double> val = 2i". However, there is
an existing GNU extension supporting this syntax and interpreting the
result as a _Complex type.

This changes parsing so that such literals are interpreted in terms of
C++14's operators if an overload is present but otherwise falls back to
the original GNU extension.

(We now have more robust diagnostics for implicit conversions so the
libc++ test that caused the original revert still passes).

llvm-svn: 310478
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Lex/LiteralSupport.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaCXX/imaginary-constants.cpp [new file with mode: 0644]