summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/compiler-core/slang-lexer.cpp9
-rw-r--r--tests/bugs/gh-4667.slang4
2 files changed, 10 insertions, 3 deletions
diff --git a/source/compiler-core/slang-lexer.cpp b/source/compiler-core/slang-lexer.cpp
index 10c5aa1ae..7d84ed938 100644
--- a/source/compiler-core/slang-lexer.cpp
+++ b/source/compiler-core/slang-lexer.cpp
@@ -185,7 +185,7 @@ namespace Slang
c = lexer->m_cursor[pos++];
- if (c == '\\')
+ while (c == '\\')
{
// We might have a backslash-escaped newline.
// Look at the next byte (if any) to see.
@@ -198,18 +198,21 @@ namespace Slang
case '\r': case '\n':
{
// The newline was escaped, so return the code point after *that*
-
int e = lexer->m_cursor[pos++];
if ((d ^ e) == ('\r' ^ '\n'))
c = lexer->m_cursor[pos++];
else
c = e;
- break;
+ continue;
}
default:
break;
}
+
+ // Only continue this while loop in the case where we consumed
+ // some newlines
+ break;
}
// TODO: handle UTF-8 encoding for non-ASCII code points here
diff --git a/tests/bugs/gh-4667.slang b/tests/bugs/gh-4667.slang
new file mode 100644
index 000000000..4b9078387
--- /dev/null
+++ b/tests/bugs/gh-4667.slang
@@ -0,0 +1,4 @@
+//TEST:SIMPLE:
+\
+\
+int x;