From 6df8a9dd552113f43274ba4bf09830d2525ff4e9 Mon Sep 17 00:00:00 2001 From: zack Date: Sun, 13 May 2001 01:28:18 +0000 Subject: gcc/cp: * except.c (choose_personality_routine): Export. Add explanatory comment. Take an enum languages, not a boolean. (initialize_handler_parm): Adjust to match. * cp-tree.h: Prototype choose_personality_routine. * lex.c (handle_pragma_java_exceptions): New function. (init_cp_pragma): Register #pragma GCC java_exceptions. gcc: * extend.texi: Document #pragma GCC java_exceptions. libjava: * Makefile.am (libgcj_la_OBJECTS): Remove libsupc++convenience.la. * Makefile.in: Regenerate (by hand). * include/jvm.h: Add #pragma GCC java_exceptions at top of file. * doc/cni.sgml: Document #pragma GCC java_exceptions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42027 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/doc/cni.sgml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libjava/doc/cni.sgml') diff --git a/libjava/doc/cni.sgml b/libjava/doc/cni.sgml index 0c82ca67ddd..495e3e9c5a5 100644 --- a/libjava/doc/cni.sgml +++ b/libjava/doc/cni.sgml @@ -779,6 +779,31 @@ if (i >= count) throw new java::lang::IndexOutOfBoundsException(); + +Normally, GNU C++ will automatically detect when you are writing C++ +code that uses Java exceptions, and handle them appropriately. +However, if C++ code only needs to execute destructors when Java +exceptions are thrown through it, GCC will guess incorrectly. Sample +problematic code: + + struct S { ~S(); }; + extern void bar(); // is implemented in Java and may throw exceptions + void foo() + { + S s; + bar(); + } + +The usual effect of an incorrect guess is a link failure, complaining of +a missing routine called __gxx_personality_v0. + + +You can inform the compiler that Java exceptions are to be used in a +translation unit, irrespective of what it might think, by writing +#pragma GCC java_exceptions at the head of the +file. This #pragma must appear before any +functions that throw or catch exceptions, or run destructors when +exceptions are thrown through them. Synchronization -- cgit v1.2.3