c++: Fix parsing of prefixed C++11 raw string literals

See http://en.cppreference.com/w/cpp/language/string_literal
This commit is contained in:
Colomban Wendling 2016-01-24 15:30:00 +01:00
parent cdabbecd37
commit 5a279f0bf6
3 changed files with 30 additions and 1 deletions

View File

@ -802,8 +802,12 @@ process:
* *
* which is perfectly valid (yet probably very unlikely). */ * which is perfectly valid (yet probably very unlikely). */
int prev = fileGetNthPrevC (1, 0); int prev = fileGetNthPrevC (1, 0);
int prev2 = fileGetNthPrevC (2, 0);
int prev3 = fileGetNthPrevC (3, 0);
if (! isident (prev)) if (! isident (prev) ||
(! isident (prev2) && (prev == 'L' || prev == 'u' || prev == 'U')) ||
(! isident (prev3) && (prev2 == 'u' && prev == '8')))
{ {
int next = fileGetc (); int next = fileGetc ();
if (next != DOUBLE_QUOTE) if (next != DOUBLE_QUOTE)

View File

@ -19,3 +19,16 @@ struct typ2 { int memb2; };
static const char* str3 = FOUR"f(iv)e"; static const char* str3 = FOUR"f(iv)e";
struct typ3 { int memb3; }; struct typ3 { int memb3; };
/* check for prefixes */
static const char* str4 = LR"blah(";int bug4;)blah";
struct typ4 { int memb4; };
static const char* str5 = u8R"blah(";int bug5;)blah";
struct typ5 { int memb5; };
static const char* str6 = uR"blah(";int bug6;)blah";
struct typ6 { int memb6; };
static const char* str7 = UR"blah(";int bug7;)blah";
struct typ7 { int memb7; };

View File

@ -3,9 +3,21 @@ FOUR
memb1Ì64Îtyp1Ö0Ïint memb1Ì64Îtyp1Ö0Ïint
memb2Ì64Îtyp2Ö0Ïint memb2Ì64Îtyp2Ö0Ïint
memb3Ì64Îtyp3Ö0Ïint memb3Ì64Îtyp3Ö0Ïint
memb4Ì64Îtyp4Ö0Ïint
memb5Ì64Îtyp5Ö0Ïint
memb6Ì64Îtyp6Ö0Ïint
memb7Ì64Îtyp7Ö0Ïint
str1Ì16384Ö0Ïchar str1Ì16384Ö0Ïchar
str2Ì16384Ö0Ïchar str2Ì16384Ö0Ïchar
str3Ì16384Ö0Ïchar str3Ì16384Ö0Ïchar
str4Ì16384Ö0Ïchar
str5Ì16384Ö0Ïchar
str6Ì16384Ö0Ïchar
str7Ì16384Ö0Ïchar
typ1Ì2048Ö0 typ1Ì2048Ö0
typ2Ì2048Ö0 typ2Ì2048Ö0
typ3Ì2048Ö0 typ3Ì2048Ö0
typ4Ì2048Ö0
typ5Ì2048Ö0
typ6Ì2048Ö0
typ7Ì2048Ö0