Commit Graph

4279 Commits

Author SHA1 Message Date
Andrew Kelley
1066004b79
better handling of arrays in packed structs
* Separate LoadPtr IR instructions into pass1 and pass2 variants.
 * Define `type_size_bits` for extern structs to be the same as
   their `@sizeOf(T) * 8` and allow them in packed structs.
 * More helpful error messages when trying to use types in
   packed structs that are not allowed.
 * Support arrays in packed structs even when they are not
   byte-aligned.
 * Add compile error for using arrays in packed structs when the
   padding bits would be problematic. This is necessary since
   we do not have packed arrays.

closes #677
2019-02-21 14:44:14 -05:00
Andrew Kelley
2bb795dc45
@sliceToBytes works at comptime
closes #262
2019-02-21 10:07:11 -05:00
Andrew Kelley
db31c2524d
extern structs support comptime bitcasting 2019-02-21 08:46:43 -05:00
Andrew Kelley
3ee9d06cbd
packed structs support comptime bitcasting
* `type_size_store` is no longer a thing. loading and storing a pointer
   to a value may dereference up to `@sizeOf(T)` bytes, even for
   integers such as `u24`.
 * fix `types_have_same_zig_comptime_repr` to not think that the
   same `ZigTypeId` means the `ConstExprValue` neccesarily has the
   same representation.
 * implement `buf_write_value_bytes` and `buf_read_value_bytes` for
   `ContainerLayoutPacked`

