Jakub Konka
90b3599c68
coff: reorganize the linker
2022-08-30 10:42:21 +02:00
Andrew Kelley
7453f56e67
stage2: explicitly tagged enums no longer have one possible value
...
Previously, Zig had inconsistent semantics for an enum like this:
`enum(u8){zero = 0}`
Although in theory this can only hold one possible value, the tag
`zero`, Zig no longer will treat the type this way. It will do loads and
stores, as if the type has runtime bits.
Closes #12619
Tests passed locally:
* test-behavior
* test-cases
2022-08-24 22:20:31 -07:00
Andrew Kelley
af19909b9c
stage2: fix generic function cleanup
...
When removing generic function instantiations from monomorphed_funcs, we
need to first make sure the function is generic, otherwise the hash map
tries to access the `hash` field of the function which is undefined.
closes #12614
2022-08-24 16:47:58 -07:00
Veikka Tuominen
b55a5007fa
Sema: fix parameter of type 'T' must be comptime error
...
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Andrew Kelley
437311756d
LLVM: add DLL export attribute
...
This was present in stage1 but missing from self-hosted.
2022-08-19 16:45:16 -07:00
Andrew Kelley
cee82c7ce4
improved ABI alignment/size for >= 128-bit integers
...
* riscv64: adjust alignment and size of 128-bit integers.
* take ofmt=c into account for ABI alignment of 128-bit integers and
structs.
* Type: make packed struct support intInfo
* fix f80 alignment for i386-windows-msvc
2022-08-18 20:34:36 -07:00
Andrew Kelley
6e313eb110
stage2: agree with LLVM that @alignOf(u128) is 8
...
on x86_64 and similar targets.
2022-08-18 17:11:32 -07:00
Andrew Kelley
933436dc52
stage2: remove destroyed functions from maps
...
This is likely the cause of the flaky test failures in master branch.
Since we have some test coverage for incremental compilation, it's not
OK to leave proper memory management of Fn objects as "TODO".
2022-08-10 23:23:30 -07:00
Isaac Freund
0d32b73078
stage2: Implement explicit backing integers for packed structs
...
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Veikka Tuominen
c76b5c1a31
stage2: correct node offset of nested declarations
2022-08-09 11:59:10 +03:00
Veikka Tuominen
42ade6a114
Merge pull request #12300 from antlilja/getParamName
...
Replace param_names and anytype_args fields inside of Fn with functions
2022-08-05 15:29:59 +03:00
Veikka Tuominen
f1768b40b2
stage2: better source location for var decls
2022-08-01 23:37:01 +03:00
antlilja
ab3b614a33
Removed anytype_args field from Fn
...
anytype_args field was replaced with isAnytypeParam function.
2022-08-01 14:51:54 +02:00
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
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
LordMZTE
c6f5832bb6
Module: fix inverted condition
2022-07-27 18:17:07 +03:00
LordMZTE
8c4896fb3a
Module: use path.isSep
...
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-07-27 18:17:07 +03:00
LordMZTE
1110eafe9b
Module: fix error message importing file starting with root path
2022-07-27 18:17:07 +03:00
Veikka Tuominen
825fc654b6
Sema: better source location for builtin options
2022-07-26 12:14:59 +03:00
Veikka Tuominen
28478a4bac
Module: improve handling of errors in @call arguments
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
Andrew Kelley
93ae386f56
stage2: don't skip liveness or codegen if -femit-asm is supplied
...
Fixes Godbolt's CLI usage of Zig.
2022-07-24 15:02:05 -07:00
Meghan
dea437edfb
stage2: implement noinline fn
2022-07-24 11:56:33 +03:00
Veikka Tuominen
2436dd2c1b
Sema: validate duplicate fields in anon structs
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
ff7ec4efb5
Sema: bad union field access safety
2022-07-23 15:40:11 +03:00
Veikka Tuominen
821e4063f9
Sema: better source location for function call args
2022-07-21 12:21:30 -07:00
Veikka Tuominen
79ef0cdf30
Sema: better function parameter source location
2022-07-21 12:21:30 -07:00
Veikka Tuominen
83b2d2cd3e
Sema: better source location for incompatible capture group
2022-07-21 12:21:30 -07:00
Veikka Tuominen
1705a21f80
Sema: more union and enum tag type validation
2022-07-21 12:21:30 -07:00
Veikka Tuominen
8feb398760
Sema: validate function parameter types and return type
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d851b24180
Sema: validate function pointer alignment
2022-07-21 12:21:30 -07:00
Veikka Tuominen
76e7959a90
Sema: explain why comptime is needed
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d729173204
stage2: better pointer source location
2022-07-21 12:21:30 -07:00
Veikka Tuominen
cf207df592
Module: improve source spans for initializers and var types
...
```zig
const U = union { foo: u32, bar: u32 };
test {
var a = U{ .foo = 1213, .bar = 1123 };
_ = a;
}
test {
var a: (123 + 5238094) = 0;
_ = a;
}
```
before:
```
:30: note: additional initializer here
var a = U{ .foo = 1213, .bar = 1123 };
^~~
:12: error: expected type 'type', found 'comptime_int'
var a: (123 + 5238094) = 0;
^
```
after:
```
:30: note: additional initializer here
var a = U{ .foo = 1213, .bar = 1123 };
~^~~~~~~~~~
:12: error: expected type 'type', found 'comptime_int'
var a: (123 + 5238094) = 0;
^~~~~~~~~~~~~~~
```
2022-07-15 16:06:16 +03:00
Veikka Tuominen
1463144fc8
Compilation: point caret in error message at the main token
2022-07-15 15:11:43 +03:00
Veikka Tuominen
b5a838247b
stage2: point to error location using spans
2022-07-14 22:18:58 +03:00
Andrew Kelley
4a28c1d5c3
stage2: lower each struct field type, align, init separately
...
Previously, struct types, alignment values, and initialization
expressions were all lowered into the same ZIR body, which caused false
positive "depends on itself" errors when the initialization expression
depended on the size of the struct.
This also uses ResultLoc.coerced_ty for struct field alignment and
initialization values. The resulting ZIR encoding ends up being roughly
the same, neither smaller nor larger than previously.
Closes #12029
2022-07-13 02:38:13 -04:00
Veikka Tuominen
2a3f3766a4
stage2: handle parser notes in a more general way
2022-07-12 12:50:59 +03:00
Veikka Tuominen
5d22204d2d
parser: add helpful error for C style container declarations
...
```zig
// a.zig
struct Foo {
a: u32,
};
```
before:
```
a.zig:1:1: error: expected test, comptime, var decl, or container field, found 'struct'
struct Foo {
^
```
after:
```
a.zig:1:8: error: 'struct Foo' is invalid
struct Foo {
^
a.zig:1:8: note: to declare a container do 'const Foo = struct'
struct Foo {
^
```
2022-07-12 12:50:59 +03:00
Veikka Tuominen
27ee414159
Sema: improve slice source locations
2022-07-07 10:50:06 +03:00
Veikka Tuominen
2ca752ea1a
Module: add .node_offset_un_op
2022-07-07 10:50:06 +03:00
Veikka Tuominen
6cadac18b8
Sema: improve auto generated union enum name
2022-06-30 09:57:38 +02:00
Andrew Kelley
3b19869853
Sema: honor the --test-filter flag
2022-06-27 14:31:54 -07:00
Veikka Tuominen
0f820d0bdf
stage2: improve debugging tools
...
llvm: dump failed module when -femit-llvm-ir set
print_air:
* print fully qualified name
* use Type.fmt and Value.fmtValue, fmtDebug is useless
TypedValue
* handle anon structs and tuples
* fix bugs
2022-06-11 11:02:56 +03:00
Andrew Kelley
2bf532fc23
stage2: use std.debug.Trace only when explicitly enabled
...
Because it bumps up the stack space requirements, which is making a test
case fail on aarch64 drone CI.
2022-06-09 20:00:59 -07:00