Commit graph

869 commits

Author SHA1 Message Date
Andrew Kelley
d4bd1b1a60
Merge pull request #14618 from Vexu/fixes
small misc fixes
2023-02-13 01:58:01 -05:00
Veikka Tuominen
8127a27eb1 zig fmt: do not consider tuples blocks
Closes #14056
2023-02-11 14:36:54 +02:00
Techatrix
c63be507cf don't tokenize an invalid string literal 2023-02-11 14:25:25 +02:00
Andrew Kelley
81c27c74bc use build.zig.zon instead of build.zig.ini for the manifest file
* improve error message when build manifest file is missing
 * update std.zig.Ast to support ZON
 * Compilation.AllErrors.Message: make the notes field a const slice
 * move build manifest parsing logic into src/Manifest.zig and add more
   checks, and make the checks integrate into the standard error
   reporting code so that reported errors look sexy

closes #14290
2023-02-03 00:06:11 -07:00
Andrew Kelley
873bb29c98 introduce ZON: Zig Object Notation
* std.zig.parse is moved to std.zig.Ast.parse
 * the new function has an additional parameter that requires passing
   Mode.zig or Mode.zon
 * moved parser.zig code to Parse.zig
 * added parseZon function next to parseRoot function
2023-02-03 00:06:11 -07:00
Andrew Kelley
6b7ad22981
Merge pull request #14477 from Vexu/fixes
Improve `@ptrCast` errors, fix some bugs
2023-02-01 23:31:52 -05:00
Veikka Tuominen
f16c10a86b implement @qualCast 2023-01-30 18:55:57 +02:00
Techatrix
885d696895 zig fmt: fix file ending in a multi line comment 2023-01-30 00:42:05 +02:00
Andrew Kelley
ac28bedbee
Merge pull request #14418 from ifreund/assume-sentinel-sux
std: eliminate pointless meta.assumeSentinel() usage
2023-01-23 21:01:54 -05:00
Isaac Freund
faf2fd18d3
std: eliminate pointless meta.assumeSentinel() usage
This fixes a bug in std.net caused during the introduction of
meta.assumeSentinel due to the unfortunate semantics of mem.span()

This leaves only 3 remaining uses of meta.assumeSentinel() in the
standard library, each of which could be a simple @ptrCast([*:0]T, foo)
instead. I think this function should likely be removed.
2023-01-23 12:19:53 +01:00
Jan Philipp Hafer
55e879d2ed std.os.windows: add possible error NETNAME_DELETED of ReadFile
Closes #13631
2023-01-23 02:07:12 -05:00
Marco Munizaga
d87a58dfab Add framework paths from NIX_CFLAGS_COMPILE 2023-01-19 16:57:55 +02:00
Veikka Tuominen
841b38aae8 tokenizer: detect null as non-first byte of a line comment
Line comments do not produce actual tokens so they need special
handling for null bytes.

Closes #14346
2023-01-17 20:39:19 +02:00
Veikka Tuominen
e2adf3b61a parser: add helpful note for missing const/var before container level decl
Closes #13888
2023-01-11 21:11:21 +02:00
Techatrix
1f8f79cd53
std: add helper functions to std.zig.Ast for extracting data out of nodes 2023-01-09 16:59:19 +02:00
Andrew Kelley
72560b8db5 add some comments to explain workarounds 2023-01-02 14:08:50 -07:00
kcbanner
ccf0ab0ef6 cbe: use callconv(.C) for zig.g stub functions, use zig.h function for windows teb instead of syscall 2023-01-02 13:56:11 -07:00
kcbanner
6cab3c304e cbe: be more explicit about x86 special cases 2023-01-02 13:55:45 -07:00
kcbanner
676e4f3824 cbe: changes to get zig2.c compiling under msvc
- Add cpuid / getXCR0 functions for the cbe to use instead of asm blocks
- Don't cast between 128 bit types during truncation
- Fixup truncation to use functions for shifts / adds
- Fixup float casts for undefined values
- Add test for 128 bit integer truncation
2023-01-01 16:44:29 -05:00
Manlio Perillo
f8f1c6ac06 parser: ensure the documented grammar matches grammar.y
Move the parsing of Root from the parse function to the Parser.parseRoot
method.

Add an empty line between each rule, for consistency with grammar.y.

Ensure that normal doc-comments are always on the top, for consistency.

