Konstantin8105 / c4go

Transpiling C code to Go code
MIT License
363 stars 37 forks source link

Fix: Cannot casting {int -> (noreturn)} #59

Closed Konstantin8105 closed 5 years ago

Konstantin8105 commented 6 years ago
#include <stdio.h>

int main (int argc, char *argv[]){
  FILE *fp;
  int nchars, nwords, nlines;
  int lastnblank;    /* 0 iff the last character was a space */
  char c;

  if(argc!=2){
    printf("Usage: %s filename\n", argv[0]);
    exit(0);
  }
  if((fp=fopen(argv[1],"r"))==NULL){
    perror("fopen");
    exit(0); // <<--- PROBLEM HERE
  }
}
// Warning (*ast.CallExpr):  /home/konstantin/go/src/github.com/Konstantin8105/c4go-rating/testdata/SingleCcode/counts.c:18 :Cannot casting {int -> (noreturn)}. err = Cannot resolve type '(noreturn)' : Cannot separate function '(noreturn)' : Cannot parse function '(noreturn)' : Don't found '(' in type : (noreturn)
|   | | `-CallExpr 0x33a7680 <line:18:5, col:11> 'void'
|   | |   |-ImplicitCastExpr 0x33a7668 <col:5> 'void (*)(int) __attribute__((noreturn))' <FunctionToPointerDecay>
|   | |   | `-DeclRefExpr 0x33a75f0 <col:5> 'void (int) __attribute__((noreturn))' Function 0x33a74e0 'exit' 'void (int) __attribute__((noreturn))'
|   | |   `-IntegerLiteral 0x33a7618 <col:10> 'int' 0
Konstantin8105 commented 5 years ago

Example is Ok, C is not implemented stdlib