Skip to content

Commit fb820eb

Browse files
committed
Fix brace matching in the presence of digit separators, closes #862
If the `'` is preceded by a digit then it is a digit separator, not the start of a character literal
1 parent 394a77a commit fb820eb

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.3.0 Build 8C13:1356
2+
cppfront compiler v0.3.0 Build 8C13:1859
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8C13:1356"
1+
"8C13:1859"

source/io.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,10 @@ auto process_cpp2_line(
782782
if (prev != '\\' || prev2 == '\\') { in_string_literal = true; }
783783

784784
break;case '\'':
785-
if (prev != '\\' || prev2 == '\\') { in_char_literal = true; }
785+
if (prev != '\\' || prev2 == '\\') {
786+
// Also check that this isn't a digit separator
787+
in_char_literal = !is_hexadecimal_digit(prev);
788+
}
786789

787790
break;default: ;
788791
}

0 commit comments

Comments
 (0)