Commit Graph

1036 Commits

Author SHA1 Message Date
antlilja cd8070f94f Removed param_names from Fn inside Module.zig
Removed the copy of param_names inside of Fn and changed to
implementation of getParamName to fetch to parameter name from the ZIR.
The signature of getParamName was also changed to take an additional
*Module argument.
2022-08-01 14:51:50 +02:00
Veikka Tuominen 02dc073260 Sema: check comptime slice sentinel 2022-07-30 11:07:37 +03:00
Veikka Tuominen 4758752e5d Sema: implement coercion from tuples to tuples
Closes #12242
2022-07-30 00:18:08 +03:00
Veikka Tuominen 17622b9db1 Sema: implement @Type for functions
Closes #12280
2022-07-30 00:18:08 +03:00
Andrew Kelley a7a6f38eeb Sema: fix runtime safety for integer overflow with vectors 2022-07-29 11:03:12 -07:00
Andrew Kelley 40f8f0134f Sema: enhance div_trunc, div_exact, div_floor
* No longer emit div_exact AIR instruction that can produce a
   remainder, invoking undefined behavior.
 * div_trunc, div_exact, div_floor are extracted from analyzeArithmetic
   and directly handled similarly to div_trunc, integrating them with
   integer overflow safety checking.
 * Also they no longer emit divide-by-zero safety checking when RHS
   is comptime known to be non-zero.
2022-07-29 02:35:06 -07:00
Andrew Kelley 1fc24e8d80 Sema: enhance div instruction analysis
Concrete improvements:
 * Added safety for integer overflow (-MAX_INT/-1)
 * Omit division by zero safety check when RHS is comptime known to
   be non-zero.
 * Avoid emitting `_optimized` variants of AIR instructions for integers
   (this suffix is intended to be used for floats only).

