aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1998-06-01 11:25:35 -0700
committerPer Bothner <bothner@gcc.gnu.org>1998-06-01 11:25:35 -0700
commitea419909d41ccfbed527b4959d02be4b958ad22c (patch)
tree2e2c94662fd2d15e43f68afbd4801a03d7e0166e
parenteff71ab0ab951b6711adf0adac40a0aca6b8e633 (diff)
downloadgcc-ea419909d41ccfbed527b4959d02be4b958ad22c.zip
gcc-ea419909d41ccfbed527b4959d02be4b958ad22c.tar.gz
gcc-ea419909d41ccfbed527b4959d02be4b958ad22c.tar.bz2
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
-rw-r--r--gcc/cp/cp-tree.h16
-rw-r--r--gcc/cp/method.c71
-rw-r--r--gcc/cp/typeck.c2
3 files changed, 35 insertions, 54 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 2c7917b..fa423e1 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -60,10 +60,10 @@ Boston, MA 02111-1307, USA. */
0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE).
1: TYPE_HAS_CONSTRUCTOR.
2: TYPE_HAS_DESTRUCTOR.
- 3: Not used.
+ 3: TYPE_FOR_JAVA.
4: TYPE_NEEDS_DESTRUCTOR.
5: IS_AGGR_TYPE.
- 6: TYPE_BUILT_IN
+ 6: TYPE_BUILT_IN.
Usage of DECL_LANG_FLAG_?:
0: DECL_ERROR_REPORTED (in VAR_DECL).
@@ -280,6 +280,15 @@ extern tree intSI_type_node, unsigned_intSI_type_node;
extern tree intDI_type_node, unsigned_intDI_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_null;
extern tree current_function_return_value;
@@ -490,6 +499,9 @@ enum languages { lang_c, lang_cplusplus, lang_java };
/* In a *_TYPE, nonzero means a built-in type. */
#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) \
(!flag_vtable_thunks ? \
TREE_VALUE (CONSTRUCTOR_ELTS (ENTRY)) \
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 2679d3e..effaf33 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -83,7 +83,6 @@ static int issue_ktype PROTO((tree));
static void build_overload_scope_ref PROTO((tree));
static void build_mangled_template_parm_index PROTO((char *, 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_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
@@ -1042,7 +1041,7 @@ build_mangled_name (parmtypes, begin, end)
typevec[maxtype++] = parmtype;
if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2]
- && ! is_java_type (parmtype))
+ && ! TYPE_FOR_JAVA (parmtype))
{
Nrepeats++;
continue;
@@ -1068,7 +1067,7 @@ build_mangled_name (parmtypes, begin, end)
if ((parmtype != TYPE_MAIN_VARIANT (parmtype)
|| (TREE_CODE (parmtype) != INTEGER_TYPE
&& TREE_CODE (parmtype) != REAL_TYPE))
- && ! is_java_type (parmtype))
+ && ! TYPE_FOR_JAVA (parmtype))
TREE_USED (parmtype) = 1;
}
if (TYPE_PTRMEMFUNC_P (parmtype))
@@ -1115,7 +1114,7 @@ process_modifiers (parmtype)
if (TREE_CODE (parmtype) == INTEGER_TYPE
&& (TYPE_MAIN_VARIANT (parmtype)
== unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
- && ! is_java_type (parmtype))
+ && ! TYPE_FOR_JAVA (parmtype))
{
OB_PUTC ('U');
}
@@ -1123,23 +1122,6 @@ process_modifiers (parmtype)
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
if not, add it. Otherwise emit the code and return TRUE */
static int
@@ -1311,39 +1293,17 @@ process_overload_item (parmtype, extra_Gcode)
}
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);
if (parmtype == integer_type_node
- || parmtype == unsigned_type_node)
+ || parmtype == unsigned_type_node
+ || parmtype == java_int_type_node)
OB_PUTC ('i');
else if (parmtype == long_integer_type_node
|| parmtype == long_unsigned_type_node)
OB_PUTC ('l');
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');
else if (parmtype == signed_char_type_node)
{
@@ -1351,12 +1311,15 @@ process_overload_item (parmtype, extra_Gcode)
OB_PUTC ('c');
}
else if (parmtype == char_type_node
- || parmtype == unsigned_char_type_node)
+ || parmtype == unsigned_char_type_node
+ || parmtype == java_byte_type_node)
OB_PUTC ('c');
- else if (parmtype == wchar_type_node)
+ else if (parmtype == wchar_type_node
+ || parmtype == java_char_type_node)
OB_PUTC ('w');
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');
#if 0
/* it would seem there is no way to enter these in source code,
@@ -1365,6 +1328,8 @@ process_overload_item (parmtype, extra_Gcode)
|| parmtype == long_long_long_unsigned_type_node)
OB_PUTC ('q');
#endif
+ else if (parmtype == java_boolean_type_node)
+ OB_PUTC ('b');
else
my_friendly_abort (73);
break;
@@ -1377,9 +1342,11 @@ process_overload_item (parmtype, extra_Gcode)
parmtype = TYPE_MAIN_VARIANT (parmtype);
if (parmtype == long_double_type_node)
OB_PUTC ('r');
- else if (parmtype == double_type_node)
+ else if (parmtype == double_type_node
+ || parmtype == java_double_type_node)
OB_PUTC ('d');
- else if (parmtype == float_type_node)
+ else if (parmtype == float_type_node
+ || parmtype == java_float_type_node)
OB_PUTC ('f');
else my_friendly_abort (74);
break;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 63b2adc..785c33b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -754,6 +754,8 @@ comptypes (type1, type2, strict)
return 0;
if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
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
definition. Note that we already checked for equality of the type