Commit e9bf587a by Geoffrey Keating Committed by Geoffrey Keating

Index: objc/ChangeLog

2005-10-20  Geoffrey Keating  <geoffk@apple.com>

	* objc-act.c (synth_module_prologue): Clear TREE_NOTHROW
	on objc_msgSend and like builtin functions.

Index: testsuite/ChangeLog
2005-10-20  Geoffrey Keating  <geoffk@apple.com>

	* obj-c++.dg/except-1.mm: New.

From-SVN: r105704
parent 9738dadd
2005-10-20 Geoffrey Keating <geoffk@apple.com>
* objc-act.c (synth_module_prologue): Clear TREE_NOTHROW
on objc_msgSend and like builtin functions.
2005-10-17 Andreas Krebbel <krebbel1@de.ibm.com> 2005-10-17 Andreas Krebbel <krebbel1@de.ibm.com>
* objc-act.c (objc_build_component_ref): Adjust call to * objc-act.c (objc_build_component_ref): Adjust call to
......
...@@ -1597,6 +1597,10 @@ synth_module_prologue (void) ...@@ -1597,6 +1597,10 @@ synth_module_prologue (void)
(xref_tag (RECORD_TYPE, (xref_tag (RECORD_TYPE,
get_identifier (UTAG_IVAR_LIST))); get_identifier (UTAG_IVAR_LIST)));
/* TREE_NOTHROW is cleared for the message-sending functions,
because the function that gets called can throw in Obj-C++, or
could itself call something that can throw even in Obj-C. */
if (flag_next_runtime) if (flag_next_runtime)
{ {
/* NB: In order to call one of the ..._stret (struct-returning) /* NB: In order to call one of the ..._stret (struct-returning)
...@@ -1626,12 +1630,21 @@ synth_module_prologue (void) ...@@ -1626,12 +1630,21 @@ synth_module_prologue (void)
type, 0, NOT_BUILT_IN, type, 0, NOT_BUILT_IN,
NULL, NULL_TREE); NULL, NULL_TREE);
/* These can throw, because the function that gets called can throw
in Obj-C++, or could itself call something that can throw even
in Obj-C. */
TREE_NOTHROW (umsg_decl) = 0;
TREE_NOTHROW (umsg_nonnil_decl) = 0;
TREE_NOTHROW (umsg_stret_decl) = 0;
TREE_NOTHROW (umsg_nonnil_stret_decl) = 0;
/* id objc_msgSend_Fast (id, SEL, ...) /* id objc_msgSend_Fast (id, SEL, ...)
__attribute__ ((hard_coded_address (OFFS_MSGSEND_FAST))); */ __attribute__ ((hard_coded_address (OFFS_MSGSEND_FAST))); */
#ifdef OFFS_MSGSEND_FAST #ifdef OFFS_MSGSEND_FAST
umsg_fast_decl = builtin_function (TAG_MSGSEND_FAST, umsg_fast_decl = builtin_function (TAG_MSGSEND_FAST,
type, 0, NOT_BUILT_IN, type, 0, NOT_BUILT_IN,
NULL, NULL_TREE); NULL, NULL_TREE);
TREE_NOTHROW (umsg_fast_decl) = 0;
DECL_ATTRIBUTES (umsg_fast_decl) DECL_ATTRIBUTES (umsg_fast_decl)
= tree_cons (get_identifier ("hard_coded_address"), = tree_cons (get_identifier ("hard_coded_address"),
build_int_cst (NULL_TREE, OFFS_MSGSEND_FAST), build_int_cst (NULL_TREE, OFFS_MSGSEND_FAST),
...@@ -1654,6 +1667,8 @@ synth_module_prologue (void) ...@@ -1654,6 +1667,8 @@ synth_module_prologue (void)
umsg_super_stret_decl = builtin_function (TAG_MSGSENDSUPER_STRET, umsg_super_stret_decl = builtin_function (TAG_MSGSENDSUPER_STRET,
type, 0, NOT_BUILT_IN, 0, type, 0, NOT_BUILT_IN, 0,
NULL_TREE); NULL_TREE);
TREE_NOTHROW (umsg_super_decl) = 0;
TREE_NOTHROW (umsg_super_stret_decl) = 0;
} }
else else
{ {
...@@ -1676,6 +1691,7 @@ synth_module_prologue (void) ...@@ -1676,6 +1691,7 @@ synth_module_prologue (void)
umsg_decl = builtin_function (TAG_MSGSEND, umsg_decl = builtin_function (TAG_MSGSEND,
type, 0, NOT_BUILT_IN, type, 0, NOT_BUILT_IN,
NULL, NULL_TREE); NULL, NULL_TREE);
TREE_NOTHROW (umsg_decl) = 0;
/* IMP objc_msg_lookup_super (struct objc_super *, SEL); */ /* IMP objc_msg_lookup_super (struct objc_super *, SEL); */
type type
...@@ -1686,6 +1702,7 @@ synth_module_prologue (void) ...@@ -1686,6 +1702,7 @@ synth_module_prologue (void)
umsg_super_decl = builtin_function (TAG_MSGSENDSUPER, umsg_super_decl = builtin_function (TAG_MSGSENDSUPER,
type, 0, NOT_BUILT_IN, type, 0, NOT_BUILT_IN,
NULL, NULL_TREE); NULL, NULL_TREE);
TREE_NOTHROW (umsg_super_decl) = 0;
/* The following GNU runtime entry point is called to initialize /* The following GNU runtime entry point is called to initialize
each module: each module:
......
2005-10-20 Geoffrey Keating <geoffk@apple.com> 2005-10-20 Geoffrey Keating <geoffk@apple.com>
* obj-c++.dg/except-1.mm: New.
* obj-c++.dg/stubify-2.mm: Update the name of the RTL dump file. * obj-c++.dg/stubify-2.mm: Update the name of the RTL dump file.
2005-10-21 Alan Modra <amodra@bigpond.net.au> 2005-10-21 Alan Modra <amodra@bigpond.net.au>
/* { dg-do run { target "*-*-darwin*" } } */
/* { dg-options "-framework Foundation" } */
/* This tests that exceptions work. It used to fail because
objc_msgSend was marked with DECL_NOTHROW.
If you include objc/Object.h, the problem goes away, because
that file includes objc/objc-runtime.h which explicitly prototypes
objc_msgSend without 'nothrow'. */
#include <Foundation/Foundation.h>
#include <stdio.h>
#include <stdlib.h>
// ObjectiveC class header
@interface ObjCclass : NSObject {
}
-(void)method1;
-(void)method2;
@end
// C++ class header
class CPPclass {
public:
void function1();
};
// Main
int main(int argc, char *argv[])
{
ObjCclass * foo = [[ObjCclass alloc] init];
[foo method1];
exit (0);
}
// ObjectiveC implementation
@implementation ObjCclass
-(void) method1
{
try {
[self method2];
}
catch(...) {
return;
}
}
-(void) method2
{
CPPclass foo;
foo.function1();
}
@end
// C++ implementation
void CPPclass::function1()
{
throw (1);
/* Shouldn't be here because we threw. */
abort ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment