[Prev][Next][Index]

generating declaration statements




I'm hitting an unexpected error when I try to generate the variable declaration

int var_name;

in a program.  Here's my code:

void decl_test(SgFile& file)
{
  SgStatement *main, *decl_stmt;
  SgType *int_type;
  SgSymbol *var_symb;
  SgExpression *var_exp;
  
  main = file.mainProgram();
  int_type=SgTypeInt();

  var_symb = new SgVariableSymb("var_name",*int_type);
  var_exp = new SgVarRefExp(*var_symb);
  decl_stmt = new SgVarDeclStmt(*var_exp,*int_type);

  (main->childList1(0))->insertStmtBefore(*decl_stmt);
}
  
And here's what it adds to my dep file:

  ------TYPE ERROR---- var_name;


----

Do you have any idea what might be going wrong?

Thanks!

	---Erik