Commit ea419909 by Per Bothner

cp-tree.h (TYPE_FOR_JAVA): New macro.

a
	* cp-tree.h (TYPE_FOR_JAVA):  New macro.
	* decl.c, cp-tree.h (java_byte_type_node, java_short_type_node,
	java_int_type_node, java_long_type_node, java_float_type_node,
	java_double_type_node, java_char_type_node, java_boolean_type_node):
	New "primitive" types, with predefined names __java_byte etc.
	(record_builtin_java_type):  New function.
	(init_decl_processing):  Make Java types with record_builtin_java_type.
	(pushtag, grokdeclarator):  Set TYPE_FOR_JAVA if in extern "JAVA".
	(xref_baseypes):  If base class was TYPE_FOR_JAVA, so is this class.
	(grokfndecl):  Call check_java_method for Java classes.
	* method.c (is_java_type):  Removed.  Replaced with TYPE_FOR_JAVA.
	(process_overload_item):  Match types against specific
	java_XX_type_node types, rather than using is_java_type.
	* class.c (finish_struct_1):  Don't add default copy constructor
	or operator= if TYPE_FOR_JAVA.
	(pop_lang_conext):  Restore strict_prototyp proper if Java.
	* decl2.c (acceptable_java_type, check_java_method):  New functions.
	* pt.c (instantiate_class_template):  Copy TYPE_FOR_JAVA from pattern.
	(tsubst):  Move common statement after if statement.
	* typeck.c (comptypes):  If strict, TYPE_FOR_JAVA must match.

