aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/compiler/attrs.go1
-rw-r--r--pkg/compiler/check.go2
-rw-r--r--pkg/compiler/testdata/errors.txt3
-rw-r--r--pkg/compiler/types.go8
-rw-r--r--prog/validation.go3
5 files changed, 11 insertions, 6 deletions
diff --git a/pkg/compiler/attrs.go b/pkg/compiler/attrs.go
index 46ba89b23..dc10dbc9b 100644
--- a/pkg/compiler/attrs.go
+++ b/pkg/compiler/attrs.go
@@ -31,6 +31,7 @@ var (
structAttrs = makeAttrs(attrPacked, attrSize, attrAlign)
unionAttrs = makeAttrs(attrVarlen, attrSize)
structFieldAttrs = makeAttrs(attrIn, attrOut, attrInOut, attrOutOverlay)
+ unionFieldAttrs = makeAttrs(attrIn) // Let's still support attrIn, it's safe.
callAttrs = make(map[string]*attrDesc)
)
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index 4b2dd1330..5f7bb7108 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -185,7 +185,7 @@ func (comp *compiler) checkStructFields(n *ast.Struct, typ, name string) {
hasDirections, hasOutOverlay := false, false
for fieldIdx, f := range n.Fields {
if n.IsUnion {
- comp.parseAttrs(nil, f, f.Attrs)
+ comp.parseAttrs(unionFieldAttrs, f, f.Attrs)
continue
}
attrs := comp.parseAttrs(structFieldAttrs, f, f.Attrs)
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index 9d625a34b..83b62cfb6 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -419,8 +419,9 @@ union$overlay0 [
]
union$directions [
- f1 int32 (in) ### unknown arg/field f1 attribute in
+ f1 int32 (in)
f2 int32 (out) ### unknown arg/field f2 attribute out
+ f3 int32 (inout) ### unknown arg/field f3 attribute inout
]
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index 85a5bd527..099ab0009 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -1104,9 +1104,9 @@ ANYUNION [
ANYRES16 ANYRES16
ANYRES32 ANYRES32
ANYRES64 ANYRES64
- ANYRESDEC fmt[dec, ANYRES64]
- ANYRESHEX fmt[hex, ANYRES64]
- ANYRESOCT fmt[oct, ANYRES64]
+ ANYRESDEC fmt[dec, ANYRES64] (in)
+ ANYRESHEX fmt[hex, ANYRES64] (in)
+ ANYRESOCT fmt[oct, ANYRES64] (in)
] [varlen]
ANYPTRS [
@@ -1120,7 +1120,7 @@ resource ANYRES32[int32]: -1, 0
resource ANYRES64[int64]: -1, 0
syz_builtin0(a ptr[in, ANYPTRS]) (disabled)
-syz_builtin1(a ptr[out, ANYUNION]) (disabled)
+syz_builtin1(a ptr[inout, ANYUNION]) (disabled)
syz_builtin2() ANYRES8 (disabled)
syz_builtin3() ANYRES16 (disabled)
syz_builtin4() ANYRES32 (disabled)
diff --git a/prog/validation.go b/prog/validation.go
index 09c3cd64c..a1915f3d0 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -169,6 +169,9 @@ func (arg *ResultArg) validate(ctx *validCtx, dir Dir) error {
if arg.Dir() == DirIn && len(arg.uses) > 0 {
return fmt.Errorf("result arg '%v' is DirIn, but is used %d times", typ.Name(), len(arg.uses))
}
+ if len(arg.uses) > 0 && arg.Size() > 8 {
+ return fmt.Errorf("result arg '%v' is to be copied out, yet it's bigger than int64 (%d > 8)", typ.Name(), arg.Size())
+ }
return nil
}