}
/* Create default copy constructor, if needed. */
- if (! TYPE_HAS_INIT_REF (t) && ! IS_SIGNATURE (t))
+ if (! TYPE_HAS_INIT_REF (t) && ! IS_SIGNATURE (t) && ! TYPE_FOR_JAVA (t))
{
/* ARM 12.18: You get either X(X&) or X(const X&), but
not both. --Chip */
TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|= TYPE_HAS_ASSIGN_REF (t) || TYPE_USES_VIRTUAL_BASECLASSES (t);
- if (! TYPE_HAS_ASSIGN_REF (t) && ! IS_SIGNATURE (t))
+ if (! TYPE_HAS_ASSIGN_REF (t) && ! IS_SIGNATURE (t) && ! TYPE_FOR_JAVA (t))
{
tree default_fn = cons_up_default_function (t, name,
5 + no_const_asn_ref);
pop_lang_context ()
{
current_lang_name = *--current_lang_stack;
- if (current_lang_name == lang_name_cplusplus)
+ if (current_lang_name == lang_name_cplusplus
+ || current_lang_name == lang_name_java)
strict_prototype = strict_prototypes_lang_cplusplus;
else if (current_lang_name == lang_name_c)
strict_prototype = strict_prototypes_lang_c;
tree unsigned_intDI_type_node;
tree unsigned_intTI_type_node;
+tree java_byte_type_node;
+tree java_short_type_node;
+tree java_int_type_node;
+tree java_long_type_node;
+tree java_float_type_node;
+tree java_double_type_node;
+tree java_char_type_node;
+tree java_boolean_type_node;
+
/* A VOID_TYPE node, and the same, packaged in a TREE_LIST. */
tree void_type_node, void_list_node;
{
newdecl = 1;
d = build_decl (TYPE_DECL, name, type);
+ if (current_lang_name == lang_name_java)
+ TYPE_FOR_JAVA (type) = 1;
SET_DECL_ARTIFICIAL (d);
if (! in_class)
set_identifier_type_value_with_scope (name, type, b);
}
}
+/* Record one of the standard Java types.
+ * Declare it as having the given NAME.
+ * If SIZE > 0, it is the size of one of the integral types;
+ * otherwise it is the negative of the size of one of the other types. */
+
+static tree
+record_builtin_java_type (name, size)
+ char *name;
+ int size;
+{
+ tree type, decl;
+ if (size > 0)
+ type = make_signed_type (size);
+ else if (size > -32)
+ { /* "__java_char" or ""__java_boolean". */
+ type = make_unsigned_type (-size);
+ /*if (size == -1) TREE_SET_CODE (type, BOOLEAN_TYPE);*/
+ }
+ else
+ { /* "__java_float" or ""__java_double". */
+ type = make_node (REAL_TYPE);
+ TYPE_PRECISION (type) = - size;
+ layout_type (type);
+ }
+ record_builtin_type (RID_MAX, name, type);
+ decl = TYPE_NAME (type);
+ DECL_IGNORED_P (decl) = 1;
+ TYPE_FOR_JAVA (type) = 1;
+ return type;
+}
+
/* Push a type into the namespace so that the back-ends ignore it. */
static void
TREE_TYPE (complex_long_double_type_node) = long_double_type_node;
layout_type (complex_long_double_type_node);
+ java_byte_type_node = record_builtin_java_type ("__java_byte", 8);
+ java_short_type_node = record_builtin_java_type ("__java_short", 16);
+ java_int_type_node = record_builtin_java_type ("__java_int", 32);
+ java_long_type_node = record_builtin_java_type ("__java_long", 64);
+ java_float_type_node = record_builtin_java_type ("__java_float", -32);
+ java_double_type_node = record_builtin_java_type ("__java_double", -64);
+ java_char_type_node = record_builtin_java_type ("__java_char", -16);
+ java_boolean_type_node = record_builtin_java_type ("__java_boolean", -1);
+
integer_zero_node = build_int_2 (0, 0);
TREE_TYPE (integer_zero_node) = integer_type_node;
integer_one_node = build_int_2 (1, 0);
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
- if (check)
+ if ((! TYPE_FOR_JAVA (ctype) || check_java_method (ctype, decl))
+ && check)
{
tmp = check_classfn (ctype, decl);
template_count,
2 * (funcdef_flag != 0) +
4 * (friendp != 0));
-
- if (ctype != NULL_TREE && check)
+ if (ctype != NULL_TREE
+ && (! TYPE_FOR_JAVA (ctype) || check_java_method (ctype, decl))
+ && check)
{
tmp = check_classfn (ctype, decl);
in typenames, fields or parameters. */
if (constp || volatilep)
type = cp_build_type_variant (type, constp, volatilep);
+ if (current_lang_name == lang_name_java)
+ TYPE_FOR_JAVA (type) = 1;
if (decl_context == FIELD)
{
if (IS_SIGNATURE (current_class_type) && opaque_typedef)
SIGNATURE_HAS_OPAQUE_TYPEDECLS (current_class_type) = 1;
}
- else if (current_lang_name == lang_name_java)
- decl = build_lang_decl (TYPE_DECL, declarator, type);
else
{
/* Make sure this typedef lives as long as its type,
continue;
}
+ if (TYPE_FOR_JAVA (basetype)
+ && current_lang_stack == current_lang_base)
+ TYPE_FOR_JAVA (ref) = 1;
+
/* Note that the BINFO records which describe individual
inheritances are *not* shared in the lattice! They
cannot be shared because a given baseclass may be
cp_error ("template declaration of `%#D'", decl);
}
+/* Return true iff TYPE is a valid Java parameter or return type. */
+
+int
+acceptable_java_type (type)
+ tree type;
+{
+ if (TREE_CODE (type) == VOID_TYPE || TYPE_FOR_JAVA (type))
+ return 1;
+ if (TREE_CODE (type) == POINTER_TYPE)
+ {
+ type = TREE_TYPE (type);
+ if (TREE_CODE (type) == RECORD_TYPE)
+ {
+ complete_type (type);
+ return TYPE_FOR_JAVA (type);
+ }
+ }
+ return 0;
+}
+
+/* For a METHOD in a Java class CTYPE, return 1 if
+ the parameter and return types are valid Java types.
+ Otherwise, print appropriate error messages, and return 0. */
+
+int
+check_java_method (ctype, method)
+ tree ctype, method;
+{
+ int jerr = 0;
+ tree arg_types = TYPE_ARG_TYPES (TREE_TYPE (method));
+ tree ret_type = TREE_TYPE (TREE_TYPE (method));
+ if (! acceptable_java_type (ret_type))
+ {
+ cp_error ("Java method '%D' has non-Java return type `%T'",
+ method, ret_type);
+ jerr++;
+ }
+ for (; arg_types != NULL_TREE; arg_types = TREE_CHAIN (arg_types))
+ {
+ tree type = TREE_VALUE (arg_types);
+ if (! acceptable_java_type (type))
+ {
+ cp_error ("Java method '%D' has non-Java parameter type `%T'",
+ method, type);
+ jerr++;
+ }
+ }
+ return jerr ? 0 : 1;
+}
+
/* Sanity check: report error if this function FUNCTION is not
really a member of the class (CTYPE) it is supposed to belong to.
CNAME is the same here as it is for grokclassfn above. */