Bug 23018 – importC: syntax error for sizeof with postfix operator on parenthesized expression

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-15T19:39:33Z
Last change time
2022-05-17T20:11:11Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
duser

Comments

Comment #0 by duser — 2022-04-15T19:39:33Z
int xs[1]; struct { int x; } s, *sp; int fn(void); int i; _Static_assert( sizeof (xs)[0] == sizeof(int), "" ); _Static_assert( sizeof (sp)->x == sizeof(int), "" ); _Static_assert( sizeof (s).x == sizeof(int), "" ); _Static_assert( sizeof (fn)() == sizeof(int), "" ); _Static_assert( sizeof (i)++ == sizeof(int), "" ); all give a syntax error they should be parsed the same as "sizeof( (xs)[0] )" and so on (topmost level of parens omitted)
Comment #1 by dlang-bot — 2022-05-10T01:39:58Z
@maxhaton created dlang/dmd pull request #14099 "Fix Issue 23018 - sizeof unary-expression was not parsed correctly" fixing this issue: - Fix Issue 23018 - sizeof unary-expression was not parsed correctly This is fixed by improving the logic for guessing if a token is part of a type or not. Previously it did not use the typedef-table (boo!) the parser maintains, now it does. https://github.com/dlang/dmd/pull/14099
Comment #2 by dlang-bot — 2022-05-17T20:11:11Z
dlang/dmd pull request #14099 "Fix Issue 23018 - sizeof unary-expression was not parsed correctly" was merged into master: - edac40073550ced6d81cbb76bd1b99b538b55bbf by mhh: Fix Issue 23018 - sizeof unary-expression was not parsed correctly This is fixed by improving the logic for guessing if a token is part of a type or not. Previously it did not use the typedef-table (boo!) the parser maintains, now it does. https://github.com/dlang/dmd/pull/14099