3563 Commits

Author SHA1 Message Date
Vexu
cb257b4e11
allow non-exhaustive enums with no fields 2020-01-16 09:23:26 +02:00
Vexu
d84569895c
turn panics into compile errors, require at least 1 field in non-exhaustive enum 2020-01-16 09:04:11 +02:00
Vexu
5c2238fc4a
small fixes
* error for '_' prong on exhaustive enum
* todo panic for `@tagName`  on non-exhaustive enum
* don't require '_' field on tagged unions
2020-01-15 22:09:19 +02:00
Vexu
c57784aa15
add is_exhaustive field to typeinfo 2020-01-15 21:50:12 +02:00
Vexu
f3d174aa61
require size for non-exhaustive enums 2020-01-15 21:38:11 +02:00
Vexu
6fd0dddf18
implement non-exhaustive enums 2020-01-15 20:24:59 +02:00
Andrew Kelley
8d9d4a0658
Merge pull request #4182 from LemonBoy/mjeiorw
A bunch of patches
2020-01-15 04:28:54 -05:00
LemonBoy
49771f356f Make sure @export symbol name is not empty 2020-01-14 21:23:11 +01:00
LemonBoy
158d98a7f2 Print sentinel value in ir_print 2020-01-14 21:13:55 +01:00
LemonBoy
505b9db909 Fix codegen error for some union initializers
Closes #3377
2020-01-14 14:57:03 -05:00
LemonBoy
50754ba336 Fix ICE when BoundFn are passed as parameters
Closes #4022
Closes #3699
2020-01-14 13:09:23 -05:00
LemonBoy
cae93c860b Allow switching on pointer types
Closes #4074
2020-01-13 22:18:49 +01:00
LemonBoy
84930fec27 Validate switch range endpoints 2020-01-13 21:45:16 +01:00
Andrew Kelley
4f9739189e
add an extra assert 2020-01-13 14:48:43 -05:00
Andrew Kelley
4d4852ad31
Merge pull request #4162 from LemonBoy/fix-4020
Fix @call being too eager to resolve the fn argument
2020-01-13 11:48:54 -05:00
LemonBoy
34cdcb13c0 Fix @call being too eager to resolve the fn argument
Closes #4020
2020-01-12 23:51:18 +01:00
Michael Dusan
25b1ae0a5f
prefer C++ compiler builtins for BREAKPOINT
Fix breakpoints on macOS to trap EXC_BREAKPOINT with correct
source location when using lldb. Old behavior with `raise(SIGTRAP)`
traps SIGTRAP and incorrect source location.

Fix breakpoints on archlinux to trap SIGILL with correct source
location when using gdb. Old behavior with `raise(SIGTRAP)`
traps SIGTRAP and (sometimes) incorrect source location with
very shallow (break in main) stack.

when building stage1:
- w/ clang, use `__builtin_debugtrap()`
- w/ gcc, use `__builtin_trap()`
- else use `raise(SIGTRAP)`
2020-01-12 16:41:11 -05:00
LemonBoy
c96131f30c Propagate errors in for loop bodies
Closes #3819
2020-01-12 12:49:12 -05:00
Michael Dusan
fc20a58993
strip cwd from compile error paths
closes #43138
2020-01-11 16:45:57 -05:00
LemonBoy
34ae1d9aa8 Fix unsafe cast in translate_c
* Handle EmptyDecls to clean up the generated code

Closes #4143
2020-01-11 15:51:10 -05:00
LemonBoy
95619ecb8c Stop dropping errors from clang
* Refactor the error-writing code to be more compact and flexible
2020-01-11 15:48:32 -05:00
LemonBoy
9cc7fb66bc Don't special-case builtin too much
Let's use the usual declaration-searching mechanism that resolves the
`usingnamespace` declarations on the go instead of directly peeking into
the symbol table.

