@zigc/lib 0.16.0-test.1 → 0.17.0-dev.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/LICENSE +19 -0
  2. package/c/fcntl.zig +6 -1
  3. package/c/inttypes.zig +0 -10
  4. package/c/math.zig +138 -114
  5. package/c/pthread.zig +57 -0
  6. package/c/search.zig +1 -27
  7. package/c/stdlib/drand48.zig +0 -57
  8. package/c/stdlib.zig +0 -100
  9. package/c/string.zig +20 -7
  10. package/c/strings.zig +0 -38
  11. package/c/stropts.zig +17 -0
  12. package/c/unistd.zig +27 -26
  13. package/c/wchar.zig +10 -0
  14. package/c.zig +3 -2
  15. package/compiler/aro/aro/Attribute/names.zig +604 -589
  16. package/compiler/aro/aro/Attribute.zig +202 -116
  17. package/compiler/aro/aro/Builtins/common.zig +874 -863
  18. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  19. package/compiler/aro/aro/Builtins.zig +0 -1
  20. package/compiler/aro/aro/CodeGen.zig +8 -7
  21. package/compiler/aro/aro/Compilation.zig +137 -111
  22. package/compiler/aro/aro/Diagnostics.zig +21 -17
  23. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  24. package/compiler/aro/aro/Driver.zig +138 -63
  25. package/compiler/aro/aro/LangOpts.zig +12 -2
  26. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  27. package/compiler/aro/aro/Parser.zig +352 -153
  28. package/compiler/aro/aro/Pragma.zig +3 -2
  29. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  30. package/compiler/aro/aro/Preprocessor.zig +136 -62
  31. package/compiler/aro/aro/Target.zig +17 -12
  32. package/compiler/aro/aro/Tokenizer.zig +31 -14
  33. package/compiler/aro/aro/Toolchain.zig +4 -7
  34. package/compiler/aro/aro/Tree.zig +178 -148
  35. package/compiler/aro/aro/TypeStore.zig +82 -24
  36. package/compiler/aro/aro/Value.zig +13 -17
  37. package/compiler/aro/aro/features.zig +1 -0
  38. package/compiler/aro/aro/pragmas/message.zig +3 -2
  39. package/compiler/aro/aro/pragmas/once.zig +0 -1
  40. package/compiler/aro/aro/record_layout.zig +3 -3
  41. package/compiler/aro/aro/text_literal.zig +3 -2
  42. package/compiler/aro/assembly_backend/x86_64.zig +7 -8
  43. package/compiler/aro/backend/Assembly.zig +1 -2
  44. package/compiler/aro/backend/Interner.zig +2 -2
  45. package/compiler/aro/backend/Ir.zig +100 -92
  46. package/compiler/aro/include/ptrcheck.h +49 -0
  47. package/compiler/aro/main.zig +26 -10
  48. package/compiler/build_runner.zig +1 -2
  49. package/compiler/objdump.zig +93 -0
  50. package/compiler/reduce/Walk.zig +7 -7
  51. package/compiler/reduce.zig +5 -1
  52. package/compiler/resinator/compile.zig +2 -2
  53. package/compiler/resinator/main.zig +7 -1
  54. package/compiler/resinator/preprocess.zig +1 -3
  55. package/compiler/std-docs.zig +8 -1
  56. package/compiler/test_runner.zig +194 -62
  57. package/compiler/translate-c/MacroTranslator.zig +80 -11
  58. package/compiler/translate-c/PatternList.zig +1 -9
  59. package/compiler/translate-c/Scope.zig +43 -6
  60. package/compiler/translate-c/Translator.zig +369 -127
  61. package/compiler/translate-c/ast.zig +19 -11
  62. package/compiler/translate-c/main.zig +76 -17
  63. package/compiler_rt/cos.zig +140 -53
  64. package/compiler_rt/divmodei4.zig +40 -17
  65. package/compiler_rt/exp.zig +1 -6
  66. package/compiler_rt/exp2.zig +1 -6
  67. package/compiler_rt/exp_f128.zig +377 -0
  68. package/compiler_rt/fabs.zig +0 -2
  69. package/compiler_rt/fma.zig +0 -2
  70. package/compiler_rt/fmax.zig +0 -2
  71. package/compiler_rt/fmin.zig +0 -2
  72. package/compiler_rt/fmod.zig +0 -2
  73. package/compiler_rt/limb64.zig +1127 -0
  74. package/compiler_rt/log.zig +0 -2
  75. package/compiler_rt/log10.zig +0 -2
  76. package/compiler_rt/log2.zig +0 -2
  77. package/compiler_rt/long_double.zig +37 -0
  78. package/compiler_rt/mulXi3.zig +1 -1
  79. package/compiler_rt/mulo.zig +6 -1
  80. package/compiler_rt/rem_pio2l.zig +173 -0
  81. package/compiler_rt/round.zig +0 -2
  82. package/compiler_rt/sin.zig +139 -56
  83. package/compiler_rt/sincos.zig +277 -72
  84. package/compiler_rt/sqrt.zig +0 -2
  85. package/compiler_rt/ssp.zig +1 -1
  86. package/compiler_rt/tan.zig +117 -48
  87. package/compiler_rt/trig.zig +256 -6
  88. package/compiler_rt/trunc.zig +0 -2
  89. package/compiler_rt/udivmodei4.zig +28 -0
  90. package/compiler_rt.zig +2 -0
  91. package/fuzzer.zig +857 -307
  92. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  93. package/libc/musl/src/math/pow.c +343 -0
  94. package/package.json +1 -1
  95. package/std/Build/Cache.zig +6 -6
  96. package/std/Build/Fuzz.zig +6 -19
  97. package/std/Build/Module.zig +1 -1
  98. package/std/Build/Step/CheckObject.zig +3 -3
  99. package/std/Build/Step/Compile.zig +18 -1
  100. package/std/Build/Step/ConfigHeader.zig +49 -33
  101. package/std/Build/Step/InstallArtifact.zig +18 -0
  102. package/std/Build/Step/Run.zig +538 -89
  103. package/std/Build/Step/TranslateC.zig +0 -6
  104. package/std/Build/Step.zig +10 -19
  105. package/std/Build/WebServer.zig +31 -19
  106. package/std/Build/abi.zig +47 -11
  107. package/std/Build.zig +17 -17
  108. package/std/Io/Dir.zig +7 -2
  109. package/std/Io/Dispatch.zig +5 -13
  110. package/std/Io/File/Reader.zig +3 -1
  111. package/std/Io/File/Writer.zig +8 -6
  112. package/std/Io/File.zig +1 -0
  113. package/std/Io/Kqueue.zig +2 -2
  114. package/std/Io/Reader.zig +8 -9
  115. package/std/Io/Semaphore.zig +112 -17
  116. package/std/Io/Terminal.zig +1 -1
  117. package/std/Io/Threaded.zig +352 -180
  118. package/std/Io/Uring.zig +15 -16
  119. package/std/Io/Writer.zig +46 -42
  120. package/std/Io/net.zig +11 -11
  121. package/std/Io.zig +1052 -20
  122. package/std/SemanticVersion.zig +1 -1
  123. package/std/Target/Query.zig +2 -2
  124. package/std/Target.zig +53 -7
  125. package/std/Thread.zig +8 -3
  126. package/std/array_hash_map.zig +105 -573
  127. package/std/array_list.zig +22 -31
  128. package/std/bit_set.zig +22 -6
  129. package/std/builtin/assembly.zig +68 -0
  130. package/std/builtin.zig +4 -0
  131. package/std/c/haiku.zig +3 -0
  132. package/std/c/serenity.zig +1 -6
  133. package/std/c.zig +106 -24
  134. package/std/compress/flate/Compress.zig +3 -3
  135. package/std/compress/flate/Decompress.zig +2 -3
  136. package/std/compress/zstd/Decompress.zig +2 -4
  137. package/std/crypto/Certificate/Bundle.zig +15 -1
  138. package/std/crypto/Certificate.zig +13 -1
  139. package/std/crypto/ascon.zig +75 -33
  140. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  141. package/std/crypto/codecs/asn1.zig +33 -18
  142. package/std/crypto/codecs/base64_hex_ct.zig +16 -8
  143. package/std/crypto/ml_kem.zig +2 -9
  144. package/std/crypto/tls/Client.zig +79 -4
  145. package/std/crypto/tls.zig +1 -1
  146. package/std/crypto.zig +1 -0
  147. package/std/debug/Dwarf.zig +29 -9
  148. package/std/debug/Info.zig +4 -0
  149. package/std/debug/MachOFile.zig +46 -8
  150. package/std/debug/Pdb.zig +540 -37
  151. package/std/debug/SelfInfo/Elf.zig +19 -18
  152. package/std/debug/SelfInfo/MachO.zig +18 -7
  153. package/std/debug/SelfInfo/Windows.zig +138 -36
  154. package/std/debug.zig +181 -66
  155. package/std/enums.zig +25 -19
  156. package/std/fmt.zig +8 -3
  157. package/std/fs/path.zig +6 -4
  158. package/std/heap/ArenaAllocator.zig +145 -154
  159. package/std/heap/BufferFirstAllocator.zig +165 -0
  160. package/std/heap/debug_allocator.zig +7 -7
  161. package/std/heap.zig +2 -126
  162. package/std/http/Client.zig +31 -30
  163. package/std/http.zig +14 -13
  164. package/std/json/Scanner.zig +2 -2
  165. package/std/json/Stringify.zig +3 -3
  166. package/std/json/dynamic.zig +4 -4
  167. package/std/math/big/int.zig +16 -17
  168. package/std/mem/Allocator.zig +4 -5
  169. package/std/mem.zig +48 -0
  170. package/std/os/emscripten.zig +2 -18
  171. package/std/os/linux/IoUring.zig +2 -0
  172. package/std/os/linux/aarch64.zig +41 -12
  173. package/std/os/linux/arc.zig +173 -0
  174. package/std/os/linux/arm.zig +41 -12
  175. package/std/os/linux/hexagon.zig +33 -11
  176. package/std/os/linux/loongarch32.zig +41 -13
  177. package/std/os/linux/loongarch64.zig +41 -12
  178. package/std/os/linux/m68k.zig +41 -13
  179. package/std/os/linux/mips.zig +67 -36
  180. package/std/os/linux/mips64.zig +60 -29
  181. package/std/os/linux/mipsn32.zig +60 -29
  182. package/std/os/linux/or1k.zig +41 -12
  183. package/std/os/linux/powerpc.zig +41 -12
  184. package/std/os/linux/powerpc64.zig +41 -12
  185. package/std/os/linux/riscv32.zig +41 -12
  186. package/std/os/linux/riscv64.zig +41 -12
  187. package/std/os/linux/s390x.zig +44 -7
  188. package/std/os/linux/sparc64.zig +83 -52
  189. package/std/os/linux/thumb.zig +52 -36
  190. package/std/os/linux/x32.zig +41 -12
  191. package/std/os/linux/x86.zig +42 -13
  192. package/std/os/linux/x86_64.zig +41 -12
  193. package/std/os/linux.zig +419 -438
  194. package/std/os/uefi/tables/boot_services.zig +9 -8
  195. package/std/os/windows.zig +2 -2
  196. package/std/os.zig +41 -0
  197. package/std/pdb.zig +143 -4
  198. package/std/posix.zig +6 -12
  199. package/std/priority_dequeue.zig +13 -12
  200. package/std/priority_queue.zig +5 -4
  201. package/std/process/Child.zig +1 -1
  202. package/std/process/Environ.zig +1 -1
  203. package/std/process.zig +1 -1
  204. package/std/sort.zig +3 -3
  205. package/std/start.zig +17 -4
  206. package/std/std.zig +19 -6
  207. package/std/testing/FailingAllocator.zig +4 -4
  208. package/std/testing/Smith.zig +37 -2
  209. package/std/zig/Ast/Render.zig +187 -459
  210. package/std/zig/Ast.zig +0 -4
  211. package/std/zig/AstGen.zig +86 -103
  212. package/std/zig/AstRlAnnotate.zig +0 -11
  213. package/std/zig/AstSmith.zig +2602 -0
  214. package/std/zig/BuiltinFn.zig +0 -32
  215. package/std/zig/Client.zig +8 -3
  216. package/std/zig/LibCInstallation.zig +4 -3
  217. package/std/zig/Parse.zig +90 -81
  218. package/std/zig/Server.zig +26 -0
  219. package/std/zig/WindowsSdk.zig +13 -13
  220. package/std/zig/Zir.zig +66 -62
  221. package/std/zig/ZonGen.zig +6 -5
  222. package/std/zig/c_translation/helpers.zig +14 -9
  223. package/std/zig/llvm/Builder.zig +119 -60
  224. package/std/zig/system.zig +20 -4
  225. package/std/zig/tokenizer.zig +2 -1
  226. package/std/zig.zig +7 -10
  227. package/std/zip.zig +5 -5
  228. package/zig.h +340 -1
  229. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  230. package/libc/mingw/complex/cabs.c +0 -48
  231. package/libc/mingw/complex/cabsf.c +0 -48
  232. package/libc/mingw/complex/cacos.c +0 -50
  233. package/libc/mingw/complex/cacosf.c +0 -50
  234. package/libc/mingw/complex/carg.c +0 -48
  235. package/libc/mingw/complex/cargf.c +0 -48
  236. package/libc/mingw/complex/casin.c +0 -50
  237. package/libc/mingw/complex/casinf.c +0 -50
  238. package/libc/mingw/complex/catan.c +0 -50
  239. package/libc/mingw/complex/catanf.c +0 -50
  240. package/libc/mingw/complex/ccos.c +0 -50
  241. package/libc/mingw/complex/ccosf.c +0 -50
  242. package/libc/mingw/complex/cexp.c +0 -48
  243. package/libc/mingw/complex/cexpf.c +0 -48
  244. package/libc/mingw/complex/cimag.c +0 -48
  245. package/libc/mingw/complex/cimagf.c +0 -48
  246. package/libc/mingw/complex/clog.c +0 -48
  247. package/libc/mingw/complex/clog10.c +0 -49
  248. package/libc/mingw/complex/clog10f.c +0 -49
  249. package/libc/mingw/complex/clogf.c +0 -48
  250. package/libc/mingw/complex/conj.c +0 -48
  251. package/libc/mingw/complex/conjf.c +0 -48
  252. package/libc/mingw/complex/cpow.c +0 -48
  253. package/libc/mingw/complex/cpowf.c +0 -48
  254. package/libc/mingw/complex/cproj.c +0 -48
  255. package/libc/mingw/complex/cprojf.c +0 -48
  256. package/libc/mingw/complex/creal.c +0 -48
  257. package/libc/mingw/complex/crealf.c +0 -48
  258. package/libc/mingw/complex/csin.c +0 -50
  259. package/libc/mingw/complex/csinf.c +0 -50
  260. package/libc/mingw/complex/csqrt.c +0 -48
  261. package/libc/mingw/complex/csqrtf.c +0 -48
  262. package/libc/mingw/complex/ctan.c +0 -50
  263. package/libc/mingw/complex/ctanf.c +0 -50
  264. package/libc/mingw/math/arm/s_rint.c +0 -86
  265. package/libc/mingw/math/arm/s_rintf.c +0 -51
  266. package/libc/mingw/math/arm/sincos.S +0 -30
  267. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  268. package/libc/mingw/math/arm64/rint.c +0 -12
  269. package/libc/mingw/math/arm64/rintf.c +0 -12
  270. package/libc/mingw/math/arm64/sincos.S +0 -32
  271. package/libc/mingw/math/bsd_private_base.h +0 -148
  272. package/libc/mingw/math/fdiml.c +0 -24
  273. package/libc/mingw/math/frexpf.c +0 -13
  274. package/libc/mingw/math/frexpl.c +0 -71
  275. package/libc/mingw/math/x86/acosf.c +0 -29
  276. package/libc/mingw/math/x86/atanf.c +0 -23
  277. package/libc/mingw/math/x86/atanl.c +0 -18
  278. package/libc/mingw/math/x86/cos.def.h +0 -65
  279. package/libc/mingw/math/x86/cosl.c +0 -46
  280. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  281. package/libc/mingw/math/x86/ldexp.c +0 -23
  282. package/libc/mingw/math/x86/scalbn.S +0 -41
  283. package/libc/mingw/math/x86/scalbnf.S +0 -40
  284. package/libc/mingw/math/x86/sin.def.h +0 -65
  285. package/libc/mingw/math/x86/sinl.c +0 -46
  286. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  287. package/libc/mingw/math/x86/tanl.S +0 -62
  288. package/libc/mingw/misc/btowc.c +0 -28
  289. package/libc/mingw/misc/wcstof.c +0 -66
  290. package/libc/mingw/misc/wcstoimax.c +0 -132
  291. package/libc/mingw/misc/wcstoumax.c +0 -126
  292. package/libc/mingw/misc/wctob.c +0 -29
  293. package/libc/mingw/misc/winbs_uint64.c +0 -6
  294. package/libc/mingw/misc/winbs_ulong.c +0 -6
  295. package/libc/mingw/misc/winbs_ushort.c +0 -6
  296. package/libc/mingw/stdio/_Exit.c +0 -10
  297. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  298. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  299. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  300. package/libc/mingw/stdio/_stat64i32.c +0 -37
  301. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  302. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  303. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  304. package/libc/mingw/winpthreads/spinlock.c +0 -82
  305. package/libc/musl/src/legacy/isastream.c +0 -7
  306. package/libc/musl/src/legacy/valloc.c +0 -8
  307. package/libc/musl/src/linux/tee.c +0 -8
  308. package/libc/musl/src/math/__cosl.c +0 -96
  309. package/libc/musl/src/math/__sinl.c +0 -78
  310. package/libc/musl/src/math/__tanl.c +0 -143
  311. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  312. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  313. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  314. package/libc/musl/src/math/cosl.c +0 -39
  315. package/libc/musl/src/math/fdim.c +0 -10
  316. package/libc/musl/src/math/fdimf.c +0 -10
  317. package/libc/musl/src/math/fdiml.c +0 -18
  318. package/libc/musl/src/math/finite.c +0 -7
  319. package/libc/musl/src/math/finitef.c +0 -7
  320. package/libc/musl/src/math/frexp.c +0 -23
  321. package/libc/musl/src/math/frexpf.c +0 -23
  322. package/libc/musl/src/math/frexpl.c +0 -29
  323. package/libc/musl/src/math/i386/lrint.c +0 -8
  324. package/libc/musl/src/math/i386/lrintf.c +0 -8
  325. package/libc/musl/src/math/i386/rintf.c +0 -7
  326. package/libc/musl/src/math/lrint.c +0 -72
  327. package/libc/musl/src/math/lrintf.c +0 -8
  328. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  329. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  330. package/libc/musl/src/math/rintf.c +0 -30
  331. package/libc/musl/src/math/s390x/rintf.c +0 -15
  332. package/libc/musl/src/math/sincosl.c +0 -60
  333. package/libc/musl/src/math/sinl.c +0 -41
  334. package/libc/musl/src/math/tanl.c +0 -29
  335. package/libc/musl/src/math/x32/lrint.s +0 -5
  336. package/libc/musl/src/math/x32/lrintf.s +0 -5
  337. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  338. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  339. package/libc/musl/src/string/strdup.c +0 -10
  340. package/libc/musl/src/string/strndup.c +0 -12
  341. package/libc/musl/src/string/wcsdup.c +0 -10
  342. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  343. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  344. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  345. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  346. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  347. package/libc/musl/src/unistd/dup2.c +0 -20
  348. package/libc/musl/src/unistd/dup3.c +0 -26
  349. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
  350. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  351. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  352. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
