Skip to content

Commit 559ba2a

Browse files
committed
Add hint for Cpp1 new expression
1 parent 768f125 commit 559ba2a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
main: () =
2+
{
3+
v := new int;
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pure2-new-expression-error.cpp2...
2+
pure2-new-expression-error.cpp2(3,14): error: use 'new<T>', not 'new T' (at 'int')
3+

source/parse.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,6 +4092,14 @@ class parser
40924092
generated_tokens->emplace_back( ">>=", t.position(), lexeme::RightShiftEq);
40934093
return &generated_tokens->back();
40944094
}
4095+
if (
4096+
peek(-1)->type() == lexeme::Identifier
4097+
&& peek(-1)->as_string_view() == "new"
4098+
&& next.type() != lexeme::Less
4099+
)
4100+
{
4101+
error("use 'new<T>', not 'new T'");
4102+
}
40954103
return nullptr;
40964104
},
40974105
[=,this]{ return logical_or_expression(allow_angle_operators); }

0 commit comments

Comments
 (0)