string literals are now null terminated

this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
This commit is contained in:
Andrew Kelley
2019-11-19 20:29:08 -05:00
parent 21f344b3b9
commit 47f06be369
51 changed files with 986 additions and 716 deletions

View File

@@ -164,7 +164,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"using an unknown len ptr type instead of array",
\\const resolutions = [*][*]const u8{
\\ c"[320 240 ]",
\\ "[320 240 ]",
\\ null,
\\};
\\comptime {
@@ -781,7 +781,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
"peer cast then implicit cast const pointer to mutable C pointer",
\\export fn func() void {
\\ var strValue: [*c]u8 = undefined;
\\ strValue = strValue orelse c"";
\\ strValue = strValue orelse "";
\\}
,
"tmp.zig:3:32: error: cast discards const qualifier",
@@ -1115,7 +1115,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
"libc headers note",
\\const c = @cImport(@cInclude("stdio.h"));
\\export fn entry() void {
\\ _ = c.printf(c"hello, world!\n");
\\ _ = c.printf("hello, world!\n");
\\}
,
"tmp.zig:1:11: error: C import failed",
@@ -3352,7 +3352,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"variable has wrong type",
\\export fn f() i32 {
\\ const a = c"a";
\\ const a = "a";
\\ return a;
\\}
,
@@ -4786,7 +4786,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"assign through constant pointer",
\\export fn f() void {
\\ var cstr = c"Hat";
\\ var cstr = "Hat";
\\ cstr[0] = 'W';
\\}
,