File tree 4 files changed +27
-19
lines changed
4 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -72,28 +72,20 @@ literals_cpp2: () = {
72
72
123'456LL;
73
73
// float points
74
74
123'456.0f;
75
- 123'456.f;
76
75
456.0;
77
- 456.;
78
76
1.0e10;
79
77
1.0e+10;
80
78
1.0e-10;
81
79
1.0e-10f;
82
- 1.e-10;
83
- 1.e-10f;
84
80
1e-10;
85
81
1e-10f;
86
82
1e-1'0;
87
83
123'456.0F;
88
- 123'456.F;
89
84
456.0;
90
- 456.;
91
85
1.0E10;
92
86
1.0E+10;
93
87
1.0E-10;
94
88
1.0E-10F;
95
- 1.E-10;
96
- 1.E-10F;
97
89
1E-10;
98
90
1E-10F;
99
91
1E-1'0;
@@ -108,6 +100,15 @@ literals_cpp2: () = {
108
100
// 1e - 10.0;
109
101
// 1e - 10f;
110
102
// 1e - 10.0f;
103
+ // 123'456.f;
104
+ // 123'456.f;
105
+ // 456.;
106
+ // 1.e-10;
107
+ // 1.e-10f;
108
+ // 123'456.F;
109
+ // 456.;
110
+ // 1.E-10;
111
+ // 1.E-10F;
111
112
}
112
113
113
114
main: ()->int = { }
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ void literals_cpp1() {
61
61
62
62
#line 57 "mixed-float-literals.cpp2"
63
63
auto literals_cpp2 () -> void;
64
- #line 113 "mixed-float-literals.cpp2"
64
+ #line 114 "mixed-float-literals.cpp2"
65
65
[[nodiscard]] auto main () -> int;
66
66
67
67
// === Cpp2 definitions ==========================================================
@@ -86,28 +86,20 @@ auto literals_cpp2() -> void{
86
86
123'456LL ;
87
87
// float points
88
88
123'456 .0f ;
89
- 123'456 .f ;
90
89
456.0 ;
91
- 456 .;
92
90
1.0e10 ;
93
91
1.0e+10 ;
94
92
1.0e-10 ;
95
93
1 .0e-10f ;
96
- 1 .e -10 ;
97
- 1 .e -10f ;
98
94
1e-10 ;
99
95
1e-10f ;
100
96
1e-1'0 ;
101
97
123'456 .0F ;
102
- 123'456 .F ;
103
98
456.0 ;
104
- 456 .;
105
99
1.0E10 ;
106
100
1.0E+10 ;
107
101
1.0E-10 ;
108
102
1 .0E-10F ;
109
- 1 .E -10 ;
110
- 1 .E -10F ;
111
103
1E-10 ;
112
104
1E-10F ;
113
105
1E-1'0 ;
@@ -122,6 +114,15 @@ auto literals_cpp2() -> void{
122
114
// 1e - 10.0;
123
115
// 1e - 10f;
124
116
// 1e - 10.0f;
117
+ // 123'456.f;
118
+ // 123'456.f;
119
+ // 456.;
120
+ // 1.e-10;
121
+ // 1.e-10f;
122
+ // 123'456.F;
123
+ // 456.;
124
+ // 1.E-10;
125
+ // 1.E-10F;
125
126
}
126
127
127
128
[[nodiscard]] auto main () -> int{}
Original file line number Diff line number Diff line change @@ -2562,7 +2562,7 @@ class cppfront
2562
2562
}
2563
2563
2564
2564
// Going backwards if we found LeftParen it might be UFCS
2565
- // expr_list is emited to args variable for future use
2565
+ // expr_list is emitted to ' args' for future use
2566
2566
if (i->op ->type () == lexeme::LeftParen) {
2567
2567
2568
2568
assert (i->op );
Original file line number Diff line number Diff line change @@ -1233,7 +1233,7 @@ auto lex_line(
1233
1233
auto j = 1 ;
1234
1234
while (is_separator_or (is_digit,peek (j))) { ++j; }
1235
1235
if (
1236
- peek (j) != ' .'
1236
+ ( peek (j) != ' .' || ! is_digit ( peek (j+ 1 )))
1237
1237
&& peek (j) != ' f'
1238
1238
&& peek (j) != ' F'
1239
1239
&& peek (j) != ' e'
@@ -1259,6 +1259,12 @@ auto lex_line(
1259
1259
// slurps the digits after '.'
1260
1260
if (peek (j) == ' .' ) {
1261
1261
++j;
1262
+ if (!is_digit (peek (j))) {
1263
+ errors.emplace_back (
1264
+ source_position (lineno, i),
1265
+ " a floating point literal must have at least one digit after the decimal point (can be '.0')"
1266
+ );
1267
+ }
1262
1268
while (is_separator_or (is_digit,peek (j))) {
1263
1269
++j;
1264
1270
}
You can’t perform that action at this time.
0 commit comments