Commit Graph

55 Commits

Author SHA1 Message Date
Andrew Kelley
011df61f8a fix not verifying GlobalLinkage and AtomicOrder types
thanks to aep4Ayai on IRC
2017-09-10 14:04:19 -04:00
Andrew Kelley
bc0a60c7a6 more compile errors for non-const variables of things
closes #456
2017-09-09 22:46:08 -04:00
Andrew Kelley
3ff465e288 add OpaqueType builtin
closes #326
2017-09-05 18:51:07 -04:00
Andrew Kelley
c42e809f13 setEvalBranchQuota must be called from top of comptime stack 2017-08-31 16:54:20 -04:00
Andrew Kelley
67b6dd28ec allow array literals to have size and fix comptime bug 2017-08-31 16:30:46 -04:00
Andrew Kelley
052b4ae941 align syntax: align(4) instead of align 4
closes #37
2017-08-30 04:54:33 -04:00
Andrew Kelley
e9280c86a1 compile error for not-aligned-enough pointer to cmpxchg
See #37
2017-08-30 02:56:42 -04:00
Andrew Kelley
b35dad88b4 add tests for function alignment handling
See #37
2017-08-30 00:06:14 -04:00
Andrew Kelley
898d65baa9 more alignment improvements
* add alignment capability for fn protos
 * add @alignCast
 * fix some ast rendering code
 * fix some ir rendering code
 * add error for pointer cast increasing alignment
 * update allocators in std to correctly align

See #37
2017-08-29 23:33:25 -04:00
Andrew Kelley
910a96f046 fix tests 2017-08-29 17:10:11 -04:00
Andrew Kelley
816689a3b1 ptrCast gives compile error for increasing alignment
See #37
2017-08-29 16:52:31 -04:00
Andrew Kelley
be94299666 prevent implicitly increasing pointer alignment
See #37
2017-08-29 15:19:15 -04:00
Andrew Kelley
c5c9d98065 introduce align keyword
* remove `@setGlobalAlign`
 * add align keyword for setting alignment on functions and
   variables.
 * loads and stores use alignment from pointer
 * memcpy, memset use alignment from pointer
 * add syntax for pointer alignment
 * slices can have volatile
 * add u2, i2 primitives
 * ignore preferred align and use abi align everywhere
 * back to only having alignOf builtin.
   preferredAlignOf is too tricky to be useful.
   See #432. Partial revert of
   e726925e80.

See #37
2017-08-29 07:51:34 -04:00
Andrew Kelley
cd2f65ff6a add compile error for globally shadowing a primitive type
closes #423
2017-08-19 02:02:25 -04:00
Andrew Kelley
987768778a bit shifting safety
* add u3, u4, u5, u6, u7 and i3, i4, i5, i6, i7
 * shift operations shift amount parameter type is
   integer with log2 bit width of other param
   - This enforces not violating undefined behavior on
     shift amount >= bit width with the type system
 * clean up math.log, math.ln, math.log2, math.log10

closes #403
2017-08-19 01:43:43 -04:00
Andrew Kelley
35d3444e27 more intuitive left shift and right shift operators
Before:
 * << is left shift, not allowed to shift 1 bits out
 * <<% is left shift, allowed to shift 1 bits out
 * >> is right shift, allowed to shift 1 bits out

After:
 * << is left shift, allowed to shift 1 bits out
 * >> is right shift, allowed to shift 1 bits out
 * @shlExact is left shift, not allowed to shift 1 bits out
 * @shrExact is right shift, not allowed to shift 1 bits out

Closes #413
2017-08-09 10:09:38 -04:00
Andrew Kelley
54675b060a add ptrToInt builtin, remove usize(ptr) cast
closes #415
2017-08-08 17:38:25 -04:00
Andrew Kelley
2234788fa8 add ability to explicitly cast float to integer
closes #414
2017-08-07 15:57:41 -04:00
Marc Tiehuis
0705b711f8 Correct floating-point literal allowed ranges
The exponent range for floating-point values is [-1022, 1023].

Fixes #399.
2017-08-07 18:08:09 +12:00
Andrew Kelley
ad9f48b74b fix initializing undefined and crash when casting to invalid type
closes #408
2017-08-05 16:54:50 -04:00
Andrew Kelley
6a93dda3e1 progress toward windows hello world working 2017-06-14 00:04:34 -04:00
Andrew Kelley
e5b90651ba compileError builtin includes "referenced by" notes
to help track down the cause

