Skip to content

Add hint for Cpp1 prefix operators #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions regression-tests/pure2-cpp1-prefix-expression.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main: () =
{
v := 1;
p := &v;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pure2-cpp1-prefix-expression.cpp2...
pure2-cpp1-prefix-expression.cpp2(4,10): error: use postfix 'var&' for address, not '&var'

14 changes: 14 additions & 0 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3793,6 +3793,20 @@ class parser
if ((n->expr = postfix_expression())) {
return n;
}
switch (curr().type())
{
break; case lexeme::PlusPlus:
error("only postfix 'var++' increment is supported, not '++var'", false);
break; case lexeme::MinusMinus:
error("only postfix 'var--' decrement is supported, not '--var'", false);
break; case lexeme::Multiply:
error("use postfix 'ptr*' to dereference, not '*ptr'", false);
break; case lexeme::Ampersand:
error("use postfix 'var&' for address, not '&var'", false);
break; case lexeme::Tilde:
error("use postfix 'var~' for bitwise complement, not '~var'", false);
break; default: ;
}
return {};
}

Expand Down