[aspectc-user] referencing nested classes in exception specification

Olaf Spinczyk os at aspectc.org
Wed Jan 2 15:42:59 CET 2008


Hi Panu,

the lookup scope that is used to parse the named type after "throw" in
line 6 of ExceptTest.cpp seems to be wrong. This is clearly a parser
bug. I have created a bugzilla entry. The ID is 351.

Thanks,

Olaf


Panu Bloigu schrieb:
> Hello.
>
> I have run across a problem with compiling the following three files. I
> have tested this with both 1.0pre3 and an SVN version checked out today.
>
>
> =============================================
> File: ExcepTest.h
> =============================================
> 1:    class ExcepTest
> 2:    {
> 3:    public:
> 4:            ExcepTest();
> 5:            virtual ~ExcepTest();
> 6:            class Exception{};
> 7:            void method() throw (Exception);
> 8:    };
> =============================================
>
> =============================================
> File: ExcepTest.cpp
> =============================================
> 1:    #include "ExcepTest.h"
> 2:    ExcepTest::ExcepTest(){}
> 3:
> 4:    ExcepTest::~ExcepTest(){}
> 5:
> 6:    void ExcepTest::method() throw (Exception)
> 7:    {
> 8:            throw new Exception();
> 9:    }
> =============================================
>
> =============================================
> File: main.cpp
> =============================================
> 1:    #include "ExcepTest.h"
> 2:    int main()
> 3:    {
> 4:            ExcepTest et;
> 5:            return 0;
> 6:    }
> =============================================
>
>
>
> When I issue the command (with 1.0pre3):
> =============================================
> ag++ -k -v9 --keep_acc ExcepTest.cpp main.cpp -o main
> =============================================
>
> the compiler woes:
> =============================================
> *
> *
> * AG++ Configuration:
> *   Create puma.config: 1
> *   Aspect C++ weaver:  ac++
> *   C++ compiler:       g++
> *   Files:               ExcepTest.cpp main.cpp
> *   Options (G++):       -v -I"." -I"."
> *   Options (AC++):      -k -v9 -p.
> *   Options (total):     -k -v9 -v ExcepTest.cpp -I"." main.cpp -I"." -p.
> *   Weave: 1 Compile: 1 Link: 1
> *
> *
> * Generating Puma configuration file
>    - Parsing output of g++ compiler
>    - Executing: "g++"  -v -I"." -I"." -E -dM -v -x c++ "/dev/null"
> 2>ExcepTest.cpp.err.out 1>ExcepTest.cpp.std.out
>    - Exit: Success
>    - removing temporary file: ExcepTest.cpp.std.out
>    - removing temporary file: ExcepTest.cpp.err.out
>    - Writing puma configuration file
> * Weaving
>    - Executing: "ac++" --config "puma.config"  -k -v9 -p. -c
> "ExcepTest.cpp" -o "ExcepTest.acc"
> * Running ac++ 1.0pre3
> * Handling Translation Unit `ExcepTest.cpp'.
>    - Path "ExcepTest.cpp"
>    - Inserting namespace AC
>    - Parsing ...
> ExcepTest.cpp:6: error: invalid declaration near token `Exception'
>    - Aborting
> error: Execution failed: "ac++" --config "puma.config"  -k -v9 -p. -c
> "ExcepTest.cpp" -o "ExcepTest.acc"
>    - Exitcode: 256 (should be 0 )
>
> =============================================
>
>
> With g++ this compiles fine. I have tried compiling this also in Eclipse
> with the latest ACDT.
>
> Note, however, that if I change the exception specification of the
> method ExcepTest::method in the file ExcepTest.cpp so that it references
> the inner class Exception with it's fully qualified name, the
> compilation goes fine. In other words, if the line 6 in the file
> ExcepTest.cpp reads 'void ExcepTest::method() throw
> (ExcepTest::Exception)', the compilation succeeds.
>
> Why doesn't ac++ allow referencing a nested type in the exception
> specification if g++ does? Is it against the C++ Standard? Also note
> that if I define the method ExcepTest::method in the header file, then
> the fully qualified name is not needed in the exception specification.
>
>
> --Panu.
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>




More information about the aspectc-user mailing list