Andrew Kelley
62c25af802
add higher level arg-parsing API + misc. changes
...
* add @noInlineCall - see #640
This fixes a crash in --release-safe and --release-fast modes
where the optimizer inlines everything into _start and
clobbers the command line argument data.
If we were able to verify that the user's code never reads
command line args, we could leave off this "no inline"
attribute.
* add i29 and u29 primitive types. u29 is the type of alignment,
so it makes sense to be a primitive.
probably in the future we'll make any `i` or `u` followed by
digits into a primitive.
* add `aligned` functions to Allocator interface
* add `os.argsAlloc` and `os.argsFree` so that you can get
a `[]const []u8`, do whatever arg parsing you want, and then free
it. For now this uses the other API under the hood, but it could
be reimplemented to do a single allocation.
* add tests to make sure command line argument parsing works.
2017-12-06 18:12:05 -05:00
Andrew Kelley
249cb2aa30
fix regressions from previous commit
...
c49ee9f632
broke the tests
and this fixes them
2017-12-05 22:39:36 -05:00
Andrew Kelley
f464fe14f4
switch on enum which only has 1 field is comptime known
...
closes #593
2017-12-05 22:26:17 -05:00
Andrew Kelley
bb6b4f8db2
fix enum with 1 member causing segfault
...
closes #647
2017-12-05 22:15:33 -05:00
Andrew Kelley
c49ee9f632
allow union and its tag type to peer resolve to the tag type
2017-12-05 21:33:24 -05:00
Andrew Kelley
2715f6fdb8
allow implicit cast from union to its enum tag type
...
closes #642
2017-12-05 21:10:47 -05:00
Andrew Kelley
960914a073
add implicit cast from enum to union
...
when the enum is the tag type of the union and is comptime known
to be of a void field of the union
See #642
2017-12-05 20:46:58 -05:00
Andrew Kelley
63a2f9a8b2
fix casting integer literal to enum
2017-12-05 18:09:22 -05:00
Andrew Kelley
74cea89fce
translate-c: fix not printing clang errors
2017-12-05 12:28:59 -05:00
Andrew Kelley
5ebed1c9ee
fix incorrect LLVM IR for union constant when active field is void
...
found in the llvm6 branch with llvm assertions on
2017-12-04 17:10:46 -05:00
Andrew Kelley
a966275e50
rename builtin.is_big_endian to builtin.endian
...
See #307
2017-12-04 10:36:31 -05:00
Andrew Kelley
67e6d9bc30
Merge pull request #644 from Dubhead/Dubhead-fix-message-color
...
Fix the color of compiler messages for light-themed terminal.
2017-12-04 09:15:17 -05:00
MIURA Masahiro
fea016afc0
Fix the color of compiler messages for light-themed terminal.
2017-12-04 19:22:34 +09:00
Andrew Kelley
76f3bdfff8
add test for casting union to tag type of union
2017-12-04 02:12:13 -05:00
Andrew Kelley
dd3437d5ba
fix build on windows
2017-12-04 02:08:26 -05:00
Andrew Kelley
54138d9e82
add test for union with 1 void field being 0 bits
2017-12-04 02:05:33 -05:00
Andrew Kelley
084911d9b3
add test for @sizeOf on extern and packed unions
2017-12-04 02:04:08 -05:00
Andrew Kelley
942b250895
update docs regarding enums and unions
2017-12-04 01:43:06 -05:00
Andrew Kelley
05d9f07541
more tests for unions
...
See #618
2017-12-04 00:56:27 -05:00
Andrew Kelley
fce435db26
fix abi alignment of union-enums not counting tag type
...
add more tests for unions
See #618
2017-12-04 00:32:12 -05:00
Andrew Kelley
5a8367e892
rename @EnumTagType to @TagType. add tests for union-enums
...
See #618
2017-12-03 22:36:01 -05:00
Andrew Kelley
0ad1239522
rework enums and unions and their relationship to each other
...
* @enumTagName renamed to @tagName and it works on enums and
union-enums
* Remove the EnumTag type. Now there is only enum and union,
and the tag type of a union is always an enum.
* unions support specifying the tag enum type, and they support
inferring an enum tag type.
* Enums no longer support field types but they do support
setting the tag values. Likewise union-enums when inferring
an enum tag type support setting the tag values.
* It is now an error for enums and unions to have 0 fields.
* switch statements support union-enums
closes #618
2017-12-03 20:43:56 -05:00
Andrew Kelley
137c8f5e8a
ability to set tag values of enums
...
also remove support for enums with 0 values
closes #305
2017-12-02 22:32:39 -05:00
Andrew Kelley
98237f7c0b
casting between integer and enum only works via tag type
...
See #305
2017-12-02 17:12:37 -05:00
Josh Wolfe
54a0db0daf
todo: fix #639
2017-12-01 19:54:01 -07:00
Josh Wolfe
67b8b00c44
implement insertion sort. something's broken
2017-12-01 16:11:39 -07:00
Andrew Kelley
921825b4c0
Merge branch 'llvm5.0.1'
2017-12-01 13:51:53 -05:00
Andrew Kelley
cf96b6f87b
update to LLVM 5.0.1rc2
2017-12-01 13:44:28 -05:00
Andrew Kelley
bdd5241615
update c_headers to llvm 5.0.1rc2
2017-12-01 12:15:19 -05:00
Andrew Kelley
a206ef34bb
LLD patch: Fix the ASM code generated for __stub_helpers section
...
This applies 93ca847862af07632197dcf2d8a68b9b27a26d7a
from the llvm-project git monorepo to the embedded LLD.
2017-12-01 12:11:55 -05:00
Andrew Kelley
ddca67a2b9
LLD patch: workaround for buggy MACH-O code
...
This reapplies 1a1414fc42
to the embedded LLD.
2017-12-01 12:09:55 -05:00
Andrew Kelley
fa45407e78
LLD patch: Fix for LLD on linker scripts with empty sections
...
This reapplies 569cf286ff
to the embedded LLD.
2017-12-01 12:08:16 -05:00
Andrew Kelley
9ea23272fa
LLD patch: COFF: better behavior when using as a library
...
This applies de776439b61fb71c1256ad86238799c758c66048
from the LLVM git monorepo to the embedded LLD.
2017-12-01 12:06:33 -05:00
Andrew Kelley
77b530b50a
updated embedded LLD to 5.0.1rc2
2017-12-01 11:59:14 -05:00
Andrew Kelley
b4120423a5
translate-c: only emit enum tag type if not c_int or c_uint
2017-12-01 00:37:15 -05:00
Andrew Kelley
264c86853b
packed structs can have enums with explicit tag types
...
See #305
2017-12-01 00:34:29 -05:00
Andrew Kelley
b62e2fd870
ability to specify tag type of enums
...
see #305
2017-11-30 22:08:11 -05:00
Josh Wolfe
5786df933d
add mem.readIntLE and readIntBE
2017-11-30 11:20:50 -07:00
Andrew Kelley
210d0017c4
fix build broken by previous commit
...
now we report a compile error for unusual failures from translate-c
2017-11-29 23:09:35 -05:00
Andrew Kelley
7729f6cf4e
translate-c: support static incomplete array inside function
2017-11-29 21:50:38 -05:00
Andrew Kelley
716b0b8655
fix capturing value of switch with all unreachable prongs
...
closes #635
2017-11-29 21:34:17 -05:00
Andrew Kelley
ccea8dcbf6
better error code for File.getEndPos failure
2017-11-29 21:34:17 -05:00
Josh Wolfe
88a7f203f9
add Buffer.appendFormat()
2017-11-29 19:31:09 -07:00
Josh Wolfe
418b0967fc
fix os.Dir compile errors
2017-11-29 17:52:58 -07:00
Andrew Kelley
7066283004
translate-c: support const ptr initializer
2017-11-28 23:44:45 -05:00
Andrew Kelley
26096e79d1
translate-c: fix clobbering primitive types
2017-11-28 03:17:28 -05:00
Andrew Kelley
8d5c4a67a7
Merge branch 'dimenus-c-field-expr'
2017-11-28 03:00:13 -05:00
Andrew Kelley
e745544dac
translate-c: detect macros referencing field lookup
...
as fn calls which assert the fn ptr is non-null
2017-11-28 02:58:51 -05:00
Andrew Kelley
f537c51f25
Merge branch 'c-field-expr' of https://github.com/dimenus/zig into dimenus-c-field-expr
2017-11-28 00:44:16 -05:00
Andrew Kelley
1ab84a27d3
translate-c: fix sometimes getting (no file) warnings
...
Thanks to Mason Remaley for testing the fix.
2017-11-28 00:32:32 -05:00