aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/compiler')
-rw-r--r--pkg/compiler/testdata/all.txt3
-rw-r--r--pkg/compiler/testdata/errors2.txt1
-rw-r--r--pkg/compiler/types.go21
3 files changed, 9 insertions, 16 deletions
diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt
index 9d94a81a1..789071964 100644
--- a/pkg/compiler/testdata/all.txt
+++ b/pkg/compiler/testdata/all.txt
@@ -40,10 +40,13 @@ strings {
f11 stringnoz[string_flags1]
f12 string[string_flags2]
f13 stringnoz[string_flags2]
+ f14 string[`abcdef`, 4]
+ f15 string[string_flags3, 4]
} [packed]
string_flags1 = "foo", "barbaz"
string_flags2 = ""
+string_flags3 = "ab", `010203`, `de`
int_flags = 0, 1, 0xabc, 'x', -11
_ = 1, 2
_ = C1, C2
diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt
index 47d76ab89..b5ab19ebf 100644
--- a/pkg/compiler/testdata/errors2.txt
+++ b/pkg/compiler/testdata/errors2.txt
@@ -267,6 +267,7 @@ foo$525(a int8[-256:256]) ### int range [18446744073709551360:256] is too large
foo$526(a int8[-255:255]) ### int range [18446744073709551361:255] is too large for base type of size 8
foo$527(a int16[-40000:40000]) ### int range [18446744073709511616:40000] is too large for base type of size 16
foo$528(a ptr[in, s405])
+foo$529(a ptr[in, string[`abcdde`, 3]]) ### string value "\xab\xcd\xde\x00" exceeds buffer length 3
type type500 proc[C1, 8, int8] ### values starting from 1 with step 8 overflow base type for 32 procs
type type501 int8 ### unused type type501
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index 251e0fcaa..43efee202 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -514,12 +514,11 @@ func genTextType(t *ast.Type) prog.TextKind {
}
const (
- stringnoz = "stringnoz"
- stringnozescapes = "stringnozescapes"
+ stringnoz = "stringnoz"
)
var typeString = &typeDesc{
- Names: []string{"string", stringnoz, stringnozescapes},
+ Names: []string{"string", stringnoz},
CanBeTypedef: true,
OptArgs: 2,
Args: []namedArg{
@@ -527,7 +526,7 @@ var typeString = &typeDesc{
{Name: "size", Type: typeArgInt},
},
Check: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) {
- if (t.Ident == stringnoz || t.Ident == stringnozescapes) && len(args) > 1 {
+ if t.Ident == stringnoz && len(args) > 1 {
comp.error(args[0].Pos, "fixed-size string can't be non-zero-terminated")
}
},
@@ -559,7 +558,7 @@ var typeString = &typeDesc{
return &prog.BufferType{
TypeCommon: base.TypeCommon,
Kind: prog.BufferFilename,
- NoZ: t.Ident == stringnoz || t.Ident == stringnozescapes,
+ NoZ: t.Ident == stringnoz,
}
}
subkind := ""
@@ -576,7 +575,7 @@ var typeString = &typeDesc{
Kind: prog.BufferString,
SubKind: subkind,
Values: vals,
- NoZ: t.Ident == stringnoz || t.Ident == stringnozescapes,
+ NoZ: t.Ident == stringnoz,
}
},
}
@@ -592,16 +591,6 @@ func (comp *compiler) genStrings(t *ast.Type, args []*ast.Type) []string {
}
if t.Ident == stringnoz {
return vals
- } else if t.Ident == stringnozescapes {
- for i := range vals {
- unquote, err := strconv.Unquote(`"` + vals[i] + `"`)
- if err != nil {
- comp.error(args[0].Pos, fmt.Sprintf("unable to unquote stringnozescapes %q: %v", vals[i], err))
- } else {
- vals[i] = unquote
- }
- }
- return vals
}
var size uint64
if len(args) > 1 {