diff options
author | Tim Northover <tnorthover@apple.com> | 2017-05-24 22:18:35 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2017-05-24 22:18:35 +0000 |
commit | 03e95d2ffb90719219513cabb351bbd88b2ee6d2 (patch) | |
tree | 20efe05d4c5055c4bacab8ad74a8d78fcf5f1e8b /lib/Lex | |
parent | 5497518e683abb8dab29749cd5b78e1355da0aee (diff) |
Revert "Sema: allow imaginary constants via GNU extension if UDL overloads not present."
This reverts commit r303697. It broke libc++ tests that were specifically
checking incompatibility in C++14 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 1fead55e80..1e2cbde825 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -651,6 +651,9 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, break; } } + // "i", "if", and "il" are user-defined suffixes in C++1y. + if (*s == 'i' && PP.getLangOpts().CPlusPlus14) + break; // fall through. case 'j': case 'J': @@ -662,34 +665,35 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, break; } - // "i", "if", and "il" are user-defined suffixes in C++1y. - if (s != ThisTokEnd || isImaginary) { + if (s != ThisTokEnd) { // FIXME: Don't bother expanding UCNs if !tok.hasUCN(). expandUCNs(UDSuffixBuf, StringRef(SuffixBegin, ThisTokEnd - SuffixBegin)); if (isValidUDSuffix(PP.getLangOpts(), UDSuffixBuf)) { - if (!isImaginary) { - // Any suffix pieces we might have parsed are actually part of the - // ud-suffix. - isLong = false; - isUnsigned = false; - isLongLong = false; - isFloat = false; - isHalf = false; - isImaginary = false; - MicrosoftInteger = 0; - } + // Any suffix pieces we might have parsed are actually part of the + // ud-suffix. + isLong = false; + isUnsigned = false; + isLongLong = false; + isFloat = false; + isHalf = false; + isImaginary = false; + MicrosoftInteger = 0; saw_ud_suffix = true; return; } - if (s != ThisTokEnd) { - // Report an error if there are any. - PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin), - diag::err_invalid_suffix_constant) - << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin) << isFPConstant; - hadError = true; - } + // Report an error if there are any. + PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin), + diag::err_invalid_suffix_constant) + << StringRef(SuffixBegin, ThisTokEnd-SuffixBegin) << isFPConstant; + hadError = true; + return; + } + + if (isImaginary) { + PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin), + diag::ext_imaginary_constant); } } |