Commit Graph

577 Commits

Author SHA1 Message Date
Tadeo Kondrak
d71f339395
stage1: disallow fields in opaque types 2020-10-06 22:08:27 -06:00
Tadeo Kondrak
2b4b03d301
Update zig files for opaque type syntax 2020-10-06 22:08:25 -06:00
Alexandros Naskos
e31cc80130
Merge pull request #6427 from tadeokondrak/enums-explicit-tag-type-extern-allowed
Allow enums with explicit extern-allowed tag types in extern types
2020-10-03 12:51:39 +03:00
Tadeo Kondrak
65016dff32
Add test for implicit extern-allowed enum tag type in extern struct 2020-10-01 18:10:20 -06:00
Tadeo Kondrak
cae49b1b9d
Add tests for enums with explicit extern-allowed tag types in extern types 2020-10-01 18:09:47 -06:00
Tadeo Kondrak
e18fdc12b0
stage1: Implement @Type for Fn and BoundFn 2020-10-01 18:01:38 -06:00
Tadeo Kondrak
e187ac09cb
Update compile error tests for alignment in StructField/UnionField 2020-10-01 15:06:21 -06:00
Tadeo Kondrak
e903b00eec
stage1: Fix @Type(.Enum) with invalid tag_type
Fixes https://github.com/ziglang/zig/issues/6459
2020-09-30 07:02:38 -06:00
Andrew Kelley
b811a99af9 Merge remote-tracking branch 'origin/master' into stage2-zig-cc 2020-09-29 14:53:48 -07:00
LemonBoy
56b52dd0a3 stage1: Detect OOB access of vector value
Fixes #5710
2020-09-28 17:16:12 +02:00
Andrew Kelley
b6556c944b fix another round of regressions in this branch
* std.log: still print error messages in ReleaseSmall builds.
   - when start code gets an error code from main, it uses std.log.err
     to report the error. this resulted in a test failure because
     ReleaseSmall wasn't printing `error: TheErrorCode` when an error
     was returned from main. But that seems like it should keep working.
     So I changed the std.log defaults. I plan to follow this up with a
     proposal to change the names of and reduce the quantity of the
     log levels.
 * warning emitted when using -femit-h when using stage1 backend; fatal
   log message when using -femit-h with self-hosted backend (because the
   feature is not yet available)
 * fix double `test-cli` build steps in zig's build.zig
 * update docgen to use new CLI
 * translate-c uses `-x c` and generates a temporary basename with a
   `.h` extension. Otherwise clang reports an error.
 * --show-builtin implies -fno-emit-bin
 * restore the compile error for using an extern "c" function without
   putting -lc on the build line. we have to know about the libc
   dependency up front.
 * Fix ReleaseFast and ReleaseSmall getting swapped when passing the
   value to the stage1 backend.
 * correct the zig0 CLI usage text.
 * update test harness code to the new CLI.
