Skip to content
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

Fix Issue 24025 - Expressions contained in parentheses should not be … #15377

Merged
merged 1 commit into from
Jul 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -8823,6 +8823,12 @@ LagainStc:
te.parens = true;
e = parsePostExp(te);
}
else if (token.value == TOK.leftParenthesis)
{
auto te = new AST.TypeExp(loc, t);
te.parens = true;
e = parsePostExp(te);
}
else
{
e = parseUnaryExp();
Expand Down
21 changes: 20 additions & 1 deletion compiler/test/fail_compilation/ccast.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
/*
TEST_OUTPUT:
---
fail_compilation/ccast.d(9): Error: C style cast illegal, use `cast(byte)i`
fail_compilation/ccast.d(11): Error: C style cast illegal, use `cast(byte)i`
fail_compilation/ccast.d(24): Error: C style cast illegal, use `cast(foo)5`
fail_compilation/ccast.d(26): Error: C style cast illegal, use `cast(void*)5`
---
*/

int i;
byte b = (byte)i;

void bar(int x);

void main()
{
(&bar)(5); // ok
auto foo = &bar;
(foo = foo)(5); // ok
(*foo)(5); // ok

(foo)(5); // ok
(bar)(5); // ok
(foo)5;

(void*)5;
(void*)(5); // semantic implicit cast error
}