Subjective changes: I extracted the div logic out from analyzeArithmetic
in order to reduce the amount of branches - not for performance reasons
but for code clarity. It is more lines of code however, and some logic
is duplicated.
2022-07-29 02:35:06 -07:00
Veikka Tuominen fdaf9c40d6 stage2: handle tuple init edge cases 2022-07-29 10:12:36 +03:00
Veikka Tuominen 9e0a930ce3 stage2: add error for comptime control flow in runtime block 2022-07-29 10:08:35 +03:00
Meghan 02acde99a1 stage2: ensure 'std', 'builtin', and 'root' is always available to @import 2022-07-28 15:19:17 -07:00
Andrew Kelley dfc7493dcb Merge pull request #12256 from Vexu/stage2
stage2 typeInfo UAF fix + more
2022-07-27 16:11:07 -07:00
Veikka Tuominen 793db63746 Sema: copy fn param ty in zirTypeInfo
Closes #12247
2022-07-27 18:27:17 +03:00
r00ster91 baafb8a491 std.fmt: add more invalid format string errors 2022-07-27 18:07:53 +03:00
Veikka Tuominen 3818d63dd8 Sema: resolve pointee type in zirReify
Closes #12223
2022-07-27 17:11:46 +03:00
Andrew Kelley c8c798685f Merge pull request #12244 from Vexu/stage2
Minor stage2 fixes
2022-07-26 17:41:26 -07:00
Veikka Tuominen d6e3988fe8 Sema: better error when coercing error sets 2022-07-26 23:29:54 +03:00
Veikka Tuominen 7862ab9f41 Sema: disable "unreachable else prong" error for error sets for now
Closes #11798
2022-07-26 16:40:24 +03:00
Veikka Tuominen 5d99e5ecd4 Sema: improve expression value ignored error
Closes #4483
2022-07-26 16:40:24 +03:00
Veikka Tuominen 3d18c8c130 Sema: resolve lazy values for compile log
Close #12204
2022-07-26 16:40:24 +03:00
Veikka Tuominen d78532f462 Sema: give comptime_field_ptr priority over field_ptr in tuples
Closes #11983
2022-07-26 16:40:24 +03:00
Veikka Tuominen 825fc654b6 Sema: better source location for builtin options 2022-07-26 12:14:59 +03:00
Veikka Tuominen 2f34d06d01 Sema: analyzeInlineCallArg needs a block for the arg and the param 2022-07-25 22:04:08 +03:00
Meghan dea437edfb stage2: implement noinline fn 2022-07-24 11:56:33 +03:00
Andreas Reischuck 903bed931d report better error for package not found in stage2 2022-07-24 11:55:37 +03:00
Veikka Tuominen baf516218e Sema: don't add union field access safety check for single field unions 2022-07-23 15:40:12 +03:00
Veikka Tuominen 2436dd2c1b Sema: validate duplicate fields in anon structs 2022-07-23 15:40:12 +03:00
Veikka Tuominen 5b29275240 Sema: add some more 'declared here' notes 2022-07-23 15:40:12 +03:00
Veikka Tuominen 881c0cb20b Sema: add default value here note to invalid comptime field store error 2022-07-23 15:40:12 +03:00
Veikka Tuominen 15dddfd84d AstGen: make comptime fields in packed and extern structs compile errors 2022-07-23 15:40:12 +03:00
Veikka Tuominen 0ef4cc738b Sema: check for zero length slices in @alignCast safety 2022-07-23 15:40:12 +03:00
Veikka Tuominen d75fa86d70 stage2: implement @setFloatMode 2022-07-23 15:40:12 +03:00
Veikka Tuominen 585c160c20 Sema: handle store to comptime field when ResultLoc == .none 2022-07-23 15:40:12 +03:00
Veikka Tuominen 9465906775 Sema: return .comptime_field_ptrs for tuples 2022-07-23 15:40:12 +03:00
Veikka Tuominen cf87026e52 Sema: @alignCast safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 711b656773 Sema: @floatToInt safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen ff7ec4efb5 Sema: bad union field access safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 55fe34100f Sema: exact division safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 76d099950a Sema: cast negative to unsigned safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 0782586b15 Sema: divide by zero safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 9f10dfcb54 Sema: implement shr_exact runtime safety 2022-07-23 15:40:11 +03:00
Veikka Tuominen 423a19fa60 Sema: add error for dereferencing invalid payload ptr at comptime 2022-07-22 21:10:50 +03:00
Veikka Tuominen 1f748fe426 Sema: fix mutation of optional ptr represented as regular ptr 2022-07-22 19:50:11 +03:00
Veikka Tuominen c619371ec1 Sema: fix loading and storing of optional pointers represented as pointers 2022-07-22 17:03:42 +03:00
Veikka Tuominen 393d59bb72 Sema: allow C pointers in fieldCallBind 2022-07-22 17:03:42 +03:00
Veikka Tuominen 8a488fcdb8 Sema: validate empty array init 2022-07-22 17:03:42 +03:00
Veikka Tuominen 47de73980e Sema: use resolveMaybeUndefValIntable in zirIntToPtr 2022-07-22 17:03:42 +03:00
Andrew Kelley 25f3be32db Sema: fix fn pointer align disagrees with fn align error
Check the specified function alignment rather than the effective
function alignment.
2022-07-21 15:19:56 -07:00
Andrew Kelley fc6e111b76 Sema: improve compile error for bad function alignment
* Integrate more declaratively with src/target.zig
 * Only trigger the check when a function body is found, do not trigger
   for function types.
2022-07-21 13:55:29 -07:00
Veikka Tuominen 794beafb9c Sema: validate extern struct field types earlier
`validateExternType` does not require the type to be resolved so we can
check it earlier. Only doing it in `resolveTypeFully` lead to worse or
missing compile errors.
2022-07-21 12:21:30 -07:00
Veikka Tuominen 821e4063f9 Sema: better source location for function call args 2022-07-21 12:21:30 -07:00