2020-09-26 21:03:38 -07:00
Tadeo Kondrak
acdf1f0bde
@Type for union fixes 2020-09-07 06:23:50 -06:00
Tadeo Kondrak
ff2ed966bb
Implement @Type for Union
This removes TypeInfo.UnionField.enum_field, which is redundant with
TypeInfo.Union.tag_type.
2020-09-07 06:23:24 -06:00
Veikka Tuominen
41bbadbb9a
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
2020-09-05 13:58:02 +03:00
Vexu
09c861b829
update rest of tests 2020-09-04 22:49:14 +03:00
Vexu
6b2f4fd20d
langref: atomic ops are allowed on pointers
Closes #6217
2020-09-04 22:02:39 +03:00
LemonBoy
c51b871c45 ir: Typecheck the sentinel value in *[N:S1]T to [S2]T casts
Closes #6054
2020-09-01 17:29:10 +02:00
Tadeo Kondrak
a2c47d2b0b
Remove @OpaqueType 2020-08-30 19:02:23 -06:00
Vexu
c1ee9efb7c
fix error note using invalid source node
Closes #6153
2020-08-24 15:24:00 +03:00
Vexu
9589dc4c95 add error checks to @Type 2020-08-24 11:13:43 +03:00
Tadeo Kondrak
c31e8701d7
Update compile-errors test for @Type(.Enum) changes 2020-08-21 15:00:23 -06:00
Tadeo Kondrak
5a5956bd20
Implement @Type for Enum 2020-08-21 14:31:24 -06:00
Andrew Kelley
9cfcd0c296
Merge pull request #6103 from Vexu/extern
Disallow extern variables with initializers.
2020-08-20 18:35:31 -04:00
Vexu
d25674a51e
disallow extern variables with initializers 2020-08-20 11:35:33 +03:00
Tadeo Kondrak
759485cc32
Update compile-errors test for @Type(.Struct) 2020-08-19 15:26:03 -06:00
Veikka Tuominen
d139e44cfa
Merge pull request #5495 from xackus/fix_5314
stage1: fix non-exhaustive enums with one field
2020-08-18 23:55:44 +03:00
Andrew Kelley
bdb8c49418 stage1: update compile error tests
follow-up to 56c81c713f
2020-08-18 08:44:34 -07:00
Ashish Shekar
27cb23cbc5
Handle singular param count word in error messages (#6073) 2020-08-17 22:18:29 -04:00
Vexu
2948f2d262
fix cast from invalid non-exhaustive enum to union 2020-08-17 20:48:22 +03:00
Vexu
1e835e0fcc
disallow '_' prong when switching on non-exhaustive tagged union
A tagged union cannot legally be initiated to an invalid enumeration
2020-08-17 20:47:31 +03:00
Andrew Kelley
2cd19c05d0 stage1: remove buggy "unable to inline function" compile error
We still want this compile error but I'm giving up on implementing it
correctly in stage1. It's been buggy and has false positives sometimes.

I left the test cases there, but commented out, so that when we go
through the stage1 compile error cases and get coverage for them in
stage2 we can reactivate the test cases.

closes #2154
2020-08-15 09:53:39 -07:00
Vexu
3734881577
add error for unused/duplicate block labels 2020-08-13 01:13:17 +03:00
Vexu
6bba7c702b add compile error for alignCasting zero sized types 2020-08-02 17:49:16 +00:00
Vexu
5f0bde6358 add helpful error note for when function cannot return an error
This has caused frequent confusion since it looks like you are handling
errors correctly with a try but you forgot to change your return type.
2020-07-28 04:24:52 +00:00
Andrew Kelley
a36772ee64
Merge pull request #5693 from antlilja/switch-unreachable-else
Add error message for unreachable else prong in switch
2020-07-26 05:46:18 +00:00
Andrew Kelley
995fd7314c Revert "Support taking extern pointers at comptime"
This reverts commit d3ebd42865.

This caused a build failure on multiple targets.
2020-07-24 14:06:44 -07:00
yvt
d3ebd42865 Support taking extern pointers at comptime
This commit makes it possible to obtain pointers to `extern` variables
at comptime.

 - `ir_get_var_ptr` employs several checks to determine if the given
   variable is eligible for obtaining its pointer at comptime. This
   commit alters these checks to consider `extern` variables, which have
   runtime values, as eligible.

 - After this change, it's now possible for `render_const_val` to be
   called for `extern` variables. This commit modifies
   `render_const_val` to suppress the value generation for `extern`
   variables.

 - `do_code_gen` now creates `ZigValue::llvm_global` of `extern`
   variables before iterating through module-level variables so that
   other module-level variables can refer to them.

This solution is incomplete since there are several cases still
failing:

 - `global_var.array[n..m]`
 - `&global_var.array[i]`
 - `&global_var.inner_struct.value`
 - `&global_array[i]`

Closes #5349
2020-07-24 13:33:17 -07:00
Vexu
78962eeeda
fix floatCast type check regression
Closes #5900
2020-07-18 10:22:15 +03:00
Vexu
dff1ac1089 check for invalid sentinel when creating pointer with @Type 2020-07-13 00:29:53 +00:00
Vexu
be1507a7af
update compile error tests and some doc comments 2020-07-12 00:54:07 +03:00
Vexu
2e037fd827 use correct cast function when doing @floatCast at comptime 2020-07-11 11:36:28 +03:00
Vexu
5667a21b1e fix missing check on extern variables with no type 2020-07-08 03:09:41 +00:00
antlilja
dcc406deff Add new error message for unreachable else prongs
* Adds error message for types: enum, int and bool
* Adds compile error tests
2020-07-01 16:09:36 +02:00
Andrew Kelley
581d16154b
Merge pull request #5696 from alexnask/async_call_tuple
@asyncCall now takes arguments as a tuple instead of varargs
2020-06-28 01:00:58 -04:00
arbrk1
78d8931647
Fix issue #5618 (#5685)
* fix issue #5618

* A test for the issue #5618 added.
Also inserted a comma in the neighboring test to make it more zigfmt-friendly.
2020-06-24 23:58:50 -04:00
Alexandros Naskos
eefcd04462 Small fixes, fixed tests, added test for argument tuple type 2020-06-24 16:56:24 +03:00
antlilja
0de35af98b Add duplicate checking for switch on types
* Add compile error tests
2020-06-23 15:17:04 -04:00
Robin Voetter
8696e52a3d
Make unary minus for unsigned types a compile error (#5654)
* Make unary minus for unsigned types a compile error

* Add unreachable when generating unsigned negate
2020-06-21 14:55:44 -04:00
Vexu
14acc65675
add tests for @src 2020-06-18 21:11:34 +03:00
Jakub Konka
8ffa8ed9a8 Expose full llvm intrinsic 2020-06-09 00:22:34 -04:00