This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

java/1166: compiler rejects inner-class argument to inner-class constructor



>Number:         1166
>Category:       java
>Synopsis:       compiler rejects inner-class argument to inner-class constructor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:16:42 PST 2000
>Closed-Date:    Wed Mar 22 23:27:33 PST 2000
>Last-Modified:  Mon Apr 24 20:50:00 PDT 2000
>Originator:     Bryce McKinlay
>Release:        gcc version 2.96 20000313 (experimental)
>Organization:
>Environment:
Linux Is Not UniX
>Description:
// jc1 (2.96 20000313) says "`A_Inner' not found"

public class InnerConstructor
{
  class A_Inner 
  {
    A_Inner (A_Inner i) {}
  }  
}
>How-To-Repeat:
Try to compile the test case.
>Fix:
Yet an other patch available.

>Release-Note:

>Audit-Trail:

Formerly PR gcj/172


From: tromey@sourceware.cygnus.com
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: gcj/172
Date: 14 Mar 2000 18:37:19 -0000

 CVSROOT:	/cvs/java
 Module name:	libgcj
 Changes by:	tromey@sourceware.cygnus.com	00/03/14 10:37:19
 
 Modified files:
 	libjava/testsuite: ChangeLog 
 Added files:
 	libjava/testsuite/libjava.compile: pr172.java 
 
 Log message:
 	* libjava.compile/pr172.java: New file, for PR gcj/172.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/gcc/libjava/testsuite/ChangeLog.diff?cvsroot=java&r1=1.68&r2=1.69
 http://gcc.gnu.org/cgi-bin/gcc/libjava/testsuite/libjava.compile/pr172.java.diff?cvsroot=java&r1=NONE&r2=1.1
 
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Tue Mar 14 17:18:08 2000
State-Changed-Why:
    There is a compiler patch.

From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/172
Date: 15 Mar 2000 01:18:08 -0000

 Synopsis: compiler rejects inner-class argument to inner-class constructor
 
 State-Changed-From-To: open->feedback
 State-Changed-By: apbianco
 State-Changed-When: Tue Mar 14 17:18:08 2000
 State-Changed-Why:
     There is a compiler patch.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=172&database=java

From: Bryce McKinlay <bryce@albatross.co.nz>
To: apbianco@cygnus.com
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/172
Date: Wed, 15 Mar 2000 22:04:49 +1300

 The patch works fine for me. Thanks Alex.
 
   [ bryce ]
 
 
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Wed Mar 15 01:30:57 2000
State-Changed-Why:
    I checked in the following patch:
    
      http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00516.html

From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/172
Date: 15 Mar 2000 09:30:57 -0000

 Synopsis: compiler rejects inner-class argument to inner-class constructor
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: apbianco
 State-Changed-When: Wed Mar 15 01:30:57 2000
 State-Changed-Why:
     I checked in the following patch:
     
       http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00516.html
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=172&database=java
State-Changed-From-To: closed->feedback
State-Changed-By: apbianco
State-Changed-When: Wed Mar 15 15:22:14 2000
State-Changed-Why:
    The patch caused a regression. Here's a better patch to
    fix 172, 174 and 176.

From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/172
Date: 15 Mar 2000 23:22:14 -0000

 Synopsis: compiler rejects inner-class argument to inner-class constructor
 
 State-Changed-From-To: closed->feedback
 State-Changed-By: apbianco
 State-Changed-When: Wed Mar 15 15:22:14 2000
 State-Changed-Why:
     The patch caused a regression. Here's a better patch to
     fix 172, 174 and 176.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=172&database=java

