Commit a1774733 by Benjamin Kosnik

cp-tree.h (start_decl): Update prototype.

d
Thu Apr  9 22:16:57 1998  Per Bothner  <bothner@cygnus.com>
        * cp-tree.h (start_decl):  Update prototype.
        * decl.c (start_decl):  Like the C version, new parameters
        for the attributes.  Call cplus_decl_attributes here,
        (pushdecl):  Like C version, do build_type_copy if TYPE_DECL,
        (grokdeclarator):  Pass NULL for new start_decl arguments.
        * pt.c (tsubst_expr):  Likewise.
        * parse.y:  Merge cplus_decl_attribute calls into start_decl calls.
	* typeck.c (common_type): Check TYPE_MAIN_VARIANT.
	* lex.c (build_lang_decl): Add lang_name_java.
	* class.c (push_lang_context): Add lang_name_java.
	* method.c (build_mangled_name): Check for is_java_type.
Thu Apr  9 22:16:57 1998  Benjamin Kosnik  <bkoz@loony.cygnus.com>
	* decl.c (grokdeclarator): Check TYPE_MAIN_VARIANT.
	* call.c (build_scoped_method_call): Check for TREE_CODE for
	VOID_TYPE instead of type ==  void_type_node.
	(build_method_call): Ditto.
	* decl.c (lookup_name_real): Ditto.
	(grokdeclarator): Ditto.
	(start_decl): Ditto.
	(grokparms): Ditto.
	(start_function): Ditto.
	(finish_function): Ditto.
	(start_method): Ditto.
also fixes g++/15415

From-SVN: r19071
parent 2e076ddf
......@@ -382,11 +382,12 @@ build_scoped_method_call (exp, basetype, name, parms)
and template parms. */
if (TREE_CODE (name) == BIT_NOT_EXPR && ! IS_AGGR_TYPE (basetype))
{
if (type != basetype)
if (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (basetype))
cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')",
exp, basetype, type);
name = TREE_OPERAND (name, 0);
if (basetype != name && basetype != get_type_value (name))
if (TYPE_MAIN_VARIANT (basetype) != name
&& basetype != get_type_value (name))
cp_error ("qualified type `%T' does not match destructor name `~%T'",
basetype, name);
return cp_convert (void_type_node, exp);
......@@ -630,7 +631,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
basetype = TREE_TYPE (instance);
if (TREE_CODE (basetype) == REFERENCE_TYPE)
basetype = TREE_TYPE (basetype);
if (! (name == basetype
if (! (name == TYPE_MAIN_VARIANT (basetype)
|| (IS_AGGR_TYPE (basetype)
&& name == constructor_name (basetype))
|| basetype == get_type_value (name)))
......
......@@ -131,7 +131,7 @@ tree *current_lang_base, *current_lang_stack;
int current_lang_stacksize;
/* Names of languages we recognize. */
tree lang_name_c, lang_name_cplusplus;
tree lang_name_c, lang_name_cplusplus, lang_name_java;
tree current_lang_name;
/* When layout out an aggregate type, the size of the
......@@ -4886,7 +4886,7 @@ push_lang_context (name)
current_lang_stacksize += 10;
}
if (name == lang_name_cplusplus)
if (name == lang_name_cplusplus || name == lang_name_java)
{
strict_prototype = strict_prototypes_lang_cplusplus;
current_lang_name = name;
......
......@@ -4373,6 +4373,8 @@ build_lang_decl (code, name, type)
DECL_LANGUAGE (t) = lang_cplusplus;
else if (current_lang_name == lang_name_c)
DECL_LANGUAGE (t) = lang_c;
else if (current_lang_name == lang_name_java)
DECL_LANGUAGE (t) = lang_java;
else my_friendly_abort (64);
SET_DECL_NAMESPACE (t, current_namespace);
......
......@@ -1044,7 +1044,8 @@ build_mangled_name (parmtypes, begin, end)
/* Every argument gets counted. */
typevec[maxtype++] = parmtype;
if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2])
if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2]
&& ! is_java_type (parmtype))
{
Nrepeats++;
continue;
......@@ -1067,9 +1068,10 @@ build_mangled_name (parmtypes, begin, end)
}
/* Only cache types which take more than one character. */
if (parmtype != TYPE_MAIN_VARIANT (parmtype)
|| (TREE_CODE (parmtype) != INTEGER_TYPE
&& TREE_CODE (parmtype) != REAL_TYPE))
if ((parmtype != TYPE_MAIN_VARIANT (parmtype)
|| (TREE_CODE (parmtype) != INTEGER_TYPE
&& TREE_CODE (parmtype) != REAL_TYPE))
&& ! is_java_type (parmtype))
TREE_USED (parmtype) = 1;
}
if (TYPE_PTRMEMFUNC_P (parmtype))
......@@ -1113,14 +1115,34 @@ process_modifiers (parmtype)
if (TREE_READONLY (parmtype))
OB_PUTC ('C');
if (TREE_CODE (parmtype) == INTEGER_TYPE &&
TYPE_MAIN_VARIANT (parmtype) ==
unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
OB_PUTC ('U');
if (TREE_CODE (parmtype) == INTEGER_TYPE
&& (TYPE_MAIN_VARIANT (parmtype)
== unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
&& ! is_java_type (parmtype))
{
OB_PUTC ('U');
}
if (TYPE_VOLATILE (parmtype))
OB_PUTC ('V');
}
/* True iff TYPE was declared as a "Java" type (inside extern "Java"). */
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
......@@ -1292,6 +1314,30 @@ 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)
......
......@@ -318,8 +318,8 @@ parse_decl(declarator, specs_attrs, attributes, initialized, decl)
used_extern_spec = 1;
}
sm = suspend_momentary ();
*decl = start_decl (declarator, current_declspecs, initialized);
cplus_decl_attributes (*decl, attributes, prefix_attributes);
*decl = start_decl (declarator, current_declspecs, initialized,
attributes, prefix_attributes);
return sm;
}
%}
......@@ -942,9 +942,8 @@ condition:
}
current_declspecs = $1.t;
$<itype>5 = suspend_momentary ();
$<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $4,
/*prefix_attributes*/ NULL_TREE);
$<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
$4, /*prefix_attributes*/ NULL_TREE);
}
init
{
......@@ -1769,14 +1768,14 @@ maybeasm:
initdcl:
declarator maybeasm maybe_attribute '='
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
$3, prefix_attributes); }
init
/* Note how the declaration of the variable is in effect while its init is parsed! */
{ cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
| declarator maybeasm maybe_attribute
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0);
cplus_decl_attributes ($<ttype>$, $3, prefix_attributes);
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
$3, prefix_attributes);
cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
;
......
......@@ -5014,7 +5014,7 @@ tsubst_expr (t, args, in_decl)
dcl = start_decl
(tsubst (TREE_OPERAND (t, 0), args, in_decl),
tsubst (TREE_OPERAND (t, 1), args, in_decl),
TREE_OPERAND (t, 2) != 0);
TREE_OPERAND (t, 2) != 0, NULL_TREE, NULL_TREE);
init = tsubst_expr (TREE_OPERAND (t, 2), args, in_decl);
cp_finish_decl
(dcl, init, NULL_TREE, 1, /*init ? LOOKUP_ONLYCONVERTING :*/ 0);
......
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