[aspectc-user] ‘srcthis’ was not declared in this scope

Panu Bloigu panu.bloigu at mbnet.fi
Tue Feb 27 12:31:11 CET 2007


Hello.

I have the following problem. In an abstract base aspect I have virtual 
pointcuts, which I then define in two separate inherited aspects. The 
virtual pointcut is part of another pointcut in the abstract aspect and 
that pointcut is used to instrument code in the inherited aspects. This 
seems to be something that ac++ does not feel comfortable with. Or I 
have made a mistake somewhere. To get the picture, please consider the 
following file.
======================================================================
#include <iostream>
// Base aspect
aspect Base
{
        pointcut virtual target_methods() = 0;
        pointcut virtual target_class() = 0;

        pointcut on_test() = execution("% ...::_test_()") && 
that(target_class());

        advice target_class() : slice class
        {
        private:
                void _test_(){}
        };


        advice execution(target_methods()) : around()
        {
                tjp->that()->_test_();
                tjp->proceed();
        }
};

// Descendant A
aspect InherA : public Base
{
        pointcut target_methods() = "void A::a()";
        pointcut target_class() = "A";

        advice on_test() : around()
        {
                std::cout<<"This is before void A::_test_()\n";
                tjp->proceed();
        }
};

// Descendant B
aspect InherB : public Base
{
        pointcut target_methods() = "void B::b()";
        pointcut target_class() = "B";

        advice on_test() : around()
        {
                std::cout<<"This is before void B::_test_()\n";
                tjp->proceed();
        }
};

// The classes to be instrumented
class A
{
public:
        A(){}
        virtual ~A(){}
        void a(){}
};

class B
{
public:
        B(){}
        virtual ~B(){}
        void b(){}
};

// entry point
int main()
{
        A a;
        B b;
        a.a();
        b.b();
        return 0;
}
======================================================================

Now the compiler gives me the following error:
======================================================================
[bloigu at athlonxp inher]$ ag++ -k --keep_acc inher.cpp -o inher
inher.acc: In member function ‘void A::TJP__ZN1A6_test_Ev_1::proceed()’:
inher.acc:409: error: ‘srcthis’ was not declared in this scope
error: Execution failed: "g++" -xc++ "inher.acc" -xnone -I"." -o "inher"
======================================================================

What is that 'srcthis' and how come it's not defined? I took a peek in 
the generated .acc file and what struck me odd was that the structure 
A::TJP__ZN1A6_test_Ev_1 referenced 'srcthis' while the corresponding 
structure for the class B didn't reference 'srcthis' at all.I would also 
like to know if this is a bug, missing feature or illegal AspectC++ 
code. Also, if someone would suggest a method to accomplish this 
functionality, it would be greatly appreciated.

Thanks in advance,

Panu.






More information about the aspectc-user mailing list