From: Bryce McKinlay <bryce@albatross.co.nz>
To: apbianco@cygnus.com
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/172
Date: Thu, 16 Mar 2000 13:20:49 +1300

 The new patch works for all three test cases.
 
 But here's another variation to keep you busy:
 
 // InnerConstructor2.java:9: Superclass `A' of class `InnerConstructor2$B' not
 found.
 public class InnerConstructor2
 {
   class A {}
   class B extends A {}
 }
 
 Again, it seems to be looking at the top-level scope for "A" instead of finding
 the inner class declaration first.
 
   [ bryce ]
 
 

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/172
Date: Wed, 15 Mar 2000 16:59:26 -0800 (PST)

 Bryce McKinlay writes:
 > And here's another, although I'm guessing this might be a seperate issue:
 
 Yes, I'm going to file a PR for this one. With the revised patch to
 fix InnerConstructor2.java, you run into the same problem. I need to
 reorder the list which tells how innerclasses are expanded...
 
 By the way, here's the revised patch to fix InnerConstructor2.java+172+174+176.
 
 ./A
 
 2000-03-15  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
 	* parse.y (register_incomplete_type): JDEP_ENCLOSING set
 	depending on the type of dependency which dictates what the
 	current class is.
 	(unresolved_type_p): Resolved types limited to the current class.
 
 Index: parse.y
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
 retrieving revision 1.145
 diff -u -p -r1.145 parse.y
 --- parse.y	2000/03/15 09:30:39	1.145
 +++ parse.y	2000/03/16 00:52:11
 @@ -4702,9 +4702,16 @@ unresolved_type_p (wfl, returned)
  {
    if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
      {
 -      tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
        if (returned)
 -	*returned = (decl ? TREE_TYPE (decl) : NULL_TREE);
 +	{
 +	  tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
 +	  if (decl && current_class && (decl == TYPE_NAME (current_class)))
 +	    *returned = TREE_TYPE (decl);
 +	  else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
 +	    *returned = TREE_TYPE (GET_CPC ());
 +	  else
 +	    *returned = NULL_TREE;
 +	}
        return 1;
      }
    if (returned)
 @@ -4883,7 +4890,10 @@ register_incomplete_type (kind, wfl, dec
    JDEP_WFL (new) = wfl;
    JDEP_CHAIN (new) = NULL;
    JDEP_MISC (new) = NULL_TREE;
 -  if(!(JDEP_ENCLOSING (new) = GET_ENCLOSING_CPC_CONTEXT ()))
 +  if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
 +      && GET_ENCLOSING_CPC ())
 +    JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
 +  else
      JDEP_ENCLOSING (new) = GET_CPC ();
    JDEP_GET_PATCH (new) = (tree *)NULL;
  
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Wed Mar 22 23:27:33 2000
State-Changed-Why:
    I checked in a patch to fix the bug:
      http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00790.html
    

From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
  java-gnats@sourceware.cygnus.com
Cc:  
Subject: Re: gcj/172
Date: 23 Mar 2000 07:27:33 -0000

 Synopsis: compiler rejects inner-class argument to inner-class constructor
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: apbianco
 State-Changed-When: Wed Mar 22 23:27:33 2000
 State-Changed-Why:
     I checked in a patch to fix the bug:
       http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00790.html
     
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=172&database=java

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: Bryce McKinlay <bryce@albatross.co.nz>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/172
Date: Mon, 24 Apr 2000 20:42:48 -0700 (PDT)

 Bryce McKinlay writes:
 
 > And here's another, although I'm guessing this might be a seperate
 > issue:
 
 Yes. I just posted a patch. It's related to the PR #177.
 
 ./A
 
 2000-04-24  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
 	* class.c (common_enclosing_context_p): New function.
 	* parse.h (INNER_ENCLOSING_SCOPE_CHECK): Relaxed test to allow
 	classes sharing an outer context with the current instance.
 	* parse.y (verify_constructor_super): Skip enclosing context
 	argument in the case of a pure inner class constructor.
 	(patch_method_invocation): Insert enclosing context as second
 	parameter to pure inner class constructor super invocations.
 
 Index: class.c
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/class.c,v
 retrieving revision 1.65
 diff -u -p -r1.65 class.c
 --- class.c	2000/04/06 01:01:11	1.65
 +++ class.c	2000/04/25 03:20:49
 @@ -486,6 +486,30 @@ enclosing_context_p (type1, type2)
    return 0;
  }
  
 +/* Return 1 iff there exists a common enclosing context between TYPE1
 +   and TYPE2.  */
 +
 +int common_enclosing_context_p (type1, type2)
 +     tree type1, type2;
 +{
 +  if (!PURE_INNER_CLASS_TYPE_P (type2) && !PURE_INNER_CLASS_TYPE_P (type2))
 +    return 0;
 +  
 +  for (type1 = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type1))); type1; 
 +       type1 = (PURE_INNER_CLASS_TYPE_P (type1) ?
 +		TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type1))) : NULL_TREE))
 +    {
 +      tree current;
 +      for (current = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type2))); current;
 +	   current = (PURE_INNER_CLASS_TYPE_P (current) ?
 +		      TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current))) : 
 +		      NULL_TREE))
 +	if (type1 == current)
 +	  return 1;
 +    }
 +  return 0;
 +}
 +
  static void
  add_interface_do (basetype_vec, interface_class, i)
       tree basetype_vec, interface_class;
 Index: parse.h
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
 retrieving revision 1.51
 diff -u -p -r1.51 parse.h
 --- parse.h	2000/04/24 16:17:03	1.51
 +++ parse.h	2000/04/25 03:20:51
 @@ -822,15 +822,17 @@ struct parser_ctxt {
  
  /* Make sure that innerclass T sits in an appropriate enclosing
     context.  */
 -#define INNER_ENCLOSING_SCOPE_CHECK(T)					\
 -  (INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T))			\
 -   && ((current_this							\
 -	/* We have a this and it's not the right one */			\
 -	&& (DECL_CONTEXT (TYPE_NAME ((T)))				\
 -	    != TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))	\
 -	&& !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)),	\
 -			     TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T)))))	\
 -       /* We don't have a this. */					\
 +#define INNER_ENCLOSING_SCOPE_CHECK(T)					      \
 +  (INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T))			      \
 +   && ((current_this							      \
 +	/* We have a this and it's not the right one */			      \
 +	&& (DECL_CONTEXT (TYPE_NAME ((T)))				      \
 +	    != TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))	      \
 +	&& !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)),	      \
 +			     TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))	      \
 +        && !common_enclosing_context_p (TREE_TYPE (TREE_TYPE (current_this)), \
 +					(T)))				      \
 +       /* We don't have a this. */					      \
         || !current_this))
  
  /* Push macro. First argument to PUSH_CPC is a DECL_TYPE, second
 Index: parse.y
 ===================================================================
 RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
 retrieving revision 1.155
 diff -u -p -r1.155 parse.y
 --- parse.y	2000/04/24 23:27:39	1.155
 +++ parse.y	2000/04/25 03:21:25
 @@ -8220,11 +8220,14 @@ verify_constructor_super (mdecl)
      }
    else
      {
 +      int inner = PURE_INNER_CLASS_TYPE_P (class);
        for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
  	{
 -	  if (DECL_CONSTRUCTOR_P (sdecl)
 -	      && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl))) 
 -	         == end_params_node)
 +	  tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
 +	  if (inner)
 +	    arg = TREE_CHAIN (arg);
 +		      
 +	  if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
  	    return 0;
  	}
      }
 @@ -9501,6 +9504,13 @@ patch_method_invocation (patch, primary,
        else
  	args = tree_cons (NULL_TREE, integer_zero_node, args);
      }
 +
 +  /* This handles the situation where a constructor invokation needs
 +     to have an enclosing context passed as a second parameter (the
 +     constructor is one of an inner class.) */
 +  if (is_super_init
 +      && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
 +    args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
  
    is_static_flag = METHOD_STATIC (list);
    if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
 
>Unformatted:



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]