]> gcc.gnu.org Git - gcc.git/commitdiff
class.c (layout_class_method): Call build_java_argument_signature on constructors...
authorAlexandre Petit-Bianco <apbianco@cygnus.com>
Wed, 2 Dec 1998 16:47:33 +0000 (16:47 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Wed, 2 Dec 1998 16:47:33 +0000 (08:47 -0800)
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.

From-SVN: r24065

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/parse.c
gcc/java/parse.y

index e3b33a20d0808b9b73f3f500d1c4a6c31fbde15d..c597e10af81d8379d0f263a9aa6958a9b6546d55 100644 (file)
@@ -1,3 +1,12 @@
+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
index dedff9e5facf6cb448829170bb12cae36f77b978..8deff6eebb9bb570f98ddb6e680acd6635055c65 100644 (file)
@@ -1578,6 +1578,7 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
       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))
     {
index 3683f98d063b05fa0cffb1f2d98a5c4787c514e4..6d1feb0d5880896de9f125e73b26186d7248754a 100644 (file)
@@ -6969,7 +6969,7 @@ check_method_redefinition (class, method)
 {
   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 */
 
@@ -6983,11 +6983,10 @@ check_method_redefinition (class, method)
   
   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'",
@@ -9234,6 +9233,10 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl, super)
          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. */
@@ -9367,10 +9370,14 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl, super)
 
   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 "
index aa9d076056681f25e01d87f454fb3bd7c23153fa..807ed9c9e7458de0bb15d8b86c6423a7ad675834 100644 (file)
@@ -4364,7 +4364,7 @@ check_method_redefinition (class, method)
 {
   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 */
 
@@ -4378,11 +4378,10 @@ check_method_redefinition (class, method)
   
   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'",
@@ -6629,6 +6628,10 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl, super)
          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. */
@@ -6762,10 +6765,14 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl, super)
 
   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 "
This page took 0.10451 seconds and 5 git commands to generate.