File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1787,6 +1787,17 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
1787
1787
# check the style here after the pragmas have been processed:
1788
1788
styleCheckDef(c, s)
1789
1789
# compute the type's size and check for illegal recursions:
1790
+ if a[0].kind == nkPragmaExpr:
1791
+ let pragmas = a[0][1]
1792
+ for i in 0 ..< pragmas.len:
1793
+ if pragmas[i].kind == nkExprColonExpr and
1794
+ pragmas[i][0].kind == nkIdent and
1795
+ whichKeyword(pragmas[i][0].ident) == wSize:
1796
+ if s.typ.kind != tyEnum and sfImportc notin s.flags:
1797
+ # EventType* {.size: sizeof(uint32).} = enum
1798
+ # AtomicFlag* {.importc: "atomic_flag", header: "<stdatomic.h>", size: 1.} = object
1799
+ localError(c.config, pragmas[i].info, "size pragma only allowed for enum types and imported types")
1800
+
1790
1801
if a[1].kind == nkEmpty:
1791
1802
var x = a[2]
1792
1803
if x.kind in nkCallKinds and nfSem in x.flags:
You can’t perform that action at this time.
0 commit comments