@@ -7,7 +7,9 @@ const Diagnostics = @import("Diagnostics.zig");
7
7
  const Parser = @import("Parser.zig");
8
8
  const Tree = @import("Tree.zig");
9
9
  const TokenIndex = Tree.TokenIndex;
10
- const QualType = @import("TypeStore.zig").QualType;
10
+ const TypeStore = @import("TypeStore.zig");
11
+ const Type = TypeStore.Type;
12
+ const QualType = TypeStore.QualType;
11
13
  const Value = @import("Value.zig");
12
14
 
13
15
  const Attribute = @This();
@@ -341,7 +343,6 @@ fn diagnoseField(
341
343
 
342
344
  pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, arg_start: TokenIndex, node: Tree.Node, p: *Parser) !bool {
343
345
  switch (attr) {
344
- .nonnull => return false,
345
346
  inline else => |tag| {
346
347
  const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)];
347
348
  const max_arg_count = comptime maxArgCount(tag);
@@ -529,7 +530,10 @@ const attributes = struct {
529
530
  pub const @"noinline" = struct {};
530
531
  pub const noipa = struct {};
531
532
  // TODO: arbitrary number of arguments
532
- pub const nonnull = struct {};
533
+ // const nonnull = struct {
534
+ // // arg_index: []const u32,
535
+ // };
536
+ // };
533
537
  pub const nonstring = struct {};
534
538
  pub const noplt = struct {};
535
539
  pub const @"noreturn" = struct {};
@@ -577,6 +581,7 @@ const attributes = struct {
577
581
  };
578
582
  } = null,
579
583
  };