Fixes #4134
2020-01-10 16:44:15 -05:00
LemonBoy
84e98405de Inform the debugger about the effective type sizes
Makes every debugger happy and closes #2685
2020-01-10 16:42:49 -05:00
LemonBoy
570ffc470e Handle forward-declared functions
Closes #4130
2020-01-10 16:34:40 -05:00
Andrew Kelley
5e345ff0ee
Merge pull request #3955 from LemonBoy/fix-1528
Pointer arithmetic affects the alignment factor
2020-01-09 13:53:56 -05:00
LemonBoy
5ab5de89c0 New @export() handling
Use a struct as second parameter to be future proof (and also allows to
specify default values for the parameters)

Closes #2679 as it was just a matter of a few lines of code.
2020-01-09 13:43:06 -05:00
LemonBoy
c51b79c56e Correct alignment calculation for runtime addends 2020-01-09 11:56:45 +01:00
LemonBoy
27b290f312 Propagate more failures upwards
Fixes #4112
2020-01-08 17:25:00 -05:00
LemonBoy
7ea7842ed0 Fix calculation of new alignment factor 2020-01-08 21:02:05 +01:00
LemonBoy
e134e6c994 Pointer arithmetic affects the alignment factor
Closes #1528
2020-01-08 20:03:03 +01:00
LemonBoy
fd7e69a2c0 More translate-c fixes
* Translate OpaqueValueExpr
* Translate BinaryConditionalOperator
* Fix translation of boolean->int casts
* Reoder some tokens to avoid rendering errors
2020-01-08 08:43:37 +01:00
LemonBoy
2a5c622e65 Fix crash with unresolved loc
Fixes #4099
2020-01-07 18:16:17 -05:00
Andrew Kelley
af390b75db
cleanups related to --eh-frame-hdr 2020-01-07 16:02:38 -05:00
David Cao
8e57dd57ca
add --eh-frame-hdr conditionally 2020-01-07 15:58:40 -05:00
David Cao
599213463d
add --eh-frame-hdr arg for linking 2020-01-07 15:58:39 -05:00
LemonBoy
3607d9ee68 Fix crash in struct initializer evaluation
Closes #4100
2020-01-07 15:06:22 -05:00
via
9390e8b848 Preserve packed attribute in C translated struct (#4085)
* Preserve packed attribute in C translated struct

* Add tests for packed C struct
2020-01-07 02:36:07 -05:00
LemonBoy
8c640b3e60 Prevent bitCast to enum types
Stop the user from creating invalid enum values.
2020-01-06 19:36:17 -05:00
Andrew Kelley
baaef7ed97
Merge pull request #4083 from LemonBoy/better-stdbool
Better _Bool translation
2020-01-06 19:21:55 -05:00
LemonBoy
1dc25d7550
Translate anonymous union/struct 2020-01-06 19:17:47 -05:00
Andrew Kelley
be2483c576
fix test suite regressions 2020-01-06 18:20:31 -05:00
Andrew Kelley
3b5c71d2a5
fix regression with @TypeInfo 2020-01-06 17:13:45 -05:00
Andrew Kelley
5951b79af4
remove stdcallcc, extern, nakedcc from stage1; zig fmt rewrites 2020-01-06 15:23:05 -05:00
Andrew Kelley
0a9daeb37e
Merge branch 'cc-work' of https://github.com/LemonBoy/zig into LemonBoy-cc-work 2020-01-06 14:07:56 -05:00
LemonBoy
cd39f6df95 Better _Bool translation 2020-01-06 00:12:18 +01:00
LemonBoy
6ff70d3c31 Better InitListExpr translation 2020-01-05 17:39:29 -05:00
Andrew Kelley
a0ca34979e
Merge pull request #4053 from ziglang/test-run-translated-c
add test harness for "run translated C" tests
2020-01-05 14:50:02 -05:00
Andrew Kelley
14fcfe2981
translate-c supports --cache on
this will be used to provide a zig build step
2020-01-03 22:11:19 -05:00
LemonBoy
b91eaba38c Correct evaluation of optional type alignment
The lazy logic was too oversimplified and produced a different result
than the one computed later causing all kinds of problems.

Closes #4013
2020-01-03 17:41:55 -05:00
Haze Booth
f40b6b85f1 Remove translate-c-2 from zig help 2020-01-03 02:17:08 -05:00