[Prev][Next][Index]

Bug in SgStatement::insertStmtBefore()




I seem to have found a bug in SgStatement::insertStmtBefore(). This is the
code that I'm executing. The function createLockStmt() simply creates the
statement "Lock();". The variable 'stmt' is the place where I want to
insert the call to lock:


    SgStatement *synch = this->createLockStmt();
    stmt->insertStmtBefore(*synch);


This is the code I am applying the above construct to:

---------------------------------------------------------------------------
struct Record {
	...
};

main()
{
	struct Record  s;

	for (...) {	<-- 'stmt' points here.
	}
}
---------------------------------------------------------------------------


In this case, the variable 'stmt' is the for loop. Therefore, the statement
'stmt->insertStmtBefore(*synch)' should yield:

---------------------------------------------------------------------------
struct Record {
	...
};

main()
{
	struct Record  s;

	Lock();
	for (...) {
	}
}
---------------------------------------------------------------------------




However, what I'm getting is this:


---------------------------------------------------------------------------
struct Record {
	...
};

main()
{
	struct Record {		===> This doesn't make sense!
		Lock();
	} s;

	for (...) {
	}
}
---------------------------------------------------------------------------



Thank you. Diego.


--
Diego Novillo (diego@cs.ualberta.ca)    |      Dept of Computing Science
WWW http://web.cs.ualberta.ca/~diego    |          University of Alberta
Use 'finger' to get my PGP public key   |     Edmonton, Alberta - Canada