closes #278
2017-06-03 15:09:40 -04:00
Andrew Kelley
c42c91ee7c fix segfault with array of generic functions
closes #377
2017-05-26 14:39:18 -04:00
Andrew Kelley
fcdd808c5c fix segfault with array of variadic functions
closes #377
2017-05-25 13:48:10 -04:00
Andrew Kelley
1c8fee41c2 add compile error for goto leaving defer expression
closes #284
2017-05-21 10:59:09 -04:00
Andrew Kelley
9f3cca8615 add error for break/continue exiting defer expression
See #284
2017-05-21 10:44:55 -04:00
Andrew Kelley
1c6f415a64 fix compiler crash when indexing types
closes #376
2017-05-21 09:50:15 -04:00
Andrew Kelley
29b488245d add setFloatMode builtin and std.math.floor
* skip installing std/rand_test.zig as it's not needed beyond running
   the std lib tests
 * add std.math.floor function
 * add setFloatMode builtin function to choose between
   builtin.FloatMode.Optimized (default) and builtin.FloatMode.Strict
   (Optimized is equivalent to -ffast-math in gcc)
2017-05-20 23:06:32 -04:00
Andrew Kelley
051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley
9851a943ed add compile error for compile-time integer cast truncating bits
closes #371
2017-05-16 17:04:35 -04:00
Andrew Kelley
a7570186eb add compile error for comptime division by zero
closes #372
2017-05-14 13:07:45 -04:00
Andrew Kelley
63f6676fee add compile error for casting negative value to...
...unsigned integer at compile-time
2017-05-10 00:21:27 -04:00
Andrew Kelley
7261cd19b7 detect duplicate switch value even when else prong present
closes #43
2017-05-07 13:40:35 -04:00
Andrew Kelley
818a0a2629 switch expression - add compile errors
* for duplicate integer value
   * for missing integer values
   * for missing else prong

see #43
2017-05-07 12:07:35 -04:00
Andrew Kelley
29beb603b7 allow division and remainder operators sometimes
when the values are comptime known and the result would be the same,
allow `/` and `%` for signed integers and floats.

closes #365
2017-05-06 23:59:57 -04:00
Andrew Kelley
157af4332a builtin functions for division and remainder division
* add `@divTrunc` and `@divFloor` functions
 * add `@rem` and `@mod` functions
 * add compile error for `/` and `%` with signed integers
 * add `.bit_count` for float primitive types

closes #217
2017-05-06 23:13:12 -04:00
Andrew Kelley
866c841dd8 add compile error when unable to inline a function
See #38
2017-05-04 15:11:24 -04:00
Andrew Kelley
20b1491e6b implement while for nullables and error unions
See #357
2017-05-04 10:28:00 -04:00
Andrew Kelley
698829b772 change while syntax
Old:

```
while (condition; expression) {}
```

New:

```
while (condition) : (expression) {}
```

This is in preparation to allow nullable and
error union types as the condition. See #357
2017-05-03 18:12:07 -04:00
Andrew Kelley
644ea2dde9 remove test and try expressions in favor of if expressions
See #357
2017-05-03 17:23:11 -04:00
Andrew Kelley
0940d46c01 add compile error for shadowing variable
closes #360
2017-05-03 16:13:57 -04:00
Andrew Kelley
6756c27ca4 zig build: cache_root is relative to build_root 2017-05-03 16:13:57 -04:00
Andrew Kelley
17b935325e @import("builtin") instead of @compileVar
See #226
Closes #220
2017-05-01 13:12:38 -04:00
Andrew Kelley
458afb0ef9 phi instruction retains stack ptr hint 2017-04-27 23:40:43 -04:00
Andrew Kelley
2e512a0e6e add compile error for returning local variable address
closes #344
2017-04-27 19:40:35 -04:00
Josh Wolfe
08a871f625 defer requires expr to be void. closes #341 2017-04-23 22:33:06 -07:00
Josh Wolfe
ac7971122d fix check-statement-is-void. add tests
see #291
2017-04-23 21:50:34 -07:00
Josh Wolfe
c6605cba83 blocks check that their statements are void
closes #291

This changes the error message "return value ignored" to "expression value is ignored".
This is because this error also applies to {1;}, which has no function calls.

Also fix ignored expression values in std and test.
This caught a bug in debug.readAllocBytes where an early Eof error would have been missed.
See #219.
2017-04-23 21:15:15 -07:00
Josh Wolfe
14dfbd6ad3 remove redundant unreachable code error 2017-04-23 08:36:21 -07:00
Andrew Kelley
ad9040443c new compile errors for setGlobalAlign and setGlobalSection builtins
if you try to use them on an external variable or function
then you get a compile error, since the alignment/section
is set externally in this case.

closes #244
2017-04-22 12:54:00 -04:00