You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
c_import: a file-scope record with no tag and no typedef renders as 'type struct (unnamed at ...)' and the import fails to parse (winnt.h C_ASSERT(TYPE_ALIGNMENT(...))) #1396
With #1387 fixed (branch fix-1387-cimport-var-extent), with check of the bzip2 release UAT fixture on native Windows 10 x64 finishes c_import of bzlib.h (which includes windows.h) in 1.6 s instead of dying at 29 GB — and then fails to parse its own generated bindings:
error: expected type body
--> <c_import bzlib.h>:765:13
765 | type struct (unnamed at C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\winnt.h:2602:1) { x: c_char = 0, test: _LARGE_INTEGER }
| ^
error: expected declaration (fn, type, enum, let, use, extern)
--> <c_import bzlib.h>:766:22
766 | impl Copy for struct (unnamed at C:\...\winnt.h:2602:1)
winnt.h:2602 is C_ASSERT(TYPE_ALIGNMENT(LARGE_INTEGER) == 8); where TYPE_ALIGNMENT(t) is FIELD_OFFSET(struct { char x; t test; }, test): the unnamed struct is declared inside an expression at file scope, so it is a top-level StructDecl with no tag and no typedef. The later expected expression / expected ']' errors at TOKEN_INTEGRITY_LEVEL_MAX_SIZE look like parser recovery from these.
Repro (darwin, installed v0.15.2.1 and the #1387 branch alike)
// src/an.h
typedef struct { int a; } X; // fine: the typedef names it
struct { int b; } g; // broken: no tag, no typedef
int f(void);
// src/an.w
use c_import("an.h")
fn main: print("ok")
with check src/an.w:
31 | type struct (unnamed at .../src/an.h:2:1) { b: c_int = 0 }
error: expected type body
ci_translate_struct (src/CImport.w) takes with_cimport_decl_name, which is libclang's cursor spelling struct (unnamed at file:line:col) for an anonymous record, and emits it as a type name. An anonymous file-scope record that no typedef names either gets a synthesized With name used consistently by every type that refers to it (g's type), or — when nothing can refer to it, as in the C_ASSERT expression — is not emitted. Never an unparseable declaration.
Blocks release-bzip2-uat / release-libcurl-uat on Windows after #1387.
Activity
Parser: sizeof[*mut T]() / transmute[*const T](x) — a raw pointer typ…
c_import: a record with no tag and no typedef name gets the name of t…
c_import: layouts With cannot spell import opaque — `_`-tagged record…
Parser: sizeof[*mut T]() / transmute[*const T](x) — a raw pointer typ…
c_import: a record with no tag and no typedef name gets the name of t…
c_import: layouts With cannot spell import opaque — `_`-tagged record…
Parser: sizeof[*mut T]() / transmute[*const T](x) — a raw pointer typ…
c_import: a record with no tag and no typedef name gets the name of t…
c_import: layouts With cannot spell import opaque — `_`-tagged record…
Parser: sizeof[*mut T]() / transmute[*const T](x) — a raw pointer typ…
c_import: a record with no tag and no typedef name gets the name of t…
c_import: layouts With cannot spell import opaque — `_`-tagged record…
Parser: sizeof[*mut T]() / transmute[*const T](x) — a raw pointer typ…
c_import: a record with no tag and no typedef name gets the name of t…
c_import: layouts With cannot spell import opaque — `_`-tagged record…
c_import: records with no tag and no typedef name are named by their …
c_import: windows.h type-checks — bodies over opaque records omitted,…
c_import: windows.h type-checks — bodies over opaque records omitted,…
D71 facade rulings: ok lists, valid on failed, callback-scope handles…