closes #1120
2019-02-20 22:40:41 -05:00
Andrew Kelley
079728752e
deduplicate compile errors for undeclared identifiers
closes #111
2019-02-20 08:04:46 -05:00
Andrew Kelley
067968c57f
Merge branch 'matthew-mcallister-slice-deref-failure' 2019-02-19 15:35:00 -05:00
Andrew Kelley
c8ce351ec9
pull request fixups 2019-02-19 15:34:44 -05:00
Andrew Kelley
1034af40f9
Merge branch 'slice-deref-failure' of https://github.com/matthew-mcallister/zig into matthew-mcallister-slice-deref-failure 2019-02-19 15:27:10 -05:00
LemonBoy
400006bbe7 Prevent crash in tagged enums rendering (#1986)
* Prevent crash in tagged enums rendering

* Add a test case
2019-02-19 15:18:57 -05:00
Andrew Kelley
db74832e40
valgrind client requests for undefined values
with this change, when you assign undefined, zig emits a few
assembly instructions to tell valgrind that the memory is undefined

it's on by default for debug builds, and disabled otherwise. only
support for linux, darwin, solaris, mingw on x86_64 is currently
implemented.

--disable-valgrind turns it off even in debug mode.
--enable-valgrind turns it on even in release modes.

It's always disabled for compiler_rt.a and builtin.a.

Adds `@import("builtin").valgrind_support` which lets code know
at comptime whether valgrind client requests are enabled.

See #1989
2019-02-19 12:07:56 -05:00
Andrew Kelley
c9fb5240d6
remove --no-rosegment workaround now that valgrind bug is fixed
See #896

Zig 0.3.0+ and Valgrind 3.14+ do not need the workaround.
2019-02-19 08:39:36 -05:00
Andrew Kelley
007a260cda
Merge branch 'kristate-zig-backport-issue1944' 2019-02-18 18:12:02 -05:00
Andrew Kelley
ea3d9d5c53
add test for 74bdc1d1f8 2019-02-18 18:11:30 -05:00
Andrew Kelley
b0ceea1831
zig fmt: fix infix operator before multiline string literal 2019-02-18 18:11:12 -05:00
kristopher tate
74bdc1d1f8
src/analyze.cpp: default to using param_node upon callconv error; 2019-02-18 17:57:24 -05:00
John Schmidt
99adda9df5 Some function doc tweaks (#1961)
* Add docs for the inline function attribute

* Remove outdated comment

Seems like a leftover from when implicit returns were around.

* Consistent terminology
2019-02-18 17:53:41 -05:00
Andrew Kelley
043090020f
docs: shadowing
closes #1245
2019-02-18 17:49:26 -05:00
Andrew Kelley
8922008dec
docs: note top level declarations are order-independent
closes #1244
2019-02-18 17:41:55 -05:00
Andrew Kelley
28bf768883 export _mh_execute_header with weak linkage
* also fix extern variables with initialiaztion values to generate runtime code
 * remove the workaround in example/shared_library/mathtest.zig
 * introduce the ability for global variables to have Weak and LinkOnce
   linkage
 * fix `@export` to work for non-functions. this code needs to be
   audited though.
 * fix comptime ptrcast not keeping bigger alignment
 * fix linker warnings when targeting darwin

closes #1903
2019-02-18 16:47:30 -05:00
Andrew Kelley
74a335c4cc
Merge branch 'emekoi-fix-1711' 2019-02-18 13:12:03 -05:00
Andrew Kelley
7a84fe79b9
pull request fixups 2019-02-18 13:05:26 -05:00
emekoi
9b3013d2f6
make @enumToInt work on union(enum)
closes #1711
2019-02-18 11:43:45 -05:00
Jimmi HC
d2fb95af88 Fixed std.testing.expectEqual 2019-02-18 17:22:14 +01:00
LemonBoy
e280dce30f Translate parameterless C functions (#1978)
Both FunctionNoProto and FunctionProto are subclasses of FunctionType,
the only difference is that the former is parameterless.
2019-02-18 10:26:45 -05:00
LemonBoy
7d762648a4 Add align attribute for params pointers 2019-02-18 09:52:18 -05:00
Andrew Kelley
74d9593d85
README: add NetBSD to support table 2019-02-18 00:13:18 -05:00
Andrew Kelley
3e586264e5
Merge pull request #1972 from coypoop/netbsd
Add NetBSD support
2019-02-18 00:10:31 -05:00
Andrew Kelley
39207fa1d4
Merge pull request #1963 from matthew-mcallister/dedup-compile-log-warning
Deduplicate compile log statement warnings
2019-02-17 23:53:43 -05:00
Quetzal Bradley
7e54954052 fix openWriteNoClobber and add test 2019-02-17 23:21:45 -05:00
Matthew McAllister
c70ee9177e Check for duped error messages in compile tests 2019-02-17 15:33:28 -08:00
Matthew McAllister
51783510b9 Deduplicate compile log statement warnings 2019-02-17 14:02:37 -08:00
Maya Rashish
b93405c24b Don't provide a bogus definition of EVFILT_USER 2019-02-17 23:50:30 +02:00
Andrew Kelley
de18ece294
Merge pull request #1975 from BenoitJGirard/master
Fix std.math.powi so powi(x, +-0) = 1 for any x.
2019-02-17 15:00:17 -05:00
Benoit Jauvin-Girard
fcf65f06c4 Fix std.math.powi so powi(x, +-0) = 1 for any x. 2019-02-17 14:52:40 -05:00
LemonBoy
6cf38369d2 Silence gcc8 class-memaccess warnings
Use an explicit cast to tell gcc we know what we're doing.
2019-02-17 14:40:01 -05:00
BenoitJGirard
6daa041932
Merge pull request #2 from ziglang/master
Refreshing fork.
2019-02-17 14:38:55 -05:00
Maya Rashish
2878efee86 Undo local, unneeded patch 2019-02-17 14:14:17 +02:00
Maya Rashish
8d2a902945 freebsd: fix pointer cast in mmap 2019-02-17 02:25:37 -05:00
Maya Rashish
bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley
db9c1b0528
Merge branch 'sjdh02-master' 2019-02-17 00:33:43 -05:00
Andrew Kelley
4a0bb62584
fixups 2019-02-17 00:29:58 -05:00
sjdh02
fd61a084e4 fix BufferedInStream not reading delayed input 2019-02-16 21:19:49 -06:00
Matthew McAllister
91989e70ba Fix lvalue dereference type checking
Previously, if a dereference instruction was an lvalue, it would fail to
typecheck that the value being dereferenced was indeed a pointer.
Although a little clunky, this change obviates the need for redundant
type checks scattered about the analysis.
2019-02-16 17:37:47 -08:00
Andrew Kelley
c3c92ca8b1
translate-c: 4 more functions using C decls
See #1964
2019-02-16 19:48:39 -05:00
Andrew Kelley
2dfa76a1a7 fix regressions from previous commit when building with clang 2019-02-16 16:17:30 -05:00
Andrew Kelley
356cfa08f4
translate-c: proof of concept for transitioning to userland
See #1964
2019-02-16 15:26:44 -05:00
Andrew Kelley
bd52d81dc3
README: direct link to Download & Documentation at the top 2019-02-16 14:36:52 -05:00
Andrew Kelley
f4c5bcfea5
refactor translate-c - no more using namespace clang
this is in preparation for #1964
2019-02-16 14:09:00 -05:00
Andrew Kelley
f57182456d
Merge pull request #1898 from Sahnvour/translate-c-arrays
Translate c arrays
2019-02-16 14:07:41 -05:00
Andrew Kelley
a97362e677
fmt_runner: remove redundant check 2019-02-16 12:24:02 -05:00