Skip to content

Error while lexing identifier if it contains an escaped newline followed by a Unicode character #65156

Closed
@mattmanj17

Description

@mattmanj17

Minimal test case

int main(void) {
    int a\
ス = 42;
    return aス;
}

Godbolt example of failed compilation in clang 16
https://godbolt.org/z/TsMrbKqT6

Godbolt example of successful compilation with GCC 13.2
https://godbolt.org/z/hrzqcPKnn

Based on some debugging, I think we are looking at the '\\' in tryConsumeIdentifierUTF8Char, downstream of LexIdentifierContinue.
Perhaps that function needs to take a Size argument like tryConsumeIdentifierUCN does, so that it can correctly decode the Unicode char after the escaped newline.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions