github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/compiler/testdata/errors.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  # Errors that happen during type checking phase.
     5  
     6  meta foobar			### unknown type foobar
     7  meta noextract["foo"]		### wrong number of arguments for type noextract, expect no arguments
     8  meta "foobar"			### unexpected string "foobar", expect type
     9  meta arches["z80"]		### unknown arch z80
    10  
    11  #include "something"		### confusing comment faking a directive (rephrase if it's intentional)
    12  #define FOO BAR			### confusing comment faking a directive (rephrase if it's intentional)
    13  # include "something"		### confusing comment faking a directive (rephrase if it's intentional)
    14  #	incdir "dir"		### confusing comment faking a directive (rephrase if it's intentional)
    15  
    16  foo$0(x fileoff, y int8, z buffer[in])
    17  foo$1(x "bar")			### unexpected string "bar", expect type
    18  foo$2(x 123, y "bar")		### unexpected int 123, expect type	### unexpected string "bar", expect type
    19  foo$3(x string)			### string can't be syscall argument
    20  
    21  resource r0[int32]: 0, 0x1
    22  resource r1[string["foo"]]	### string can't be resource base (int types can)
    23  resource r1[int32]		### type r1 redeclared, previously declared as resource at LOCATION
    24  resource int32[int32]		### resource name int32 conflicts with builtin type
    25  resource fileoff[intptr]	### type fileoff redeclared, previously declared as type alias at builtins
    26  
    27  s1 {
    28  	f1	int32
    29  }
    30  
    31  s1 {				### type s1 redeclared, previously declared as struct at LOCATION
    32  	f1	int32
    33  	f1	intptr		### duplicate field f1 in struct s1
    34  	parent	int8		### reserved field name parent in struct s1
    35  }
    36  
    37  s2 {				### struct s2 has no fields, need at least 1 field
    38  }
    39  
    40  int32 {				### struct name int32 conflicts with builtin type
    41  	f1	int32
    42  }
    43  
    44  r0 {				### type r0 redeclared, previously declared as resource at LOCATION
    45  	f1	int32
    46  }
    47  
    48  u0 [
    49  	f1	int32
    50  	f2	fileoff[int32]
    51  ]
    52  
    53  u1 [				### union u1 has no fields, need at least 1 field
    54  ]
    55  
    56  u2 [
    57  	f1	int8
    58  	f1	int16		### duplicate field f1 in union u2
    59  	parent	int32		### reserved field name parent in union u2
    60  ]
    61  
    62  foo$4(a int8, a int16)		### duplicate argument a in syscall foo$4
    63  foo$4()				### syscall foo$4 redeclared, previously declared at LOCATION
    64  foo()
    65  foo()				### syscall foo redeclared, previously declared at LOCATION
    66  foo$5(a0 int8, a1 int8, a2 int8, a3 int8, a4 int8, a5 int8, a6 int8, a7 int8, a8 int8, a9 int8)	### syscall foo$5 has 10 arguments, allowed maximum is 9
    67  foo$6(parent int8)		### reserved argument name parent in syscall foo$6
    68  
    69  f1 = 1
    70  f2 = 1, 2
    71  f2 = 1, 2			### flags f2 redeclared, previously declared at LOCATION
    72  sf1 = "a"
    73  sf2 = "a", "b"
    74  sf2 = "c"			### string flags sf2 redeclared, previously declared at LOCATION
    75  
    76  f110 = 1, 2, 3, 4, f120		### flags f110 used twice or circular dependency on f110
    77  f120 = 10, 11, 12, f130		### flags f120 used twice or circular dependency on f120
    78  f130 = 100, 110, f110		### flags f130 used twice or circular dependency on f130
    79  
    80  loop_flags(a flags[f110])
    81  
    82  f200 = f300, 200, 201		### flags identifier not at the end in f200 definition
    83  f300 = 300, 301
    84  
    85  f210 = "1", "2", "3", f220	### flags f210 used twice or circular dependency on f210
    86  f220 = "10", "11", f230		### flags f220 used twice or circular dependency on f220
    87  f230 = "100", "110", f210	### flags f230 used twice or circular dependency on f230
    88  
    89  resource r2[r0]: 2
    90  resource r3[int32:1]		### unexpected ':', only struct fields can be bitfields
    91  resource r4[int32[opt]]		### resource base can't be marked as opt
    92  resource r5[non_existent]	### unknown type non_existent
    93  resource r6[int64be]		### int64be can't be resource base (int types can)
    94  resource r9["foo"]		### unexpected string "foo", expect type
    95  
    96  foo$7(a r0, a1 r2[opt])
    97  foo$8(a fileoff[a, b, int8])	### template fileoff needs 0 arguments instead of 3
    98  foo$9(a buffer[inout])
    99  foo$10(a buffer[intout])	### unexpected value intout for direction argument of ptr type, expect [in out inout]
   100  foo$11(a buffer["in"])		### unexpected string "in" for direction argument of ptr type, expect [in out inout]
   101  foo$12(a buffer[10])		### unexpected int 10 for direction argument of ptr type, expect [in out inout]
   102  foo$13(a int32[2:3])
   103  foo$14(a int32[2:2])
   104  foo$17(a ptr[in, int32])
   105  foo$18(a ptr[in, int32[2:3]])
   106  foo$19(a ptr[in, int32[opt]])
   107  foo$20(a ptr)			### wrong number of arguments for type ptr, expect direction, type, [opt]
   108  foo$21(a ptr["foo"])		### wrong number of arguments for type ptr, expect direction, type, [opt]
   109  foo$22(a ptr[in])		### wrong number of arguments for type ptr, expect direction, type, [opt]
   110  foo$23(a ptr[in, s3[in]])	### wrong number of arguments for type s3, expect no arguments
   111  foo$25(a proc[0, "foo"])	### unexpected string "foo" for per-proc values argument of proc type, expect int
   112  foo$26(a flags[no])		### unknown flags no
   113  foo$27(a flags["foo"])		### unexpected string "foo" for flags argument of flags type, expect identifier
   114  foo$28(a ptr[in, string["foo"]], b ptr[in, string["foo", 4]])
   115  foo$30(a ptr[in, string[no]])	### unknown string flags no
   116  foo$31(a int8, b ptr[in, csum[a, inet]])		### wrong number of arguments for type csum, expect csum target, kind, [proto], base type
   117  foo$32(a int8, b ptr[in, csum[a, inet, 1, int32]])	### only pseudo csum can have proto
   118  foo$33(a int8, b ptr[in, csum[a, pseudo, 1, int32]])
   119  foo$34(a int32["foo"])		### unexpected string "foo" for value argument of int32 type, expect identifier or int
   120  foo$35(a ptr[in, s3[opt]])	### s3 can't be marked as opt
   121  foo$36(a const[1:2])		### unexpected ':'
   122  foo$39(a fileoff:1)		### type alias fileoff with ':'
   123  foo$40(a len["a"])		### unexpected string "a" for len target argument of len type, expect identifier
   124  foo$41(a vma[C1:C2])
   125  foo$43(a ptr[in, string[1]])	### unexpected int 1 for literal or flags argument of string type, expect string or identifier
   126  foo$44(a int32) len[a]		### len can't be syscall return
   127  foo$45(a int32) len[b]		### len can't be syscall return
   128  foo$46(a ptr[in, in])		### unknown type in
   129  foo$47(a int32:2)		### unexpected ':', only struct fields can be bitfields
   130  foo$48(a ptr[in, int32:7])	### unexpected ':', only struct fields can be bitfields
   131  foo$49(a ptr[in, array[int32, 0:1]])
   132  foo$52(a intptr, b bitsize[a])
   133  foo$53(a proc[20, 10, opt])
   134  # This must not error yet (consts are not patched).
   135  foo$54(a ptr[in, string["foo", C1]])
   136  foo$55(a int8[opt[int8]])	### opt can't have arguments
   137  foo$56(a void)			### void can't be syscall argument
   138  foo$57(a ptr[in, stringnoz["foo", 10]])	### fixed-size string can't be non-zero-terminated
   139  foo$58(a ptr[in, stringnoz[sf2, 10]])	### fixed-size string can't be non-zero-terminated
   140  foo$59(a s1)			### s1 can't be syscall argument
   141  foo$60() s1			### s1 can't be syscall return
   142  foo$61(a u6)			### u6 can't be syscall argument
   143  foo$62() u6			### u6 can't be syscall return
   144  foo$63(a int32[1[2]])		### value argument has subargs
   145  foo$64(a ptr[in, flags[f1[int32], int32]])	### flags argument has subargs
   146  foo$65(a int32, b len[1])	### unexpected int 1 for len target argument of len type, expect identifier
   147  foo$66(a int32, b len[a:1])	### unexpected int 1 after colon, expect identifier
   148  foo$67(x int32[1:2:3, opt])	### unexpected ':'
   149  foo$68(a int32[15, 2])		### align argument of int32 is not supported unless first argument is a range
   150  foo$69() (foo)			### unknown syscall foo$69 attribute foo
   151  foo$70() ("foo")		### unexpected string "foo", expect attribute
   152  foo$71() (42)			### unexpected int 42, expect attribute
   153  foo$72() (disabled, disabled)	### duplicate syscall foo$72 attribute disabled
   154  foo$73(a int32[int_flags, 2])	### align argument of int32 is not supported unless first argument is a range
   155  foo$74() (int8:1)		### unexpected ':'
   156  
   157  opt {				### struct uses reserved name opt
   158  	f1	int32
   159  }
   160  
   161  in = 1, 2			### flags uses reserved name in
   162  out = "1", "2"			### string flags uses reserved name out
   163  int_flags = 0, 1, 0xabc, 'x', -11
   164  
   165  out [				### union uses reserved name out
   166  	f1	int32
   167  	f2	int8
   168  ]
   169  
   170  resource inout[int32]		### resource uses reserved name inout
   171  
   172  bar()
   173  
   174  s3 {
   175  	f1	int8:0		### bitfields of size 0 are not supported
   176  	f2	int8:1
   177  	f3	int8:7
   178  	f4	int8:8
   179  	f5	int8:9		### bitfield of size 9 is too large for base type of size 8
   180  	f6	int32:32
   181  	f7	int32:33	### bitfield of size 33 is too large for base type of size 32
   182  	f8	const[0, int32:C1]	### literal const bitfield sizes are not supported
   183  	f9	const[0]	### wrong number of arguments for type const, expect value, base type
   184  	f10	int8:1:1	### unexpected ':'
   185  } [packed, align[4]]
   186  
   187  s5 {
   188  	f1	int8
   189  } [varlen]			### unknown struct s5 attribute varlen
   190  
   191  s7 {
   192  	f1	ptr64[in, int32]
   193  }
   194  
   195  s8 {
   196  	f1	int8
   197  } [unknown]			### unknown struct s8 attribute unknown
   198  
   199  s9 {
   200  	f1	int8
   201  } ["foo"[0]]			### unexpected string "foo", expect attribute
   202  
   203  s10 {
   204  	f1	int8
   205  } [packed[0]]			### packed attribute has args
   206  
   207  s11 {
   208  	f1	int8
   209  } [size["foo"]]			### unexpected string "foo", expect int
   210  
   211  s12 {
   212  	f1	int8
   213  } [size[0:1]]			### size attribute has colon or args
   214  
   215  s13 {
   216  	f1	int8
   217  } [size[0[0]]]			### size attribute has colon or args
   218  
   219  s14 {
   220  	f1	int8
   221  } [size[1, 2]]			### size attribute is expected to have 1 argument
   222  
   223  u3 [
   224  	f1	int8
   225  	f2	int32
   226  ] [varlen]
   227  
   228  u4 [
   229  	f1	int8
   230  	f2	int32
   231  ] [packed]			### unknown union u4 attribute packed
   232  
   233  u5 [
   234  	f1	int8:1		### unexpected ':', only struct fields can be bitfields
   235  	f2	int8:2		### unexpected ':', only struct fields can be bitfields
   236  ]
   237  
   238  u6 [
   239  	f1	int8
   240  	f2	int64
   241  	f3	array[int8]
   242  ]
   243  
   244  define d0 SOMETHING
   245  define d1 `some C expression`
   246  define d2 some C expression
   247  define d2 SOMETHING		### duplicate define d2
   248  define d3 1
   249  
   250  # Type aliases.
   251  
   252  type mybool8 int8[0:1]
   253  type mybool16 int16[0:1]
   254  type net_port proc[100, 1, int16be]
   255  resource typeres0[mybool8]
   256  typestruct {
   257  	f1	mybool8
   258  	f2	mybool16
   259  }
   260  
   261  type type0 int8
   262  type type0 int8			### type type0 redeclared, previously declared as type alias at LOCATION
   263  resource type0[int32]		### type type0 redeclared, previously declared as type alias at LOCATION
   264  type0 = 0, 1
   265  type type1 type1		### type instantiation loop: type1 -> type1
   266  type type2 int8:4		### unexpected ':', only struct fields can be bitfields
   267  type type3 type2		### unknown type type2
   268  type type4 const[0]		### wrong number of arguments for type const, expect value, base type
   269  type type6 len[foo, int32]	### len can't be type alias target
   270  type type7 len[foo]		### len can't be type alias target
   271  resource typeres1[int32]
   272  type type8 typeres1		### typeres1 can't be type alias target
   273  type int8 int8			### type name int8 conflicts with builtin type
   274  type opt int8			### type uses reserved name opt
   275  type type9 const[0, int8]
   276  type type12 proc[123, 2, int16, opt]
   277  type type13 ptr[in, typestruct13]
   278  type type14 flags[type0, int32]
   279  type type15 const[0, type0]	### unexpected value type0 for base type argument of const type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
   280  type type16 type17		### type instantiation loop: type16 -> type16
   281  type type17 type18		### unknown type type16
   282  type type18 type16		### unknown type type16
   283  type bool8 int8[0:1]		### type bool8 redeclared, previously declared as type alias at builtins
   284  
   285  typestruct11 {
   286  	f	type11		### unknown type type11
   287  }
   288  
   289  typestruct12 {
   290  	f	type11		### unknown type type11
   291  }
   292  
   293  typestruct13 {
   294  	f1	type9
   295  	f2	type12
   296  }
   297  
   298  foo$100(a mybool8, b mybool16)
   299  foo$102(a type2)		### unknown type type2
   300  foo$103(a type0:4)		### type alias type0 with ':'
   301  foo$104(a type0[opt])		### type type0 is not a template
   302  foo$105() type0			### int8 can't be syscall return
   303  foo$106() type6			### unknown type type6
   304  foo$107(a type9, b type12)
   305  foo$108(a flags[type0])
   306  foo$109(a ptr[in, type0])
   307  
   308  # Type templates.
   309  
   310  type templ0[A, B] const[A, B]
   311  type templ2[A] A[0]
   312  type templ3[A] ptr[in, A]
   313  type templ4[A, A] ptr[in, A]	### duplicate type argument A
   314  type templ5[abc] ptr[in, abc]	### type argument abc must be ALL_CAPS
   315  type templ6[T] ptr[in, T]
   316  type templ7 templ0[templ6, int8]
   317  type templ8[BASE, A] BASE[A]	### type argument BASE must be the last argument
   318  type templ9[BASE] BASE
   319  type templ10[A] templ9[A]
   320  type templ11[VAL, BASE] const[VAL, BASE]
   321  
   322  # Note: here 42 is stripped as base type, so const ends up without arguments.
   323  foo$201(a templ1[42])		### wrong number of arguments for type const, expect value
   324  type templ1[A] const[A]
   325  
   326  type templ_struct0[A, B] {
   327  	len	len[parent, int16]
   328  	typ	const[A, int16]
   329  	data	B
   330  } [align[4]]
   331  
   332  type templ_struct1[STR] {
   333  	f	string[STR, 40]
   334  	f	int32		### duplicate field f in template struct templ_struct1
   335  }
   336  
   337  type templ_struct2[A] {
   338  	f	B
   339  }
   340  
   341  type templ_base0[TYPE] {
   342  	f1	TYPE
   343  }
   344  
   345  type templ_templ0[B] {
   346  	f1	B
   347  }
   348  
   349  type templ_templ1[B] {
   350  	f1	B[int16]			### both template parameter B and its usage have sub-arguments
   351  }
   352  
   353  templ_templ_use0 {
   354  	f1	templ_templ0[templ_base0]	### template templ_base0 needs 1 arguments instead of 0
   355  	f2	templ_templ1[templ_base0[int32]]
   356  }
   357  
   358  foo$200(a templ0[42, int8])
   359  foo$202(a templ0)		### template templ0 needs 2 arguments instead of 0
   360  foo$203(a type0[42])		### type type0 is not a template
   361  foo$204(a ptr[in, templ_struct0[42, int8]])
   362  foo$205(a ptr[in, templ_struct0[int8, int8]])
   363  foo$207(a ptr[in, templ_struct2[1]])		### template argument A is not used
   364  foo$208(a ptr[in, templ9[string["foo"]]])	### unexpected value string for base type argument of templ9 type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
   365  foo$209(a ptr[in, templ10[templ0[42, int8]]])	### unexpected value templ0 for base type argument of templ9 type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
   366  foo$210(a ptr[in, templ11[0, 1, int8]])		### template templ11 needs 2 arguments instead of 3
   367  foo$211(a ptr[in, templ9])			### template templ9 needs 1 arguments instead of 0
   368  foo$212(a ptr[in, templ11[1]])			### template templ11 needs 2 arguments instead of 1
   369  
   370  type TR[A, B] {
   371  	f TR[A, A[B]]		### type instantiation recursion: TR[X, Y] -> TR[X, X[Y]] -> TR[X, X[X[Y]]] -> TR[X, X[X[X[Y]]]] -> TR[X, X[X[X[X[Y]]]]] -> TR[X, X[X[X[X[X[Y]]]]]] -> TR[X, X[X[X[X[X[X[Y]]]]]]] -> TR[X, X[X[X[X[X[X[X[Y]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[Y]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[Y]]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[X[Y]]]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[X[X[Y]]]]]]]]]]]]
   372  }
   373  type TU TR[X, Y]
   374  
   375  type TT1[A] {
   376  	f0 templ_base0[A]
   377  	f1 TT2[A]
   378  }
   379  
   380  type TT2[A] {
   381  	f1 templ_base0[A]
   382  	f2 TT3[A]
   383  }
   384  
   385  type TT3[A] {
   386  	f1 templ_base0[A]
   387  	f2 TT1[A]				### type instantiation loop: TT1[int8] -> TT2[int8] -> TT3[int8] -> TT1[int8]
   388  }
   389  
   390  foo$213(a ptr[in, TT1[int8]])
   391  
   392  foo$glob001(a ptr[in, glob[1]])			### unexpected int 1 for literal or flags argument of glob type, expect string or identifier
   393  foo$glob002(a ptr[in, glob])			### glob only accepts 1 arg, provided 0
   394  foo$glob003(a ptr[in, glob["/sys", 5]])		### glob only accepts 1 arg, provided 2
   395  foo$glob004(a ptr[in, glob["/sys", 5, 2]])	### wrong number of arguments for type glob, expect [literal or flags], [size], [opt]
   396  
   397  # fmt
   398  
   399  foo$fmt0(a ptr[in, fmt])			### wrong number of arguments for type fmt, expect format, value
   400  foo$fmt1(a fmt[dec, int8])			### fmt can't be syscall argument
   401  foo$fmt2(a ptr[in, fmt[dec, ptr[in, int8]]])	### bad fmt value ptr, expect an integer
   402  foo$fmt3(a ptr[in, fmt[foo, int8]])		### unexpected value foo for format argument of fmt type, expect [dec hex oct]
   403  foo$fmt4(a ptr[in, fmt[dec, int8:3]])		### unexpected ':', only struct fields can be bitfields
   404  
   405  struct$fmt0 {
   406  	f0	fmt[dec, int8:3]		### unexpected ':', only struct fields can be bitfields
   407  	f1	int32:-1			### bitfield of size 18446744073709551615 is too large for base type of size 32
   408  }
   409  
   410  struct$perfielddir {
   411  	f0	int32	(in, in)	### duplicate arg/field f0 attribute in
   412  	f1	int32	(out, out)	### duplicate arg/field f1 attribute out
   413  	f2	int32	(inout, inout)	### duplicate arg/field f2 attribute inout
   414  	f3	int32	(in, out)	### arg/field has multiple direction attributes
   415  	f4	int32	(in, inout)	### arg/field has multiple direction attributes
   416  	f5	int32	(out, inout)	### arg/field has multiple direction attributes
   417  	f6	int32	(in, out, inout)	### arg/field has multiple direction attributes
   418  }
   419  
   420  struct$overlay0 {
   421  	f0	int32	(out_overlay)	### out_overlay attribute must not be specified on the first field
   422  	f1	int32	(out_overlay)	### multiple out_overlay attributes
   423  }
   424  
   425  struct$overlay1 {
   426  	f0	int32
   427  	f1	int32	(out_overlay, out_overlay)	### duplicate arg/field f1 attribute out_overlay
   428  	f2	int32	(out_overlay)	### multiple out_overlay attributes
   429  }
   430  
   431  struct$overlay2 {
   432  	f0	int32	(in)
   433  	f1	int32	(out_overlay)	### mix of direction and out_overlay attributes is not supported
   434  }
   435  
   436  union$overlay0 [
   437  	f0	int32
   438  	f1	int32	(out_overlay)	### unknown arg/field f1 attribute out_overlay
   439  ]
   440  
   441  union$directions [
   442  	f1	int32	(in)
   443  	f2	int32	(out)	### unknown arg/field f2 attribute out
   444  	f3	int32	(inout)	### unknown arg/field f3 attribute inout
   445  ]
   446  
   447  
   448  compressed$test(a int32) compressed_image	### compressed_image can't be syscall return
   449  
   450  define FLAG1 = 1
   451  define FLAG2 = 2
   452  
   453  some_nested_flags {
   454  	f1	int32
   455  }
   456  
   457  conditional_fields {
   458  	f1	int32
   459  	f2      some_nested_flags (if[value[f1] & FLAG1])
   460  	f3      some_nested_flags (if[value[f1] & FLAG1], if[value[f1] & FLAG1]) ### duplicate arg/field f3 attribute if
   461  	f4      some_nested_flags (if[value & FLAG1]) ### value reference must have only one argument
   462  	f5      some_nested_flags (if[value[f1] & FLAG1, FLAG2]) ### if attribute is expected to have only one argument
   463  	f6      some_nested_flags (if[value[f1, FLAG2] & FLAG1]) ### value reference must have only one argument
   464  	f7      some_nested_flags (if[5])
   465  	f8      some_nested_flags
   466  	f9      some_nested_flags (if[value[f8:f1] & FLAG1])
   467  	f10     some_nested_flags (if[value[f8:f1, A] & FLAG1]) ### value reference must have only one argument
   468  	f11     some_nested_flags (if[value[f8:f1[A]] & FLAG1]) ### value aguments must not have any further arguments
   469  	f12     some_nested_flags (if[f1 == "A"]) ### the token must be either an integer or an identifier
   470  	f13     some_nested_flags (if["ABCD"]) ### if argument must be an expression
   471  	f14     some_nested_flags (if[X[Y]]) ### consts in expressions must not have any arguments
   472  	f15	conditional_fields_union1
   473  	f16	conditional_fields_union2
   474  }
   475  
   476  conditional_fields_union1 [
   477  	u1	int32 (if [value[parent:f1] & FLAG1])
   478  	u2	int32 (if [value[parent:f1] & FLAG2]) ### unions must not have if conditions on the last field
   479  ]
   480  
   481  conditional_fields_union2 [
   482  	u1	int32 (if [value[parent:f1] & FLAG1])
   483  	u2	int32 ### either no fields have conditions or all except the last
   484  	u3	int32
   485  ]
   486  
   487  invalid_string_attr() (invalid["string"])	### unknown syscall invalid_string_attr attribute invalid