User-defined literals: reject string and character UDLs in all places where the
grammar requires a string-literal and not a user-defined-string-literal. The
two constructs are still represented by the same TokenKind, in order to prevent
a combinatorial explosion of different kinds of token. A flag on Token tracks
whether a ud-suffix is present, in order to prevent clients from needing to look
at the token's spelling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152098 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index d866307..c735c6f 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -1905,8 +1905,13 @@
if (getLang().CPlusPlus0x && Tok.is(tok::string_literal)) {
Diag(Tok.getLocation(), diag::warn_cxx98_compat_literal_operator);
+ // FIXME: Add a FixIt to insert a space before the suffix, and recover.
+ if (Tok.hasUDSuffix()) {
+ Diag(Tok.getLocation(), diag::err_literal_operator_missing_space);
+ return true;
+ }
if (Tok.getLength() != 2)
- Diag(Tok.getLocation(), diag::err_operator_string_not_empty);
+ Diag(Tok.getLocation(), diag::err_literal_operator_string_not_empty);
ConsumeStringToken();
if (Tok.isNot(tok::identifier)) {