errors.go raw

   1  package main
   2  
   3  /*
   4  #warning some warning
   5  
   6  typedef struct {
   7  	int x;
   8  	int y;
   9  } point_t;
  10  
  11  typedef someType noType; // undefined type
  12  
  13  // Some invalid noescape lines
  14  #cgo noescape
  15  #cgo noescape foo bar
  16  #cgo noescape unusedFunction
  17  
  18  #define SOME_CONST_1 5) // invalid const syntax
  19  #define SOME_CONST_2 6) // const not used (so no error)
  20  #define SOME_CONST_3 1234 // const too large for byte
  21  #define   SOME_CONST_b      3   ) // const with lots of weird whitespace (to test error locations)
  22  #  define SOME_CONST_startspace 3)
  23  */
  24  //
  25  //
  26  // #define SOME_CONST_4 8) // after some empty lines
  27  // #cgo CFLAGS: -DSOME_PARAM_CONST_invalid=3/+3
  28  // #cgo CFLAGS: -DSOME_PARAM_CONST_valid=3+4
  29  import "C"
  30  
  31  // #warning another warning
  32  import "C"
  33  
  34  // #define add(a, b) (a+b)
  35  // #define add_toomuch add(1, 2, 3)
  36  // #define add_toolittle add(1)
  37  import "C"
  38  
  39  // Make sure that errors for the following lines won't change with future
  40  // additions to the CGo preamble.
  41  //
  42  //line errors.go:100
  43  var (
  44  	// constant too large
  45  	_ C.char = 2 << 10
  46  
  47  	// z member does not exist
  48  	_ C.point_t = C.point_t{z: 3}
  49  
  50  	// constant has syntax error
  51  	_ = C.SOME_CONST_1
  52  
  53  	_ byte = C.SOME_CONST_3
  54  
  55  	_ = C.SOME_CONST_4
  56  
  57  	_ = C.SOME_CONST_b
  58  
  59  	_ = C.SOME_CONST_startspace
  60  
  61  	// constants passed by a command line parameter
  62  	_ = C.SOME_PARAM_CONST_invalid
  63  	_ = C.SOME_PARAM_CONST_valid
  64  
  65  	_ = C.add_toomuch
  66  	_ = C.add_toolittle
  67  )
  68