Add extract-grammar.zig to the tools directory; it is used to extract
the PEG grammar from parse.zig, so that it can be compared with
grammar.y.
2022-12-30 17:11:59 +02:00
Veikka Tuominen
8a6295fcba AstGen: make type sentinel expressions implicitly comptime 2022-12-29 12:43:02 +02:00
Veikka Tuominen
622311fb9a update uses of overflow arithmetic builtins 2022-12-27 15:13:14 +02:00
Veikka Tuominen
af9a9a1374 zig fmt: improve handling of comptime tuple fields 2022-12-27 13:52:37 +02:00
Veikka Tuominen
0b859831ad update grammar in langref
Closes #14072
2022-12-26 16:36:29 +02:00
travisstaloch
581d292381
fix overflow found while fuzzing
* allow file level `union {}` to parse as tuple field

this was found while fuzzing zls.

* before this patch the input `union {}` crashed the parser.  after
  this, it parses correctly just like `struct {}`.
* adds behavior tests for both inputs `struct {}` and `union {}`,
  checking that each becomes a file level tuple field.
2022-12-23 23:10:04 +02:00
travisstaloch
4aa8462cc9
std.zig: fix integer overflows during parsing
these were found while fuzzing zls.

this patch prevents overflow for the following file contents and adds
tests for them.
	* `enum(u32)` - causes overflow in std.zig.Ast.fullContainerDecl()
	* `*x` - causes overflow in std.zig.Ast.fullPtrType()
	* `**x` - causes overflow in std.zig.Ast.firstToken()
2022-12-20 17:33:40 +02:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
Techatrix
4809e0ea7f
fix potential integer underflow in std.zig.Ast.fullCall 2022-12-18 04:59:43 +00:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
yujiri8
68d2f68ed8
zig fmt: fix extra whitespace with multiline strings
Fixes #13937
2022-12-17 00:24:58 +02:00
Veikka Tuominen
014009a730 parser: fix usage of incorrect error tag
Closes #13921
2022-12-14 14:08:22 +02:00
yujiri8
d36cd49f0b
zig fmt: remove c_void -> anyopaque rewrite
TODO comments said to remove this
2022-12-12 10:46:28 +01:00
r00ster91
6b7d9b34e8 api(std.ascii): remove deprecated decls 2022-12-09 21:57:17 +01:00
Veikka Tuominen
6039554b26 tokenizer: detect null bytes before EOF
Closes #13811
2022-12-08 00:16:30 +02:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Andrew Kelley
b7b905d227 add behavior test for while(true) not needing else unreachable
closes #707
2022-12-06 17:57:27 -07:00
Jakub Konka
5eaacf1ce9 windows: use array of tmp bufs as backing store for input memory to ntdll 2022-12-02 12:24:15 -05:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Andrew Kelley
b8473ae7d3
Merge pull request #13693 from Vexu/safety
Safety panic improvements & some bug fixes
2022-11-29 19:59:55 -05:00
Jakub Konka
9d0ea0e3f1 arm: implement CPU feature detection by parsing system registers
Also add an incomplete table implementing instruction fusions according
to official optimisation programming manuals.
2022-11-29 19:24:42 +01:00
Jakub Konka
988fff260e windows: map CP 40xx registry values to system ID registers 2022-11-29 19:24:42 +01:00
Jakub Konka
152202da77 windows: if detecting CPU feature set and model fails, use generic with overrides 2022-11-29 19:24:42 +01:00
Veikka Tuominen
34be5784a3 parser: disallow defer and variable declaration as else branch
Closes #13658
2022-11-29 15:47:02 +02:00
Jakub Konka
7bf12b1197 arm: move cpu model table into system/arm.zig
Now we can reuse the table between CPU model parsers on Linux and
Windows.

Use similar parsing structure for Windows as we do for Linux. On
Windows, we rely on two entries in the registry per CPU core:
`CP 4000` and `Identifier`. Collating the data from the two allows
us recreating most of the `/proc/cpuinfo` data natively on Windows.
Additionally, we still allow for overwriting any CPU features as flagged
by pulling the feature data embedded in `SharedUserData`.
2022-11-28 17:07:35 +01:00
Jakub Konka
7fbd2955fa windows: pull QWORD and SZ identifiers from registry in one syscall
At the same time, do not assume the values necessarily exist, and
use defaults as markers for the lack of keys in the registry.
2022-11-28 17:07:34 +01:00
Jakub Konka
d64d7aaac7 windows: drive the registry helper with actual value set for reg entries 2022-11-28 17:07:34 +01:00
Jakub Konka
57bda6524b windows: make registry helper generic over value types 2022-11-28 17:07:34 +01:00
Jakub Konka
49ce86bddf windows: fix logic for pulling info for each core 2022-11-28 17:07:34 +01:00
Jakub Konka
7473ef98e9 windows: implement simplistic CPU model parser 2022-11-28 17:07:34 +01:00
Jakub Konka
7ea2c7fbcd windows: use RtlQueryRegistryValues to query reg in a single syscall 2022-11-28 17:07:34 +01:00