diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index c7543a48c0b50e..e59c7805b38623 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -2262,7 +2262,6 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, unsigned PrefixLen = 0; while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) { - ++PrefixLen; if (!isLexingRawMode() && llvm::is_contained({'$', '@', '`'}, CurPtr[PrefixLen])) { const char *Pos = &CurPtr[PrefixLen]; @@ -2271,6 +2270,7 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, : diag::ext_cxx26_raw_string_literal_character_set) << StringRef(Pos, 1); } + ++PrefixLen; } // If the last character was not a '(', then we didn't lex a valid delimiter. diff --git a/clang/test/Lexer/cxx2c-raw-strings.cpp b/clang/test/Lexer/cxx2c-raw-strings.cpp index a1e971434e2447..cf114e57d8bb11 100644 --- a/clang/test/Lexer/cxx2c-raw-strings.cpp +++ b/clang/test/Lexer/cxx2c-raw-strings.cpp @@ -21,4 +21,8 @@ int main() { (void) R"\()\"; // expected-error@-1 {{invalid character '\' in raw string delimiter}} // expected-error@-2 {{expected expression}} + + (void) R"@(foo)@"; + // cxx26-warning@-1 {{'@' in a raw string literal delimiter is incompatible with standards before C++2c}} + // precxx26-warning@-2 {{'@' in a raw string literal delimiter is a C++2c extension}} }