OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [obj-c++.dg/] [except-1.mm] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
/* { dg-do run } */
/* { dg-do run } */
/* This tests that exceptions work.  It used to fail because
/* This tests that exceptions work.  It used to fail because
   objc_msgSend was marked with DECL_NOTHROW.
   objc_msgSend was marked with DECL_NOTHROW.
   If you include objc/Object.h, the problem goes away, because
   If you include objc/Object.h, the problem goes away, because
   that file includes objc/objc-runtime.h which explicitly prototypes
   that file includes objc/objc-runtime.h which explicitly prototypes
   objc_msgSend without 'nothrow'.  */
   objc_msgSend without 'nothrow'.  */
#include 
#include 
#include 
#include 
@interface Object {
@interface Object {
  Class isa;
  Class isa;
}
}
+ alloc;
+ alloc;
- init;
- init;
@end
@end
// ObjectiveC class header
// ObjectiveC class header
@interface ObjCclass : Object {
@interface ObjCclass : Object {
}
}
-(void)method1;
-(void)method1;
-(void)method2;
-(void)method2;
@end
@end
// C++ class header
// C++ class header
class CPPclass {
class CPPclass {
public:
public:
        void function1();
        void function1();
};
};
// Main
// Main
int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
{
        ObjCclass * foo = [[ObjCclass alloc] init];
        ObjCclass * foo = [[ObjCclass alloc] init];
        [foo method1];
        [foo method1];
        exit (0);
        exit (0);
}
}
// ObjectiveC implementation
// ObjectiveC implementation
@implementation ObjCclass
@implementation ObjCclass
-(void) method1
-(void) method1
{
{
        try {
        try {
                [self method2];
                [self method2];
        }
        }
        catch(...) {
        catch(...) {
                return;
                return;
        }
        }
}
}
-(void) method2
-(void) method2
{
{
        CPPclass foo;
        CPPclass foo;
        foo.function1();
        foo.function1();
}
}
@end
@end
// C++ implementation
// C++ implementation
void CPPclass::function1()
void CPPclass::function1()
{
{
        throw (1);
        throw (1);
        /* Shouldn't be here because we threw.  */
        /* Shouldn't be here because we threw.  */
        abort ();
        abort ();
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.