-/* Return nonzero value if DECL is a Java type suitable for catch or
- throw. */
-
-static bool
-decl_is_java_type (tree decl, int err)
-{
- bool r = (TYPE_PTR_P (decl)
- && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
- && TYPE_FOR_JAVA (TREE_TYPE (decl)));
-
- if (err)
- {
- if (TREE_CODE (decl) == REFERENCE_TYPE
- && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
- && TYPE_FOR_JAVA (TREE_TYPE (decl)))
- {
- /* Can't throw a reference. */
- error ("type %qT is disallowed in Java %<throw%> or %<catch%>",
- decl);
- }
-
- if (r)
- {
- tree jthrow_node
- = IDENTIFIER_GLOBAL_VALUE (get_identifier ("jthrowable"));
-
- if (jthrow_node == NULL_TREE)
- fatal_error
- ("call to Java %<catch%> or %<throw%> with %<jthrowable%> undefined");
-
- jthrow_node = TREE_TYPE (TREE_TYPE (jthrow_node));
-
- if (! DERIVED_FROM_P (jthrow_node, TREE_TYPE (decl)))
- {
- /* Thrown object must be a Throwable. */
- error ("type %qT is not derived from %<java::lang::Throwable%>",
- TREE_TYPE (decl));
- }
- }
- }
-
- return r;
-}
-
-/* Select the personality routine to be used for exception handling,
- or issue an error if we need two different ones in the same
- translation unit.
- ??? At present DECL_FUNCTION_PERSONALITY is set via
- LANG_HOOKS_EH_PERSONALITY. Should it be done here instead? */
-void
-choose_personality_routine (enum languages lang)
-{
- static enum {
- chose_none,
- chose_cpp,
- chose_java,
- gave_error
- } state;
-
- switch (state)
- {
- case gave_error:
- return;
-
- case chose_cpp:
- if (lang != lang_cplusplus)
- goto give_error;
- return;
-
- case chose_java:
- if (lang != lang_java)
- goto give_error;
- return;
-
- case chose_none:
- ; /* Proceed to language selection. */
- }
-
- switch (lang)
- {
- case lang_cplusplus:
- state = chose_cpp;
- break;
-
- case lang_java:
- state = chose_java;
- terminate_node = builtin_decl_explicit (BUILT_IN_ABORT);
- pragma_java_exceptions = true;
- break;
-
- default:
- gcc_unreachable ();
- }
- return;
-
- give_error:
- error ("mixing C++ and Java catches in a single translation unit");
- state = gave_error;
-}
-