Commit Graph

4753 Commits (8ce130de3cf38e09cfbcbd1b22da34ae5b27a040)

Author SHA1 Message Date
Andrew Kelley 99b19adeb3 stage2: fix windows regressions 2019-02-14 23:46:53 -05:00
Andrew Kelley 71d7100aa8 darwin: fix pointer cast in mmap 2019-02-14 23:38:14 -05:00
Marc Tiehuis 170ec504ec Use official llvm mirror for compiler-rt commit ref 2019-02-15 17:37:55 +13:00
Marc Tiehuis 18ad50970f Make parseFloat stricter in what it accepts as input 2019-02-15 17:32:13 +13:00
Andrew Kelley e025c70166
stage2: fix llvm.zig with opaque types back to single-item pointer 2019-02-14 23:17:11 -05:00
Andrew Kelley d6e0d82c32
translate-c: back to *c_void for opaque types
See #1059
2019-02-14 23:09:31 -05:00
Andrew Kelley d5bbd74871
allow C pointers to have alignment
clang/gcc support pointer alignment attribute:
https://clang.llvm.org/docs/AttributeReference.html#align-value
2019-02-14 20:04:13 -05:00
Andrew Kelley cc7060d0d9
compile error for C pointer with align attribute
See #1059
2019-02-14 20:02:29 -05:00
Andrew Kelley 973a93d43b
add docs for C pointers 2019-02-14 19:03:04 -05:00
Andrew Kelley df87044fd6
omit nonnull attribute for C pointers
See #1059
2019-02-14 16:10:12 -05:00
Andrew Kelley 6769183a9d
fix implicit cast error unions with non-optional to optional pointer
and update self hosted compiler for C pointers

See #1059
2019-02-14 15:48:28 -05:00
Andrew Kelley 52c03de5c2
add missing compile error for OpaqueType inside structs/unions
closes #1862
2019-02-14 13:07:51 -05:00
Andrew Kelley e03c770145
compile error tests for implicit C pointer casting
See #1059
2019-02-14 12:28:50 -05:00
Andrew Kelley c58b802034
remove the "top of the comptime stack" compile error
It's still best practice to put `@setEvalBranchQuota` at the top of
the comptime stack, but as Jimmi notes in #1949, when a function
can be called at comptime and also can be the top of the comptime stack,
this compile error is fundamentally unsound.

So now it's gone.

closes #1949
2019-02-14 10:51:59 -05:00
Andrew Kelley a4e32d9fb1
ci: freebsd: remove '.git' from URL as per upstream suggestion
https://todo.sr.ht/~sircmpwn/dispatch.sr.ht/24#comment-1465
2019-02-14 09:46:08 -05:00
Andrew Kelley 59de24817e
runtime safety check for casting null to pointer
see #1059
2019-02-14 01:09:33 -05:00
Andrew Kelley d4d2718bca
comptime detection of casting null to pointer
See #1059
2019-02-14 00:40:39 -05:00
Jimmi Holst Christensen 2911eb34de Added error for nesting vectors 2019-02-13 12:19:08 +01:00
Marc Tiehuis de7c55145a Add parseFloat support to json.zig 2019-02-14 00:12:00 +13:00
Marc Tiehuis c34ce6878e Add parseFloat to std.fmt
This is not intended to be the long-term implementation as it doesn't
provide various properties that we eventually will want (e.g.
round-tripping, denormal support). It also uses f64 internally so the
wider f128 will be inaccurate.
2019-02-14 00:07:51 +13:00
Jimmi Holst Christensen 53297a1bd0 We already support vector bit operators, so let's test it 2019-02-13 11:40:32 +01:00
Jimmi Holst Christensen c7b9ab985c Merge branch 'master' of github.com:ziglang/zig 2019-02-13 11:31:20 +01:00
Jimmi Holst Christensen c221b29c9d We already support vector on floats, so let's test it 2019-02-13 11:31:13 +01:00
Marc Tiehuis cf007e37b9 Add f128 support for fabs, isinf, isnan, inf and nan functions 2019-02-13 23:27:23 +13:00
Marc Tiehuis be861a85c8 compiler-rt: Add __addtf3, __subtf3 and __truncdfhf2
Allows addition/subtraction of f128 and narrowing casts to f16 from
larger float types.
2019-02-13 23:24:52 +13:00
Matthew McAllister 0b3db784f1 Enable compileLog to display slices 2019-02-13 02:00:02 -05:00
Andrew Kelley 5699ab5e77
C pointers: errors for nested pointer casting regarding null
See #1059
2019-02-12 18:20:00 -05:00
Andrew Kelley 270933b1e9
compile error test for casting integer to c pointer
when the int has more bits than pointers

