Skip to content

Commit 4f09ac7

Browse files
committed
Fix off-by-one issue found by post-commit review
1 parent 9b46838 commit 4f09ac7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Lex/Lexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,6 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr,
22622262
unsigned PrefixLen = 0;
22632263

22642264
while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) {
2265-
++PrefixLen;
22662265
if (!isLexingRawMode() &&
22672266
llvm::is_contained({'$', '@', '`'}, CurPtr[PrefixLen])) {
22682267
const char *Pos = &CurPtr[PrefixLen];
@@ -2271,6 +2270,7 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr,
22712270
: diag::ext_cxx26_raw_string_literal_character_set)
22722271
<< StringRef(Pos, 1);
22732272
}
2273+
++PrefixLen;
22742274
}
22752275

22762276
// If the last character was not a '(', then we didn't lex a valid delimiter.

clang/test/Lexer/cxx2c-raw-strings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ int main() {
2121
(void) R"\()\";
2222
// expected-error@-1 {{invalid character '\' in raw string delimiter}}
2323
// expected-error@-2 {{expected expression}}
24+
25+
(void) R"@(foo)@";
26+
// cxx26-warning@-1 {{'@' in a raw string literal delimiter is incompatible with standards before C++2c}}
27+
// precxx26-warning@-2 {{'@' in a raw string literal delimiter is a C++2c extension}}
2428
}

0 commit comments

Comments
 (0)