+Wed Dec 2 15:52:25 1998 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * class.c (layout_class_method): Call build_java_argument_signature
+ on constructors too.
+ * parse.y (check_method_redefinition): Use TYPE_ARGUMENT_SIGNATURE.
+ (patch_method_invocation): Define a primary when resolving an
+ expression name. Augmented comment on code checking illegal `this'
+ usage. Loosened it test by accepting NEW_CLASS_EXPR.
+
Tue Dec 1 13:53:24 1998 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (layout_class_method): Don't report error on non-static
else
DECL_NAME (method_decl) = get_identifier (p);
DECL_CONSTRUCTOR_P (method_decl) = 1;
+ build_java_argument_signature (TREE_TYPE (method_decl));
}
else if (! METHOD_STATIC (method_decl) && !DECL_ARTIFICIAL (method_decl))
{
{
tree redef, name;
tree cl = DECL_NAME (method);
- tree sig = TYPE_LANG_SPECIFIC (TREE_TYPE (method))->signature;
+ tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
/* decl name of artificial <clinit> and <finit> doesn't need to be fixed and
checked */
for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
{
- struct lang_type *t = TYPE_LANG_SPECIFIC (TREE_TYPE (redef));
-
- if (! t || (redef == method))
+ if (redef == method)
break;
- if (DECL_NAME (redef) == name && sig == t->signature)
+ if (DECL_NAME (redef) == name
+ && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
{
parse_error_context
(cl, "Duplicate %s declaration `%s'",
field = resolve_field_access (wfl, NULL, &type);
if (field == error_mark_node)
PATCH_METHOD_RETURN_ERROR ();
+ /* field is used in lieu of a primary. It alows us not to
+ report errors on erroneous use of `this' in
+ constructors. */
+ primary = field;
/* 2- Do the layout of the class where the last field
was found, so we can search it. */
is_static_flag = METHOD_STATIC (list);
- /* In the context of an explicit constructor invocation, we can't invoke
- any method relying on `this' */
+ /* In the context of an explicit constructor invocation, we can't
+ invoke any method relying on `this'. Exceptions are: we're
+ invoking a static function, primary exists and is not the current
+ this, we're creating a new object. */
if (ctxp->explicit_constructor_p
- && !is_static_flag && (!primary || primary == current_this))
+ && !is_static_flag
+ && (!primary || primary == current_this)
+ && (TREE_CODE (patch) != NEW_CLASS_EXPR))
{
parse_error_context
(wfl, "Can't reference `this' before the superclass constructor has "
{
tree redef, name;
tree cl = DECL_NAME (method);
- tree sig = TYPE_LANG_SPECIFIC (TREE_TYPE (method))->signature;
+ tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
/* decl name of artificial <clinit> and <finit> doesn't need to be fixed and
checked */
for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
{
- struct lang_type *t = TYPE_LANG_SPECIFIC (TREE_TYPE (redef));
-
- if (! t || (redef == method))
+ if (redef == method)
break;
- if (DECL_NAME (redef) == name && sig == t->signature)
+ if (DECL_NAME (redef) == name
+ && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
{
parse_error_context
(cl, "Duplicate %s declaration `%s'",
field = resolve_field_access (wfl, NULL, &type);
if (field == error_mark_node)
PATCH_METHOD_RETURN_ERROR ();
+ /* field is used in lieu of a primary. It alows us not to
+ report errors on erroneous use of `this' in
+ constructors. */
+ primary = field;
/* 2- Do the layout of the class where the last field
was found, so we can search it. */
is_static_flag = METHOD_STATIC (list);
- /* In the context of an explicit constructor invocation, we can't invoke
- any method relying on `this' */
+ /* In the context of an explicit constructor invocation, we can't
+ invoke any method relying on `this'. Exceptions are: we're
+ invoking a static function, primary exists and is not the current
+ this, we're creating a new object. */
if (ctxp->explicit_constructor_p
- && !is_static_flag && (!primary || primary == current_this))
+ && !is_static_flag
+ && (!primary || primary == current_this)
+ && (TREE_CODE (patch) != NEW_CLASS_EXPR))
{
parse_error_context
(wfl, "Can't reference `this' before the superclass constructor has "