See #1059
2019-02-12 10:25:21 -05:00
Andrew Kelley 6f05e8d1be
implicit casting between C pointer and optional non-C pointer
See #1059
2019-02-12 01:38:11 -05:00
Andrew Kelley 285e2f62ba
disallow C pointers to non-C-ABI-compatible element types
See #1059
2019-02-12 00:51:06 -05:00
Andrew Kelley 0abe6d668e
C pointers: delete dead code in ir_num_lit_fits_in_other_type 2019-02-12 00:39:08 -05:00
Andrew Kelley 069fc1a269
peer type resolution with C pointers
See #1059
2019-02-11 19:21:59 -05:00
Andrew Kelley 57a7ab0d33
comptime support for pointer arithmetic with hard coded addresses 2019-02-11 19:12:01 -05:00
Andrew Kelley 90b8cd4a45
add C pointer type to @typeInfo
See #1059
2019-02-11 16:07:40 -05:00
Andrew Kelley 342bca7f46
C pointer comparison and arithmetic
See #1059
2019-02-11 15:31:09 -05:00
Andrew Kelley d9e01be973
translate-c: use C pointer type everywhere
See #1059
2019-02-11 14:56:59 -05:00
Andrew Kelley 4a1b910e03
zig fmt: support C pointers
See #1059
2019-02-11 14:07:19 -05:00
Andrew Kelley 43df49cb35
README: move i386-macosx to Tier 4
See #1930
2019-02-11 12:59:33 -05:00
Andrew Kelley 661fc79fba
langref: update grammar with c pointers
See #1059
2019-02-10 12:02:56 -05:00
Andrew Kelley 7a8f391b0f
avoid needlessly creating global constants
This deletes some legacy cruft, and produces leaner object files.
Example:

```
var x: i32 = 1234;

export fn entry() i32 {
    return x;
}
```

This produces:

```
@x = internal unnamed_addr global i32 1234, align 4
@0 = internal unnamed_addr constant i32* @x, align 8
```

and @0 is never even used. After this commit, @0 is not produced.

This fixes a bug: Zig was creating invalid LLVM IR when one of these
globals that shouldn't exist takes the address of a thread local
variable. In LLVM 8.0.0rc2, it would produce a linker error. But
probably after my bug report is solved it will be caught by the IR
verifier.

https://bugs.llvm.org/show_bug.cgi?id=40652
2019-02-10 11:07:00 -05:00
Andrew Kelley bcbcb2e9ff
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-10 11:03:17 -05:00
Andrew Kelley 8e68d43ad3
avoid needlessly creating global constants
This deletes some legacy cruft, and produces leaner object files.
Example:

```
var x: i32 = 1234;

export fn entry() i32 {
    return x;
}
```

This produces:

```
@x = internal unnamed_addr global i32 1234, align 4
@0 = internal unnamed_addr constant i32* @x, align 8
```

and @0 is never even used. After this commit, @0 is not produced.

This fixes a bug: Zig was creating invalid LLVM IR when one of these
globals that shouldn't exist takes the address of a thread local
variable. In LLVM 8.0.0rc2, it would produce a linker error. But
probably after my bug report is solved it will be caught by the IR
verifier.

https://bugs.llvm.org/show_bug.cgi?id=40652
2019-02-10 10:58:00 -05:00
Jimmi HC 2f9fedabf0 testing.expectEqual use expected type as the type of actual
This allows for impl casts
2019-02-10 12:43:49 +01:00
Andrew Kelley 73e8e46257
casting between C pointers and normal pointers
See #1059
2019-02-10 01:11:40 -05:00
Andrew Kelley b8cbe3872e
added C pointer type and implicit int-to-ptr for this type
See #1059
2019-02-10 00:14:30 -05:00
Andrew Kelley caf672c495
`@truncate`: comptime 0 when target type is 0 bits
also if the dest type is a comptime_int, then treat it
as an implicit cast.

also compile error for attempting to truncate undefined

closes #1568
2019-02-09 21:38:34 -05:00
Andrew Kelley 31be1ddf09
docs: add threadlocal keyword to grammar 2019-02-09 20:57:45 -05:00
Andrew Kelley 34eb9f18ac
fix not updating debug info type of optional error sets
There's an unfortunate footgun in the current design of error sets.
The debug info type for every error set is the same as the debug info
type of the global error set, which is essentially an enum forward
declaration. The problem is that when we "replace" the forward
declaration with the final value, once we know all the possible errors,
we have to update the pointers of every error set.

So the footgun is that if you ever copy the debug info type of the
global error set, you have to add the address of the pointer to a list
of pointers that need to be updated once we "replace" the forward
declaration. I activated the footgun when I introduced the optimization
that `?anyerror` types are the same size as `anyerror` types (using 0 as
the null value), because I introduced a pointer copy of the global error
set debug info type, but forgot to add it to the list.

I'm sure that there is a better way to code this, which does not have
the footgun, but this commit contains only a fix, not a reworking of the
logic.

closes #1937
2019-02-09 20:41:26 -05:00
Andrew Kelley 1864acd326
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-09 18:57:39 -05:00
Andrew Kelley ca8580ece1
Merge branch 'vector-int-add-safety' 2019-02-09 16:24:41 -05:00