[Prev][Next][Index]

friend functions in sage++-1.7



I have a sage program which uses the following code to check whether a
member function is a friend function or not.  This used to work under
sage++-1.3 but no longer works with sage++-1.7.

  SgClassSymb* user_class = isSgClassSymb( symbol );
  if ( user_class ) {
    SgMemberFuncSymb* member_function = 
      isSgMemberFuncSymb( user_class->field( 1 ) );
    if ( member_function ) {
      SgDescriptType* descriptor = isSgDescriptType( member_function->type() );
      if ( descriptor ) {
	friend = descriptor->modifierFlag() & BIT_FRIEND;
	if ( friend_function ) {
	  cout << "friend function " << endl;
	}
      }
    }
  }

Am I doing something obviously wrong?  Or is there a different
mechanism in sage++-1.7 for discovering whether a function is a friend
function of a class?

I am trying to match the code:

  class test {
  public:
    friend test operator+(const test&, const test&);
  }

  int main() {
    test x, y;

    x + y;
  }

What I am doing above is looking at the class symbol test.  The
operator+ function shows up as member_function, but isSgDescriptType()
fails for member_function->type().  Printing out
member_function->type()->variant() shows it to be T_DERIVED_TYPE.  It
is not a derived class and should not be derived from anything as test
is a simple class.  Unless the fact that a member function is a
sgDerivedType() is used to mean that the member function is a friend
function?

Adam

_______________________________________________________________
email:aba@dcs.exeter.ac.uk        http://dcs.exeter.ac.uk/~aba/