Commit Graph

245 Commits

Author SHA1 Message Date
Vexu
c27a8bd6be
translate-c: don't crash on complex switches 2020-06-04 14:22:27 +03:00
Andrew Kelley
03dd1fca94
Merge pull request #5195 from tadeokondrak/opaquetype-to-type-opaque
@OpaqueType -> `@Type(.Opaque)
2020-04-28 16:21:07 -04:00
Tadeo Kondrak
0cf129689e
Fix/add translate-c tests for previous commit 2020-04-28 08:45:52 -06:00
Tadeo Kondrak
17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
Vexu
a016fb8c62
translate-c: correct invalid shortcut 2020-04-15 15:14:10 +03:00
Auguste Rame
df14578c9d
Merge branch 'master' into nameless-fields 2020-04-10 11:49:50 -04:00
Lachlan Easton
d7902707bc
Translate C: Allow casting literal ints to pointers 2020-04-08 14:11:01 -04:00
Vexu
7b5fb79b5b
Translate C: Put an alignCast in c style pointer casts to allow opaque types to cast properly in C macros
Translate C: add test case for aligning opaque types in pointer casts
2020-04-08 14:11:01 -04:00
SuperAuguste
116c76cf82 fix tests 2020-04-07 15:19:28 -04:00
SuperAuguste
882aa86843 more fixes 2020-04-07 15:08:46 -04:00
Vexu
c5ced0d74a
Merge pull request #4939 from SuperAuguste/master
translate-c: Properly translate C multicharacter literals
2020-04-06 10:31:17 +03:00
SuperAuguste
6106cf4419 fixes 2020-04-05 19:06:43 -04:00
Jadon Fowler
391ee996a5 translate-c: account for signedness when translating div & mod
Signed-off-by: Jadon Fowler <j@jadon.io>
2020-04-04 02:16:30 -04:00
Jadon Fowler
b9cb1e0d83 translate-c: add tests for div & rem assignment
Signed-off-by: Jadon Fowler <j@jadon.io>
2020-04-01 14:28:21 -04:00
Layne Gustafson
a55897106e Add macro string concat tests 2020-03-28 20:40:26 -04:00
Vexu
02c491e42a
translate-c fix order of tokens 2020-03-12 17:14:01 +02:00
Vexu
dda711ba0d
translate-c treat c bools as ints 2020-03-12 14:40:47 +02:00
Vexu
cb4c488cbd
translate-c support struct field alignment 2020-03-10 15:57:57 +02:00
Vexu
4cace8f7c3
properly mangle shadowed primitive types 2020-03-10 15:52:54 +02:00
Vexu
baec74645d
translate-c add daurnimator's pointer check to macro cast 2020-03-10 15:52:03 +02:00
Vexu
692a974c3e
translate-c reject structs with VLAs 2020-03-08 12:11:37 +02:00
Vexu
5aa993cd61
translate-c fix nested loops without blocks. 2020-03-08 11:26:53 +02:00
Andrew Kelley
9e60c89601
Revert "Translate C: Group generated casts"
This reverts commit 895672b3f9.
2020-03-08 03:53:06 -04:00
Andrew Kelley
8b80cb3072
Revert "translate-c remove redundant grouping, fix nested loops without blocks."
This reverts commit abe7305e16.
2020-03-08 03:52:52 -04:00
Vexu
abe7305e16 translate-c remove redundant grouping, fix nested loops without blocks. 2020-03-07 12:14:44 -05:00
Lachlan Easton
895672b3f9 Translate C: Group generated casts
Translate C: Put an alignCast in c style pointer casts to allow opaque types to cast properly in C macros

Translate C: add test case for aligning opaque types in pointer casts

Translate C: Fix @typeId -> @typeInfo

Add test case to run_translated_c for casting from pointer to opaque type
2020-03-07 03:26:42 -05:00
Vexu
83d27f71ef translate-c more macro ops 2020-03-06 17:34:37 -05:00
Vexu
eaccfffe56 translate-c: default initialize non-extern variables to undefined 2020-03-06 00:06:45 -05:00
Vexu
ad27041de9 translate-c demote struct to opaque if unable to translate type 2020-03-05 10:55:32 -05:00
Vexu
e063854563
translate-c correct assumption about macros 2020-03-05 12:23:32 +02:00
Vexu
8088bdc6d5
translate-c macro comma operator 2020-03-05 11:22:50 +02:00
Andrew Kelley
dbe4d72bcf
separate std.Target and std.zig.CrossTarget
Zig now supports a more fine-grained sense of what is native and what is
not. Some examples:

This is now allowed:
-target native

Different OS but native CPU, default Windows C ABI:
-target native-windows
This could be useful for example when running in Wine.

Different CPU but native OS, native C ABI.
-target x86_64-native -mcpu=skylake

Different C ABI but otherwise native target:
-target native-native-musl
-target native-native-gnu

Lots of breaking changes to related std lib APIs.
Calls to getOs() will need to be changed to getOsTag().
Calls to getArch() will need to be changed to getCpuArch().

Usage of Target.Cross and Target.Native need to be updated to use
CrossTarget API.

`std.build.Builder.standardTargetOptions` is changed to accept its
parameters as a struct with default values. It now has the ability to
specify a whitelist of targets allowed, as well as the default target.
Rather than two different ways of collecting the target, it's now always
a string that is validated, and prints helpful diagnostics for invalid
targets. This feature should now be actually useful, and contributions
welcome to further improve the user experience.

`std.build.LibExeObjStep.setTheTarget` is removed.
`std.build.LibExeObjStep.setTarget` is updated to take a CrossTarget
parameter.

`std.build.LibExeObjStep.setTargetGLibC` is removed. glibc versions are
handled in the CrossTarget API and can be specified with the `-target`
triple.

`std.builtin.Version` gains a `format` method.
2020-02-28 14:51:54 -05:00
Andrew Kelley
87b9e744dd
update std lib to new Target API 2020-02-28 14:51:54 -05:00
Vexu
45da72c5b6
remove usages of @typeId, @memberCount, @memberName and @memberType 2020-02-24 23:09:01 +02:00
Andrew Kelley
2de7d0b10c
fix zig build, ABI ABI, and update tests to new Target layout 2020-02-20 18:50:20 -05:00
Andrew Kelley
0f016b368d
support -mcpu=baseline, both in stage1 and stage2
See e381a42de9 for more details.
This is set up so that if we wish to make "baseline" depend on the
OS in the future, it is possible to do that.
2020-02-20 18:31:17 -05:00
Vexu
b15958c557 fix c tokenizer bug 2020-02-14 18:57:57 -05:00
Vexu
9206f8a8cd translate-c improve macro cast translation 2020-02-14 09:36:44 -05:00
Vexu
fa377dbd15 fix c tokenizer bug 2020-02-13 12:21:28 -05:00
Vexu
ae5ba369e1 translate-c float fixes 2020-02-10 11:02:29 -05:00
Vexu
f196ddd251
translate c type names 2020-02-05 17:52:46 +02:00
Vexu
1f49460dcb
fix regressions in comments and string prefixes 2020-02-05 08:35:30 +02:00
Vexu
35c40f0a70
fix regressions 2020-02-02 10:49:51 +02:00
LemonBoy
176bc53858 translate-c: Fix translation of fn pointers
Closes #4332
2020-01-30 21:33:50 -05:00
LemonBoy
979c69d6b2 Amend some failing test cases 2020-01-30 19:53:35 +01:00
LemonBoy
534014f84e translate-c: Handle fn protos wrapped in parenthesis
Closes #4289
2020-01-29 12:06:53 -05:00
Andrew Kelley
9dffc369f1
Merge remote-tracking branch 'origin/master' into layneson-cpus_and_features 2020-01-25 23:25:29 -05:00
Feix Weiglhofer
a4a9330648 translate-c: Don't make const parameters mutable. (#4273)
* translate-c: Remove arg-prefix from const parameters.
* translate-c: Add unittest for const parameters.
2020-01-24 15:32:32 -05:00
LemonBoy
a284be3f69 Fix unsafe cast in translate_c
Fixes #4250
2020-01-22 17:58:57 -05:00