Bug 22030 – importC: Wrong error with bad declarator

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-16T16:53:02Z
Last change time
2021-06-17T00:19:05Z
Keywords
accepts-invalid, diagnostic, ImportC, pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2021-06-16T16:53:02Z
For example: --- int ); --- GCC errors with: --- error: expected identifier or ‘(’ before ‘)’ token --- But DMD errors with: --- Error: `=`, `;` or `,` expected --- There is the following line in cparse.d --- error("identifier or `(` expected"); // ) --- which is hit with code such as `int * )`, this seems to suggest that cparseDeclarator has an incomplete implementation.
Comment #1 by ibuclaw — 2021-06-16T17:04:26Z
A further example: --- int , int; --- When compiled with GCC: --- test.c:1: error: expected identifier or ‘(’ before ‘,’ token --- However DMD compiles with no errors. So DMD is not respecting the grammar in C11 6.7 (and in particular 6.7.6), which says that `int;` is valid (declaration-specifier without an init-declarator-list), but `int,` is not. declaration: declaration-specifiers init-declarator-list(opt); init-declarator-list: init-declarator init-declarator-list , init-declarator init-declarator: declarator declarator = initializer declarator: pointer(opt) direct-declarator direct-declarator: identifier attribute-specifier-sequence(opt) ( declarator ) array-declarator attribute-specifier-sequence(opt) function-declarator attribute-specifier-sequence(opt)
Comment #2 by dlang-bot — 2021-06-16T19:04:18Z
@ibuclaw created dlang/dmd pull request #12691 "fix Issue 22030 - importC: Wrong error with bad declarator" fixing this issue: - fix Issue 22030 - importC: Wrong error with bad declarator https://github.com/dlang/dmd/pull/12691
Comment #3 by dlang-bot — 2021-06-17T00:19:05Z
dlang/dmd pull request #12691 "fix Issue 22030 - importC: Wrong error with bad declarator" was merged into master: - 8605dce0a2d21e5b4358925a8d2786d249a2486a by Iain Buclaw: fix Issue 22030 - importC: Wrong error with bad declarator https://github.com/dlang/dmd/pull/12691