From-SVN: r20175
parent eff71ab0
...@@ -60,10 +60,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -60,10 +60,10 @@ Boston, MA 02111-1307, USA. */
0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE). 0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE).
1: TYPE_HAS_CONSTRUCTOR. 1: TYPE_HAS_CONSTRUCTOR.
2: TYPE_HAS_DESTRUCTOR. 2: TYPE_HAS_DESTRUCTOR.
3: Not used. 3: TYPE_FOR_JAVA.
4: TYPE_NEEDS_DESTRUCTOR. 4: TYPE_NEEDS_DESTRUCTOR.
5: IS_AGGR_TYPE. 5: IS_AGGR_TYPE.
6: TYPE_BUILT_IN 6: TYPE_BUILT_IN.
Usage of DECL_LANG_FLAG_?: Usage of DECL_LANG_FLAG_?:
0: DECL_ERROR_REPORTED (in VAR_DECL). 0: DECL_ERROR_REPORTED (in VAR_DECL).
...@@ -280,6 +280,15 @@ extern tree intSI_type_node, unsigned_intSI_type_node; ...@@ -280,6 +280,15 @@ extern tree intSI_type_node, unsigned_intSI_type_node;
extern tree intDI_type_node, unsigned_intDI_type_node; extern tree intDI_type_node, unsigned_intDI_type_node;
extern tree intTI_type_node, unsigned_intTI_type_node; extern tree intTI_type_node, unsigned_intTI_type_node;
extern tree java_byte_type_node;
extern tree java_short_type_node;
extern tree java_int_type_node;
extern tree java_long_type_node;
extern tree java_float_type_node;
extern tree java_double_type_node;
extern tree java_char_type_node;
extern tree java_boolean_type_node;
extern int current_function_returns_value; extern int current_function_returns_value;
extern int current_function_returns_null; extern int current_function_returns_null;
extern tree current_function_return_value; extern tree current_function_return_value;
...@@ -490,6 +499,9 @@ enum languages { lang_c, lang_cplusplus, lang_java }; ...@@ -490,6 +499,9 @@ enum languages { lang_c, lang_cplusplus, lang_java };
/* In a *_TYPE, nonzero means a built-in type. */ /* In a *_TYPE, nonzero means a built-in type. */
#define TYPE_BUILT_IN(NODE) TYPE_LANG_FLAG_6(NODE) #define TYPE_BUILT_IN(NODE) TYPE_LANG_FLAG_6(NODE)
/* True if this a "Java" type, defined in 'extern "Java"'. */
#define TYPE_FOR_JAVA(NODE) TYPE_LANG_FLAG_3(NODE)
#define DELTA_FROM_VTABLE_ENTRY(ENTRY) \ #define DELTA_FROM_VTABLE_ENTRY(ENTRY) \
(!flag_vtable_thunks ? \ (!flag_vtable_thunks ? \
TREE_VALUE (CONSTRUCTOR_ELTS (ENTRY)) \ TREE_VALUE (CONSTRUCTOR_ELTS (ENTRY)) \
......
...@@ -83,7 +83,6 @@ static int issue_ktype PROTO((tree)); ...@@ -83,7 +83,6 @@ static int issue_ktype PROTO((tree));
static void build_overload_scope_ref PROTO((tree)); static void build_overload_scope_ref PROTO((tree));
static void build_mangled_template_parm_index PROTO((char *, tree)); static void build_mangled_template_parm_index PROTO((char *, tree));
static int check_btype PROTO((tree)); static int check_btype PROTO((tree));
static int is_java_type PROTO((tree));
# define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0) # define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
# define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C))) # define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
...@@ -1042,7 +1041,7 @@ build_mangled_name (parmtypes, begin, end) ...@@ -1042,7 +1041,7 @@ build_mangled_name (parmtypes, begin, end)
typevec[maxtype++] = parmtype; typevec[maxtype++] = parmtype;
if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2] if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2]
&& ! is_java_type (parmtype)) && ! TYPE_FOR_JAVA (parmtype))
{ {
Nrepeats++; Nrepeats++;
continue; continue;
...@@ -1068,7 +1067,7 @@ build_mangled_name (parmtypes, begin, end) ...@@ -1068,7 +1067,7 @@ build_mangled_name (parmtypes, begin, end)
if ((parmtype != TYPE_MAIN_VARIANT (parmtype) if ((parmtype != TYPE_MAIN_VARIANT (parmtype)
|| (TREE_CODE (parmtype) != INTEGER_TYPE || (TREE_CODE (parmtype) != INTEGER_TYPE
&& TREE_CODE (parmtype) != REAL_TYPE)) && TREE_CODE (parmtype) != REAL_TYPE))
&& ! is_java_type (parmtype)) && ! TYPE_FOR_JAVA (parmtype))
TREE_USED (parmtype) = 1; TREE_USED (parmtype) = 1;
} }
if (TYPE_PTRMEMFUNC_P (parmtype)) if (TYPE_PTRMEMFUNC_P (parmtype))
...@@ -1115,7 +1114,7 @@ process_modifiers (parmtype) ...@@ -1115,7 +1114,7 @@ process_modifiers (parmtype)
if (TREE_CODE (parmtype) == INTEGER_TYPE if (TREE_CODE (parmtype) == INTEGER_TYPE
&& (TYPE_MAIN_VARIANT (parmtype) && (TYPE_MAIN_VARIANT (parmtype)
== unsigned_type (TYPE_MAIN_VARIANT (parmtype))) == unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
&& ! is_java_type (parmtype)) && ! TYPE_FOR_JAVA (parmtype))
{ {
OB_PUTC ('U'); OB_PUTC ('U');
} }
...@@ -1123,23 +1122,6 @@ process_modifiers (parmtype) ...@@ -1123,23 +1122,6 @@ process_modifiers (parmtype)
OB_PUTC ('V'); OB_PUTC ('V');
} }
/* True iff TYPE was declared as a "Java" type (inside extern "Java"). */
static int
is_java_type (type)
tree type;
{
if (TYPE_NAME (type) != NULL_TREE)
{
tree decl = TYPE_NAME (type);
if (TREE_CODE (decl) == TYPE_DECL
&& DECL_LANG_SPECIFIC (decl) != NULL
&& DECL_LANGUAGE (decl) == lang_java)
return 1;
}
return 0;
}
/* Check to see if a tree node has been entered into the Bcode typelist /* Check to see if a tree node has been entered into the Bcode typelist
if not, add it. Otherwise emit the code and return TRUE */ if not, add it. Otherwise emit the code and return TRUE */
static int static int
...@@ -1311,39 +1293,17 @@ process_overload_item (parmtype, extra_Gcode) ...@@ -1311,39 +1293,17 @@ process_overload_item (parmtype, extra_Gcode)
} }
case INTEGER_TYPE: case INTEGER_TYPE:
/* "Java" integer types should mangle the same on all platforms,
and only depend on precision, not target 'int' size. */
if (is_java_type (parmtype))
{
if (TREE_UNSIGNED (parmtype))
{
switch (TYPE_PRECISION (parmtype))
{
case 8: OB_PUTC ('b'); return;
case 16: OB_PUTC ('w'); return;
}
}
else
{
switch (TYPE_PRECISION (parmtype))
{
case 8: OB_PUTC ('c'); return;
case 16: OB_PUTC ('s'); return;
case 32: OB_PUTC ('i'); return;
case 64: OB_PUTC ('x'); return;
}
}
}
parmtype = TYPE_MAIN_VARIANT (parmtype); parmtype = TYPE_MAIN_VARIANT (parmtype);
if (parmtype == integer_type_node if (parmtype == integer_type_node
|| parmtype == unsigned_type_node) || parmtype == unsigned_type_node
|| parmtype == java_int_type_node)
OB_PUTC ('i'); OB_PUTC ('i');
else if (parmtype == long_integer_type_node else if (parmtype == long_integer_type_node
|| parmtype == long_unsigned_type_node) || parmtype == long_unsigned_type_node)
OB_PUTC ('l'); OB_PUTC ('l');
else if (parmtype == short_integer_type_node else if (parmtype == short_integer_type_node
|| parmtype == short_unsigned_type_node) || parmtype == short_unsigned_type_node
|| parmtype == java_short_type_node)
OB_PUTC ('s'); OB_PUTC ('s');
else if (parmtype == signed_char_type_node) else if (parmtype == signed_char_type_node)
{ {
...@@ -1351,12 +1311,15 @@ process_overload_item (parmtype, extra_Gcode) ...@@ -1351,12 +1311,15 @@ process_overload_item (parmtype, extra_Gcode)
OB_PUTC ('c'); OB_PUTC ('c');
} }
else if (parmtype == char_type_node else if (parmtype == char_type_node
|| parmtype == unsigned_char_type_node) || parmtype == unsigned_char_type_node
|| parmtype == java_byte_type_node)
OB_PUTC ('c'); OB_PUTC ('c');
else if (parmtype == wchar_type_node) else if (parmtype == wchar_type_node
|| parmtype == java_char_type_node)
OB_PUTC ('w'); OB_PUTC ('w');
else if (parmtype == long_long_integer_type_node else if (parmtype == long_long_integer_type_node
|| parmtype == long_long_unsigned_type_node) || parmtype == long_long_unsigned_type_node
|| parmtype == java_long_type_node)
OB_PUTC ('x'); OB_PUTC ('x');
#if 0 #if 0
/* it would seem there is no way to enter these in source code, /* it would seem there is no way to enter these in source code,
...@@ -1365,6 +1328,8 @@ process_overload_item (parmtype, extra_Gcode) ...@@ -1365,6 +1328,8 @@ process_overload_item (parmtype, extra_Gcode)
|| parmtype == long_long_long_unsigned_type_node) || parmtype == long_long_long_unsigned_type_node)
OB_PUTC ('q'); OB_PUTC ('q');
#endif #endif
else if (parmtype == java_boolean_type_node)
OB_PUTC ('b');
else else
my_friendly_abort (73); my_friendly_abort (73);
break; break;
...@@ -1377,9 +1342,11 @@ process_overload_item (parmtype, extra_Gcode) ...@@ -1377,9 +1342,11 @@ process_overload_item (parmtype, extra_Gcode)
parmtype = TYPE_MAIN_VARIANT (parmtype); parmtype = TYPE_MAIN_VARIANT (parmtype);
if (parmtype == long_double_type_node) if (parmtype == long_double_type_node)
OB_PUTC ('r'); OB_PUTC ('r');
else if (parmtype == double_type_node) else if (parmtype == double_type_node
|| parmtype == java_double_type_node)
OB_PUTC ('d'); OB_PUTC ('d');
else if (parmtype == float_type_node) else if (parmtype == float_type_node
|| parmtype == java_float_type_node)
OB_PUTC ('f'); OB_PUTC ('f');
else my_friendly_abort (74); else my_friendly_abort (74);
break; break;
......
...@@ -754,6 +754,8 @@ comptypes (type1, type2, strict) ...@@ -754,6 +754,8 @@ comptypes (type1, type2, strict)
return 0; return 0;
if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2)) if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
return 0; return 0;
if (strict > 0 && TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
return 0;
/* Allow for two different type nodes which have essentially the same /* Allow for two different type nodes which have essentially the same
definition. Note that we already checked for equality of the type definition. Note that we already checked for equality of the type
......
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