584
+ pub const single = struct {};
580
585
  pub const spectre = struct {
581
586
  arg: enum {
582
587
  nomitigation,
@@ -618,6 +623,7 @@ const attributes = struct {
618
623
  __name_tok: TokenIndex,
619
624
  };
620
625
  pub const uninitialized = struct {};
626
+ pub const unsafe_indexable = struct {};
621
627
  pub const unsequenced = struct {};
622
628
  pub const unused = struct {};
623
629
  pub const used = struct {};
@@ -723,6 +729,7 @@ pub const Arguments = blk: {
723
729
  name.* = decl.name;
724
730
  T.* = @field(attributes, decl.name);
725
731
  }
732
+
726
733
  break :blk @Union(.auto, null, &names, &types, &@splat(.{}));
727
734
  };
728
735
 
@@ -784,15 +791,8 @@ fn ignoredAttrErr(p: *Parser, tok: TokenIndex, attr: Attribute.Tag, context: []c
784
791
  try p.err(tok, .ignored_attribute, .{ @tagName(attr), context });
785
792
  }
786
793
 
787
- pub fn applyParameterAttributes(p: *Parser, qt: QualType, attr_buf_start: usize, diagnostic: ?Parser.Diagnostic) !QualType {
788
- return applyVariableOrParameterAttributes(p, qt, attr_buf_start, diagnostic, .parameter);
789
- }
790
-
794
+ pub const applyParameterAttributes = applyVariableAttributes;
791
795
  pub fn applyVariableAttributes(p: *Parser, qt: QualType, attr_buf_start: usize, diagnostic: ?Parser.Diagnostic) !QualType {
792
- return applyVariableOrParameterAttributes(p, qt, attr_buf_start, diagnostic, .variable);
793
- }
794
-
795
- fn applyVariableOrParameterAttributes(p: *Parser, qt: QualType, attr_buf_start: usize, diagnostic: ?Parser.Diagnostic, context: enum { parameter, variable }) !QualType {
796
796
  const gpa = p.comp.gpa;
797
797
  const attrs = p.attr_buf.items(.attr)[attr_buf_start..];
798
798
  const toks = p.attr_buf.items(.tok)[attr_buf_start..];
@@ -804,6 +804,7 @@ fn applyVariableOrParameterAttributes(p: *Parser, qt: QualType, attr_buf_start:
804
804
  // zig fmt: off
805
805
  .alias, .may_alias, .deprecated, .unavailable, .unused, .warn_if_not_aligned, .weak, .used,
806
806
  .noinit, .retain, .persistent, .section, .mode, .asm_label, .nullability, .unaligned, .selectany, .internal_linkage,
807
+ .visibility,
807
808
  => try p.attr_application_buf.append(gpa, attr),
808
809
  // zig fmt: on
809
810
  .common => if (nocommon) {
@@ -820,12 +821,6 @@ fn applyVariableOrParameterAttributes(p: *Parser, qt: QualType, attr_buf_start:
820
821
  },
821
822
  .vector_size => try attr.applyVectorSize(p, tok, &base_qt),
822
823
  .aligned => try attr.applyAligned(p, base_qt, diagnostic),
823
- .nonnull => {
824
- switch (context) {
825
- .parameter => try p.err(tok, .attribute_todo, .{ "nonnull", "parameters" }),
826
- .variable => try p.err(tok, .nonnull_not_applicable, .{}),
827
- }
828
- },
829
824
  .nonstring => {
830
825
  if (base_qt.get(p.comp, .array)) |array_ty| {
831
826
  if (array_ty.elem.get(p.comp, .int)) |int_ty| switch (int_ty) {
@@ -848,11 +843,28 @@ fn applyVariableOrParameterAttributes(p: *Parser, qt: QualType, attr_buf_start:
848
843
  } else {
849
844
  try p.attr_application_buf.append(gpa, attr);
850
845
  },
851
- .calling_convention => try applyCallingConvention(attr, p, tok, base_qt),
846
+ .single,
847
+ .unsafe_indexable,
848
+ => try applyBoundsSafetyAttr(.fromTag(attr.tag), p, tok, &base_qt),
849
+
850
+ .calling_convention => try applyKeywordCallingConvention(attr, p, tok, base_qt),
851
+
852
+ .fastcall,
853
+ .stdcall,
854
+ .thiscall,
855
+ .vectorcall,
856
+ .cdecl,
857
+ .pcs,
858
+ .riscv_vector_cc,
859
+ .aarch64_sve_pcs,
860
+ .aarch64_vector_pcs,
861
+ .sysv_abi,
862
+ .ms_abi,
863
+ => try applyGnuAttrCallingConvention(attr, p, tok, base_qt),
864
+
852
865
  .alloc_size,
853
866
  .copy,
854
867
  .tls_model,
855
- .visibility,
856
868
  => |t| try p.err(tok, .attribute_todo, .{ @tagName(t), "variables" }),
857
869
  // There is already an error in Parser for _Noreturn keyword
858
870
  .noreturn => if (attr.syntax != .keyword) try ignoredAttrErr(p, tok, attr.tag, "variables"),
@@ -903,7 +915,25 @@ pub fn applyTypeAttributes(p: *Parser, qt: QualType, attr_buf_start: usize, diag
903
915
  } else {
904
916
  try p.err(tok, .designated_init_invalid, .{});
905
917
  },
906
- .calling_convention => try applyCallingConvention(attr, p, tok, base_qt),
918
+ .calling_convention => try applyKeywordCallingConvention(attr, p, tok, base_qt),
919
+
920
+ .fastcall,
921
+ .stdcall,
922
+ .thiscall,
923
+ .vectorcall,
924
+ .cdecl,
925
+ .pcs,
926
+ .riscv_vector_cc,
927
+ .aarch64_sve_pcs,
928
+ .aarch64_vector_pcs,
929
+ .sysv_abi,
930
+ .ms_abi,
931
+ => try applyGnuAttrCallingConvention(attr, p, tok, base_qt),
932
+
933
+ .single,
934
+ .unsafe_indexable,
935
+ => try applyBoundsSafetyAttr(.fromTag(attr.tag), p, tok, &base_qt),
936
+
907
937
  .alloc_size,
908
938
  .copy,
909
939
  .scalar_storage_order,
@@ -931,6 +961,7 @@ pub fn applyFunctionAttributes(p: *Parser, qt: QualType, attr_buf_start: usize)
931
961
  .@"const", .warn_unused_result, .section, .returns_nonnull, .returns_twice, .@"error",
932
962
  .externally_visible, .retain, .flatten, .gnu_inline, .alias, .asm_label, .nodiscard,
933
963
  .reproducible, .unsequenced, .nothrow, .nullability, .unaligned, .internal_linkage,
964
+ .visibility,
934
965
  => try p.attr_application_buf.append(gpa, attr),
935
966
  // zig fmt: on
936
967
  .hot => if (cold) {
@@ -959,97 +990,21 @@ pub fn applyFunctionAttributes(p: *Parser, qt: QualType, attr_buf_start: usize)
959
990
  },
960
991
  .aligned => try attr.applyAligned(p, base_qt, null),
961
992
  .format => try attr.applyFormat(p, base_qt),
962
- .calling_convention => try applyCallingConvention(attr, p, tok, base_qt),
963
- .fastcall => if (p.comp.target.cpu.arch == .x86) {
964
- try p.attr_application_buf.append(gpa, .{
965
- .tag = .calling_convention,
966
- .args = .{ .calling_convention = .{ .cc = .fastcall } },
967
- .syntax = attr.syntax,
968
- });
969
- } else {
970
- try p.err(tok, .callconv_not_supported, .{"fastcall"});
971
- },
972
- .stdcall => if (p.comp.target.cpu.arch == .x86) {
973
- try p.attr_application_buf.append(gpa, .{
974
- .tag = .calling_convention,
975
- .args = .{ .calling_convention = .{ .cc = .stdcall } },
976
- .syntax = attr.syntax,
977
- });
978
- } else {
979
- try p.err(tok, .callconv_not_supported, .{"stdcall"});
980
- },
981
- .thiscall => if (p.comp.target.cpu.arch == .x86) {
982
- try p.attr_application_buf.append(gpa, .{
983
- .tag = .calling_convention,
984
- .args = .{ .calling_convention = .{ .cc = .thiscall } },
985
- .syntax = attr.syntax,
986
- });
987
- } else {
988
- try p.err(tok, .callconv_not_supported, .{"thiscall"});
989
- },
990
- .vectorcall => if (p.comp.target.cpu.arch == .x86 or p.comp.target.cpu.arch.isAARCH64()) {
991
- try p.attr_application_buf.append(gpa, .{
992
- .tag = .calling_convention,
993
- .args = .{ .calling_convention = .{ .cc = .vectorcall } },
994
- .syntax = attr.syntax,
995
- });
996
- } else {
997
- try p.err(tok, .callconv_not_supported, .{"vectorcall"});
998
- },
999
- .cdecl => {},
1000
- .pcs => if (p.comp.target.cpu.arch.isArm()) {
1001
- try p.attr_application_buf.append(gpa, .{
1002
- .tag = .calling_convention,
1003
- .args = .{ .calling_convention = .{ .cc = switch (attr.args.pcs.kind) {
1004
- .aapcs => .arm_aapcs,
1005
- .@"aapcs-vfp" => .arm_aapcs_vfp,
1006
- } } },
1007
- .syntax = attr.syntax,
1008
- });
1009
- } else {
1010
- try p.err(tok, .callconv_not_supported, .{"pcs"});
1011
- },
1012
- .riscv_vector_cc => if (p.comp.target.cpu.arch.isRISCV()) {
1013
- try p.attr_application_buf.append(gpa, .{
1014
- .tag = .calling_convention,
1015
- .args = .{ .calling_convention = .{ .cc = .riscv_vector } },
1016
- .syntax = attr.syntax,
1017
- });
1018
- } else {
1019
- try p.err(tok, .callconv_not_supported, .{"pcs"});
1020
- },
1021
- .aarch64_sve_pcs => if (p.comp.target.cpu.arch.isAARCH64()) {
1022
- try p.attr_application_buf.append(gpa, .{
1023
- .tag = .calling_convention,
1024
- .args = .{ .calling_convention = .{ .cc = .aarch64_sve_pcs } },
1025
- .syntax = attr.syntax,
1026
- });
1027
- } else {
1028
- try p.err(tok, .callconv_not_supported, .{"pcs"});
1029
- },
1030
- .aarch64_vector_pcs => if (p.comp.target.cpu.arch.isAARCH64()) {
1031
- try p.attr_application_buf.append(gpa, .{
1032
- .tag = .calling_convention,
1033
- .args = .{ .calling_convention = .{ .cc = .aarch64_vector_pcs } },
1034
- .syntax = attr.syntax,
1035
- });
1036
- } else {
1037
- try p.err(tok, .callconv_not_supported, .{"pcs"});
1038
- },
1039
- .sysv_abi => if (p.comp.target.cpu.arch == .x86_64 and p.comp.target.os.tag == .windows) {
1040
- try p.attr_application_buf.append(gpa, .{
1041
- .tag = .calling_convention,
1042
- .args = .{ .calling_convention = .{ .cc = .x86_64_sysv } },
1043
- .syntax = attr.syntax,
1044
- });
1045
- },
1046
- .ms_abi => if (p.comp.target.cpu.arch == .x86_64 and p.comp.target.os.tag != .windows) {
1047
- try p.attr_application_buf.append(gpa, .{
1048
- .tag = .calling_convention,
1049
- .args = .{ .calling_convention = .{ .cc = .x86_64_win } },
1050
- .syntax = attr.syntax,
1051
- });
1052
- },
993
+ .calling_convention => try applyKeywordCallingConvention(attr, p, tok, base_qt),
994
+
995
+ .fastcall,
996
+ .stdcall,
997
+ .thiscall,
998
+ .vectorcall,
999
+ .cdecl,
1000
+ .pcs,
1001
+ .riscv_vector_cc,
1002
+ .aarch64_sve_pcs,
1003
+ .aarch64_vector_pcs,
1004
+ .sysv_abi,
1005
+ .ms_abi,
1006
+ => try applyGnuAttrCallingConvention(attr, p, tok, base_qt),
1007
+
1053
1008
  .malloc => {
1054
1009
  if (base_qt.get(p.comp, .func).?.return_type.isPointer(p.comp)) {
1055
1010
  try p.attr_application_buf.append(gpa, attr);
@@ -1102,7 +1057,7 @@ pub fn applyFunctionAttributes(p: *Parser, qt: QualType, attr_buf_start: usize)
1102
1057
  .no_stack_protector,
1103
1058
  .noclone,
1104
1059
  .noipa,
1105
- .nonnull,
1060
+ // .nonnull,
1106
1061
  .noplt,
1107
1062
  // .optimize,
1108
1063
  .patchable_function_entry,
@@ -1112,7 +1067,6 @@ pub fn applyFunctionAttributes(p: *Parser, qt: QualType, attr_buf_start: usize)
1112
1067
  .symver,
1113
1068
  .target,
1114
1069
  .target_clones,
1115
- .visibility,
1116
1070
  .weakref,
1117
1071
  .zero_call_used_regs,
1118
1072
  => |t| try p.err(tok, .attribute_todo, .{ @tagName(t), "functions" }),
@@ -1262,9 +1216,129 @@ fn applyFormat(attr: Attribute, p: *Parser, qt: QualType) !void {
1262
1216
  try p.attr_application_buf.append(p.comp.gpa, attr);
1263
1217
  }
1264
1218
 
1265
- fn applyCallingConvention(attr: Attribute, p: *Parser, tok: TokenIndex, qt: QualType) !void {
1266
- if (!qt.is(p.comp, .func)) {
1267
- return p.err(tok, .callconv_non_func, .{ p.tok_ids[tok].symbol(), qt });
1219
+ /// These come from GNU attributes like __attribute__((sysv_abi))
1220
+ fn applyGnuAttrCallingConvention(attr: Attribute, p: *Parser, tok: TokenIndex, qt: QualType) !void {
1221
+ if (!qt.isCallable(p.comp)) {
1222
+ return p.err(tok, .callconv_non_func, .{ p.tokSlice(tok), qt });
1223
+ }
1224
+ const gpa = p.comp.gpa;
1225
+ switch (attr.tag) {
1226
+ .fastcall => if (p.comp.target.cpu.arch == .x86) {
1227
+ try p.attr_application_buf.append(gpa, .{
1228
+ .tag = .calling_convention,
1229
+ .args = .{ .calling_convention = .{ .cc = .fastcall } },
1230
+ .syntax = attr.syntax,
1231
+ });
1232
+ } else {
1233
+ try p.err(tok, .callconv_not_supported, .{"fastcall"});
1234
+ },
1235
+ .stdcall => if (p.comp.target.cpu.arch == .x86) {
1236
+ try p.attr_application_buf.append(gpa, .{
1237
+ .tag = .calling_convention,
1238
+ .args = .{ .calling_convention = .{ .cc = .stdcall } },
1239
+ .syntax = attr.syntax,
1240
+ });
1241
+ } else {
1242
+ try p.err(tok, .callconv_not_supported, .{"stdcall"});
1243
+ },
1244
+ .thiscall => if (p.comp.target.cpu.arch == .x86) {
1245
+ try p.attr_application_buf.append(gpa, .{
1246
+ .tag = .calling_convention,
1247
+ .args = .{ .calling_convention = .{ .cc = .thiscall } },
1248
+ .syntax = attr.syntax,
1249
+ });
1250
+ } else {
1251
+ try p.err(tok, .callconv_not_supported, .{"thiscall"});
1252
+ },
1253
+ .vectorcall => if (p.comp.target.cpu.arch == .x86 or p.comp.target.cpu.arch.isAARCH64()) {
1254
+ try p.attr_application_buf.append(gpa, .{
1255
+ .tag = .calling_convention,
1256
+ .args = .{ .calling_convention = .{ .cc = .vectorcall } },
1257
+ .syntax = attr.syntax,
1258
+ });
1259
+ } else {
1260
+ try p.err(tok, .callconv_not_supported, .{"vectorcall"});
1261
+ },
1262
+ .cdecl => {},
1263
+ .pcs => if (p.comp.target.cpu.arch.isArm()) {
1264
+ try p.attr_application_buf.append(gpa, .{
1265
+ .tag = .calling_convention,
1266
+ .args = .{ .calling_convention = .{ .cc = switch (attr.args.pcs.kind) {
1267
+ .aapcs => .arm_aapcs,
1268
+ .@"aapcs-vfp" => .arm_aapcs_vfp,
1269
+ } } },
1270
+ .syntax = attr.syntax,
1271
+ });
1272
+ } else {
1273
+ try p.err(tok, .callconv_not_supported, .{"pcs"});
1274
+ },
1275
+ .riscv_vector_cc => if (p.comp.target.cpu.arch.isRISCV()) {
1276
+ try p.attr_application_buf.append(gpa, .{
1277
+ .tag = .calling_convention,
1278
+ .args = .{ .calling_convention = .{ .cc = .riscv_vector } },
1279
+ .syntax = attr.syntax,
1280
+ });
1281
+ } else {
1282
+ try p.err(tok, .callconv_not_supported, .{"pcs"});
1283
+ },
1284
+ .aarch64_sve_pcs => if (p.comp.target.cpu.arch.isAARCH64()) {
1285
+ try p.attr_application_buf.append(gpa, .{
1286
+ .tag = .calling_convention,
1287
+ .args = .{ .calling_convention = .{ .cc = .aarch64_sve_pcs } },
1288
+ .syntax = attr.syntax,
1289
+ });
1290
+ } else {
1291
+ try p.err(tok, .callconv_not_supported, .{"pcs"});
1292
+ },
1293
+ .aarch64_vector_pcs => if (p.comp.target.cpu.arch.isAARCH64()) {
1294
+ try p.attr_application_buf.append(gpa, .{
1295
+ .tag = .calling_convention,
1296
+ .args = .{ .calling_convention = .{ .cc = .aarch64_vector_pcs } },
1297
+ .syntax = attr.syntax,
1298
+ });
1299
+ } else {
1300
+ try p.err(tok, .callconv_not_supported, .{"pcs"});
1301
+ },
1302
+ .sysv_abi => if (p.comp.target.cpu.arch == .x86_64 and p.comp.target.os.tag == .windows) {
1303
+ try p.attr_application_buf.append(gpa, .{
1304
+ .tag = .calling_convention,
1305
+ .args = .{ .calling_convention = .{ .cc = .x86_64_sysv } },
1306
+ .syntax = attr.syntax,
1307
+ });
1308
+ },
1309
+ .ms_abi => if (p.comp.target.cpu.arch == .x86_64 and p.comp.target.os.tag != .windows) {
1310
+ try p.attr_application_buf.append(gpa, .{
1311
+ .tag = .calling_convention,
1312
+ .args = .{ .calling_convention = .{ .cc = .x86_64_win } },
1313
+ .syntax = attr.syntax,
1314
+ });
1315
+ },
1316
+ else => unreachable,
1317
+ }
1318
+ }
1319
+
1320
+ fn applyBoundsSafetyAttr(bounds: Type.Pointer.Bounds, p: *Parser, tok: TokenIndex, qt: *QualType) !void {
1321
+ if (qt.isInvalid()) return;
1322
+ const pointer = qt.get(p.comp, .pointer) orelse {
1323
+ return p.err(tok, .attribute_requires_pointer, .{@tagName(bounds)});
1324
+ };
1325
+ if (pointer.bounds == bounds) {
1326
+ return p.err(tok, .redundant_bounds_annotation, .{@tagName(bounds)});
1327
+ }
1328
+ if (pointer.bounds != .c) {
1329
+ return p.err(tok, .multiple_bounds_annotations, .{});
1330
+ }
1331
+ qt.* = try p.comp.type_store.put(p.comp.gpa, .{ .pointer = .{
1332
+ .child = pointer.child,
1333
+ .decayed = pointer.decayed,
1334
+ .bounds = bounds,
1335
+ } });
1336
+ }
1337
+
1338
+ /// These come from explicit MSVC keywords like __stdcall, __fastcall, etc
1339
+ fn applyKeywordCallingConvention(attr: Attribute, p: *Parser, tok: TokenIndex, qt: QualType) !void {
1340
+ if (!qt.isCallable(p.comp)) {
1341
+ return p.err(tok, .callconv_non_func, .{ p.tokSlice(tok), qt });
1268
1342
  }
1269
1343
  switch (attr.args.calling_convention.cc) {
1270
1344
  .c => {},
@@ -1295,3 +1369,15 @@ fn applySelected(qt: QualType, p: *Parser) !QualType {
1295
1369
  .attributes = p.attr_application_buf.items,
1296
1370
  } })).withQualifiers(qt);
1297
1371
  }
1372
+
1373
+ pub fn visibilityFromString(s: []const u8) ?std.builtin.SymbolVisibility {
1374
+ if (mem.eql(u8, s, "internal")) {
1375
+ return .hidden;
1376
+ }
1377
+ const visibility = std.meta.stringToEnum(std.builtin.SymbolVisibility, s) orelse return null;
1378
+ // compiler will notify us if .internal is added as a visibility type
1379
+ switch (visibility) {
1380
+ .default, .hidden, .protected => {},
1381
+ }
1382
+ return visibility;
1383
+ }