anikau31 / systemc-clang

This is a Clang tool that parses SystemC models, and synthesizes Verilog from it.
Other
73 stars 19 forks source link

Null function body not handled #389

Open mayagokhale opened 1 year ago

mayagokhale commented 1 year ago

https://github.com/intel/systemc-compiler/blob/main/designs/tests/method/test_fcall.cpp

globFunc1 has no function body, thus in the function definition hcode, the body is omitted. However, an empty body is not accepted by hcode parser. Should the hcode plugin generate a fake return stmt or should the hcode parser accept a null body?

zhuanhao-wu commented 1 year ago

I think it suffices to put an empty hcstmt node, specifically something like this:

hCStmt  NONAME NOLIST
mayagokhale commented 1 year ago

fixed in 5c2c1fe

zhuanhao-wu commented 1 year ago

Currently, a hVardecl is generated within the function body, which should be outside:

      hFunction globFunc1_func_10 [
        hFunctionRetType  NONAME [
          hTypeinfo  NONAME [
            hType void NOLIST
          ]
        ]
        hCStmt  NONAME [
          hVardecl a__local_32 [
            hTypeinfo  NONAME [
              hType int NOLIST
            ]
          ]
          hCStmt  NONAME [
            hVarAssign  NONAME [
              hVarref a__local_32 NOLIST
              hLiteral 0 NOLIST
            ]
          ]
        ]
      ]

It should be

      hFunction globFunc1_func_10 [
        hFunctionRetType  NONAME [
          hTypeinfo  NONAME [
            hType void NOLIST
          ]
        ]
          hVardecl a__local_32 [
            hTypeinfo  NONAME [
              hType int NOLIST
            ]
          ]
        hCStmt  NONAME [

          hCStmt  NONAME [
            hVarAssign  NONAME [
              hVarref a__local_32 NOLIST
              hLiteral 0 NOLIST
            ]
          ]
        ]
      ]