public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: java/4352: jc1 gets confused looking for array of local class
@ 2001-09-20  0:06 Alexandre Petit-Bianco
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Petit-Bianco @ 2001-09-20  0:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR java/4352; it has been noted by GNATS.

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: per@bothner.com, gcc-gnats@gcc.gnu.org, rhug-rhats@sources.redhat.com,
        gcc-patches@gcc.gnu.org
Cc:  
Subject: Re: java/4352: jc1 gets confused looking for array of local class
Date: Thu, 20 Sep 2001 00:00:43 -0700 (PDT)

 Alexandre Petit-Bianco writes:
 
 > I'll work on a fix, it shouldn't take too long.
 
 Here's a complete patch. It requires approval for the gcc part. I
 started to test it, I'm now bootstrapping on linux/x86.
 
 ./A
 
 gcc:
 
 2001-09-19  Alexandre Petit-Bianco  <apbianco@redhat.com>
 
 	* stringpool.c (get_identifier_with_length): New function.
 	* tree.h (get_identifier_with_length): New prototype.
 
 Index: stringpool.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/stringpool.c,v
 retrieving revision 1.10
 diff -u -p -u -r1.10 stringpool.c
 --- stringpool.c	2001/08/22 14:35:48	1.10
 +++ stringpool.c	2001/09/20 06:51:12
 @@ -109,6 +109,22 @@ get_identifier (text)
    return HT_IDENT_TO_GCC_IDENT (ht_node);
  }
  
 +/* Identical to get_identifier, except that the length is assumed
 +   known.  */
 +   
 +tree
 +get_identifier_with_length (text, length)
 +     const char *text;
 +     unsigned int length;
 +{
 +  hashnode ht_node = ht_lookup (ident_hash,
 +				(const unsigned char *) text,
 +				length, HT_ALLOC);
 +
 +  /* ht_node can't be NULL here.  */
 +  return HT_IDENT_TO_GCC_IDENT (ht_node);
 +}
 +
  /* If an identifier with the name TEXT (a null-terminated string) has
     previously been referred to, return that node; otherwise return
     NULL_TREE.  */
 Index: tree.h
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/tree.h,v
 retrieving revision 1.264
 diff -u -p -u -r1.264 tree.h
 --- tree.h	2001/09/06 08:59:35	1.264
 +++ tree.h	2001/09/20 06:51:14
 @@ -1991,6 +1991,11 @@ extern tree make_tree_vec		PARAMS ((int)
  
  extern tree get_identifier		PARAMS ((const char *));
  
 +/* Identical to get_identifier, except that the length is assumed
 +   known.  */
 +
 +extern tree get_identifier_with_length  PARAMS ((const char *, unsigned int));
 +
  /* If an identifier with the name TEXT (a null-terminated string) has
     previously been referred to, return that node; otherwise return
     NULL_TREE.  */
 
 gcc/java:
 
 2001-09-19  Alexandre Petit-Bianco  <apbianco@redhat.com>
 
 	* parse.h: (WFL_STRIP_BRACKET): Re-written using
 	build_type_name_from_array_name.
 	(STRING_STRIP_BRACKETS): New macro.
 	* parse.y (build_type_name_from_array_name): New function.
 	(array_creation_expression:): Accumulate []s instead of [s.
 	(cast_expression:): Accumulate []s instead of [s after cast type
 	name.
 	(build_array_from_name): Local string deleted, use
 	build_type_name_from_array_name.
 	(build_unresolved_array_type): Accumulate []s instead of [s after
 	type name.
 	(register_fields): Fixed comment.
 	(resolve_class): Local name, base deleted, new locals tname and
 	array_dims. Use build_type_name_from_array_name. Use array_dims to
 	build array type.
 	(purify_type_name): Use STRING_STRIP_BRACKETS.
 
 Index: parse.h
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
 retrieving revision 1.76
 diff -u -p -r1.76 parse.h
 --- parse.h	2001/09/11 20:17:04	1.76
 +++ parse.h	2001/09/20 06:53:17
 @@ -562,24 +562,34 @@ typedef struct _jdeplist {
        }									\
    }
  
 -#define WFL_STRIP_BRACKET(TARGET, TYPE)					\
 -{									\
 -  tree __type = (TYPE);							\
 -  if (TYPE && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION)		\
 -    {									\
 -      tree _node = EXPR_WFL_NODE (TYPE);				\
 -      const char *_ptr = IDENTIFIER_POINTER (_node);			\
 -      const char *_ref = _ptr;						\
 -      while (_ptr[0] == '[')						\
 -	  _ptr++;							\
 -      if (_ref != _ptr)							\
 -	{								\
 -	  tree _new = copy_node (TYPE);					\
 -	  EXPR_WFL_NODE (_new) = get_identifier (_ptr);			\
 -	  __type = _new;						\
 -	}								\
 -    }									\
 -  (TARGET) = __type;							\
 +#define WFL_STRIP_BRACKET(TARGET, TYPE)					  \
 +{									  \
 +  tree __type = (TYPE);							  \
 +  if (TYPE && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION)		  \
 +    {									  \
 +      tree _node;							  \
 +      if (build_type_name_from_array_name (EXPR_WFL_NODE (TYPE), &_node)) \
 +        {								  \
 +          tree _new = copy_node (TYPE);					  \
 +          EXPR_WFL_NODE (_new) = _node;				  	  \
 +          __type = _new;						  \
 +        }								  \
 +    }									  \
 +  (TARGET) = __type;							  \
 +}
 +
 +/* If NAME contains one or more trailing []s, NAMELEN will be the
 +   adjusted to be the index of the last non bracket character in
 +   NAME. ARRAY_DIMS will contain the number of []s found.  */
 +
 +#define STRING_STRIP_BRACKETS(NAME, NAMELEN, ARRAY_DIMS)                  \
 +{									  \
 +  ARRAY_DIMS = 0;							  \
 +  while (NAMELEN >= 2 && (NAME)[NAMELEN - 1] == ']')			  \
 +    {									  \
 +      NAMELEN -= 2;							  \
 +      (ARRAY_DIMS)++;							  \
 +    }									  \
  }
  
  /* Promote a type if it won't be registered as a patch */
 Index: parse.y
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
 retrieving revision 1.312
 diff -u -p -r1.312 parse.y
 --- parse.y	2001/09/18 05:22:40	1.312
 +++ parse.y	2001/09/20 06:53:26
 @@ -179,6 +179,7 @@ static int valid_method_invocation_conve
  static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
  static tree try_reference_assignconv PARAMS ((tree, tree));
  static tree build_unresolved_array_type PARAMS ((tree));
 +static int build_type_name_from_array_name PARAMS ((tree, tree *));
  static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
  static tree build_array_ref PARAMS ((int, tree, tree));
  static tree patch_array_ref PARAMS ((tree));
 @@ -2121,7 +2122,8 @@ array_creation_expression:
  		  char *sig;
  		  int osb = pop_current_osb (ctxp);
  		  while (osb--)
 -		    obstack_1grow (&temporary_obstack, '[');
 +		    obstack_grow (&temporary_obstack, "[]", 2);
 +		  obstack_1grow (&temporary_obstack, '\0');
  		  sig = obstack_finish (&temporary_obstack);
  		  $$ = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
  			      $2, get_identifier (sig), $4);
 @@ -2366,11 +2368,12 @@ cast_expression:		/* Error handling here
  		{ 
  		  const char *ptr;
  		  int osb = pop_current_osb (ctxp); 
 +		  obstack_grow (&temporary_obstack, 
 +				IDENTIFIER_POINTER (EXPR_WFL_NODE ($2)),
 +				IDENTIFIER_LENGTH (EXPR_WFL_NODE ($2)));
  		  while (osb--)
 -		    obstack_1grow (&temporary_obstack, '[');
 -		  obstack_grow0 (&temporary_obstack, 
 -				 IDENTIFIER_POINTER (EXPR_WFL_NODE ($2)),
 -				 IDENTIFIER_LENGTH (EXPR_WFL_NODE ($2)));
 +		    obstack_grow (&temporary_obstack, "[]", 2);
 +		  obstack_1grow (&temporary_obstack, '\0');
  		  ptr = obstack_finish (&temporary_obstack);
  		  EXPR_WFL_NODE ($2) = get_identifier (ptr);
  		  $$ = build_cast ($1.location, $2, $5);
 @@ -3254,25 +3257,42 @@ variable_redefinition_error (context, na
  		       type_name, IDENTIFIER_POINTER (name), line);
  }
  
 +/* If ANAME is terminated with `[]', it indicates an array. This
 +   function returns the number of `[]' found and if this number is
 +   greater than zero, it extracts the array type name and places it in
 +   the node pointed to by TRIMMED unless TRIMMED is null.  */
 +
 +static int
 +build_type_name_from_array_name (aname, trimmed)
 +     tree aname;
 +     tree *trimmed;
 +{
 +  const char *name = IDENTIFIER_POINTER (aname);
 +  int len = IDENTIFIER_LENGTH (aname);
 +  int array_dims;
 +
 +  STRING_STRIP_BRACKETS (name, len, array_dims);
 +
 +  if (array_dims && trimmed)
 +    *trimmed = get_identifier_with_length (name, len);
 +
 +  return array_dims;
 +}
 +
  static tree
  build_array_from_name (type, type_wfl, name, ret_name)
       tree type, type_wfl, name, *ret_name;
  {
    int more_dims = 0;
 -  const char *string;
  
    /* Eventually get more dims */
 -  string = IDENTIFIER_POINTER (name);
 -  while (string [more_dims] == '[')
 -    more_dims++;
 +  more_dims = build_type_name_from_array_name (name, &name);
    
    /* If we have, then craft a new type for this variable */
    if (more_dims)
      {
        tree save = type;
  
 -      name = get_identifier (&string [more_dims]);
 -
        /* If we have a pointer, use its type */
        if (TREE_CODE (type) == POINTER_TYPE)
          type = TREE_TYPE (type);
 @@ -3289,12 +3309,9 @@ build_array_from_name (type, type_wfl, n
           on adding dimensions) */
        else if (type_wfl)
  	{
 -	  int i = 0;
  	  type = type_wfl;
 -	  string = IDENTIFIER_POINTER (TYPE_NAME (save));
 -	  while (string[i]  == '[')
 -	    ++i;
 -	  more_dims += i;
 +	  more_dims += build_type_name_from_array_name (TYPE_NAME (save),
 +							NULL);
  	}
  
        /* Add all the dimensions */
 @@ -3327,10 +3344,10 @@ build_unresolved_array_type (type_or_wfl
    if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
      return build_java_array_type (type_or_wfl, -1);
  
 -  obstack_1grow (&temporary_obstack, '[');
 -  obstack_grow0 (&temporary_obstack,
 +  obstack_grow (&temporary_obstack,
  		 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
  		 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
 +  obstack_grow0 (&temporary_obstack, "[]", 2);
    ptr = obstack_finish (&temporary_obstack);
    wfl = build_expr_wfl (get_identifier (ptr),
  			EXPR_WFL_FILENAME (type_or_wfl),
 @@ -4391,7 +4408,7 @@ register_fields (flags, type, variable_l
  /* Generate finit$, using the list of initialized fields to populate
     its body. finit$'s parameter(s) list is adjusted to include the
     one(s) used to initialized the field(s) caching outer context
 -   local(s). */
 +   local(s).  */
  
  static tree
  generate_finit (class_type)
 @@ -5680,9 +5697,9 @@ static tree
  resolve_class (enclosing, class_type, decl, cl)
       tree enclosing, class_type, decl, cl;
  {
 -  const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
 -  const char *base = name;
 +  tree tname = TYPE_NAME (class_type);
    tree resolved_type = TREE_TYPE (class_type);
 +  int array_dims = 0;
    tree resolved_type_decl;
    
    if (resolved_type != NULL_TREE)
 @@ -5700,13 +5717,9 @@ resolve_class (enclosing, class_type, de
  
    /* 1- Check to see if we have an array. If true, find what we really
       want to resolve  */
 -  while (name[0] == '[')
 -    name++;
 -  if (base != name)
 -    {
 -      TYPE_NAME (class_type) = get_identifier (name);
 -      WFL_STRIP_BRACKET (cl, cl);
 -    }
 +  if ((array_dims = build_type_name_from_array_name (tname,
 +						     &TYPE_NAME (class_type))))
 +    WFL_STRIP_BRACKET (cl, cl);
  
    /* 2- Resolve the bare type */
    if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, 
 @@ -5715,15 +5728,10 @@ resolve_class (enclosing, class_type, de
    resolved_type = TREE_TYPE (resolved_type_decl);
  
    /* 3- If we have and array, reconstruct the array down to its nesting */
 -  if (base != name)
 +  if (array_dims)
      {
 -      while (base != name)
 -	{
 -	  resolved_type = build_java_array_type (resolved_type, -1);
 -	  name--;
 -	}
 -      /* A TYPE_NAME that is a TYPE_DECL was set in
 -         build_java_array_type, return it. */
 +      for (; array_dims; array_dims--)
 +	resolved_type = build_java_array_type (resolved_type, -1);
        resolved_type_decl = TYPE_NAME (resolved_type);
      }
    TREE_TYPE (class_type) = resolved_type;
 @@ -5943,15 +5951,24 @@ resolve_no_layout (name, cl)
    return decl;
  }
  
 -/* Called when reporting errors. Skip leader '[' in a complex array
 -   type description that failed to be resolved.  */
 +/* Called when reporting errors. Skip the '[]'s in a complex array
 +   type description that failed to be resolved. purify_type_name can't
 +   use an identifier tree.  */
  
  static const char *
  purify_type_name (name)
       const char *name;
  {
 -  while (*name && *name == '[')
 -    name++;
 +  int len = strlen (name);
 +  int bracket_found;
 +
 +  STRING_STRIP_BRACKETS (name, len, bracket_found);
 +  if (bracket_found)
 +    {
 +      char *stripped_name = xmemdup (name, len, len+1);
 +      stripped_name [len] = '\0';
 +      return stripped_name;
 +    }
    return name;
  }
  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: java/4352: jc1 gets confused looking for array of local class
@ 2002-01-04 19:19 rodrigc
  0 siblings, 0 replies; 6+ messages in thread
From: rodrigc @ 2002-01-04 19:19 UTC (permalink / raw)
  To: apbianco, gcc-bugs, gcc-prs, java-prs, per

Synopsis: jc1 gets confused looking for array of local class

State-Changed-From-To: feedback->closed
State-Changed-By: rodrigc
State-Changed-When: Fri Jan  4 19:19:26 2002
State-Changed-Why:
    Patch applied:
    http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00779.html

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4352


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: java/4352: jc1 gets confused looking for array of local class
@ 2001-09-20 14:46 Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2001-09-20 14:46 UTC (permalink / raw)
  To: apbianco; +Cc: gcc-prs

The following reply was made to PR java/4352; it has been noted by GNATS.

From: Richard Henderson <rth@redhat.com>
To: Alexandre Petit-Bianco <apbianco@cygnus.com>
Cc: per@bothner.com, gcc-gnats@gcc.gnu.org, rhug-rhats@sources.redhat.com,
        gcc-patches@gcc.gnu.org
Subject: Re: java/4352: jc1 gets confused looking for array of local class
Date: Thu, 20 Sep 2001 14:43:21 -0700

 On Thu, Sep 20, 2001 at 12:00:43AM -0700, Alexandre Petit-Bianco wrote:
 > 	* stringpool.c (get_identifier_with_length): New function.
 > 	* tree.h (get_identifier_with_length): New prototype.
 
 Ok.
 
 
 r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: java/4352: jc1 gets confused looking for array of local class
@ 2001-09-20 14:10 apbianco
  0 siblings, 0 replies; 6+ messages in thread
From: apbianco @ 2001-09-20 14:10 UTC (permalink / raw)
  To: apbianco, gcc-bugs, gcc-prs, java-prs, nobody, per

Synopsis: jc1 gets confused looking for array of local class

Responsible-Changed-From-To: unassigned->apbianco
Responsible-Changed-By: apbianco
Responsible-Changed-When: Thu Sep 20 14:10:08 2001
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Thu Sep 20 14:10:08 2001
State-Changed-Why:
    Mine.

http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=4352&database=gcc


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: java/4352: jc1 gets confused looking for array of local class
@ 2001-09-19 13:46 Alexandre Petit-Bianco
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Petit-Bianco @ 2001-09-19 13:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR java/4352; it has been noted by GNATS.

From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: per@bothner.com
Cc: gcc-gnats@gcc.gnu.org, rhug-rhats@sources.redhat.com
Subject: Re: java/4352: jc1 gets confused looking for array of local class
Date: Wed, 19 Sep 2001 13:40:47 -0700 (PDT)

 per@bothner.com writes:
 
 > While building Tomcat (using Anthony Green's rhug packaging), jc1
 > complains incorrectly
 
 I can't reproduce this particular problem.
 
 > class_type that is:
 > 
 >  <pointer_type 0x4031fdec org.apache.tomcat.util.xml.XmlMapper$Rule[] VOID
 >     align 16 symtab 0 alias set -1>
 
 I see this case being handled, although incorrectly, I agree.
 
 > I think we should be consistent in that the name of a type is the
 > source-lvele name not the signature, whether the class comes from
 > .java or .class.
 
 Yes. Using terminating []s is fine. But then I'd have to change some
 other things. So, I suggest that you keep using your patch for the
 time being (and other rhug-rhats should probably do so.) Meanwhile,
 I'll work on a fix, it shouldn't take too long.
 
 ./A


^ permalink raw reply	[flat|nested] 6+ messages in thread

* java/4352: jc1 gets confused looking for array of local class
@ 2001-09-18 14:26 per
  0 siblings, 0 replies; 6+ messages in thread
From: per @ 2001-09-18 14:26 UTC (permalink / raw)
  To: gcc-gnats

>Number:         4352
>Category:       java
>Synopsis:       jc1 gets confused looking for array of local class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 18 14:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Per Bothner
>Release:        3.1 20010917 (experimental)
>Organization:
Brainfood
>Environment:
System: Linux eureka.bothner.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/bothner/GNU/gcc/configure --enable-threads=posix --prefix=/home/bothner/GNU/install-gcc --enable-languages=c++,java
>Description:
While building Tomcat (using Anthony Green's rhug packaging), jc1
complains incorrectly 
./upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java:23: Class `org.apache.tomcat.util.xml.XmlMapper' already defined in upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java:23.
   public class XmlMapper
>How-To-Repeat:
Try to build rhug.
make[1]: Entering directory `/home/bothner/Java/rhug/jakarta-tomcat'
source='upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java' object='upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.lo' libtool=yes \
depfile='.deps/upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.Plo' tmpdepfile='.deps/upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.TPlo' \
depmode=gcc3 /bin/sh ../depcomp \
/bin/sh ../libtool --mode=compile gcj  --encoding=UTF-8 -fassume-compiled -fCLASSPATH=./upstream/src/share:../jakarta-servletapi/upstream/src/share:../xerces/xerces-1.4.2.jar -O2 -c -o upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.lo `test -f upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java || echo './'`upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java
rm -f upstream/src/share/org/apache/tomcat/util/xml/.libs/XmlMapper.lo
gcj --encoding=UTF-8 -fassume-compiled -fCLASSPATH=./upstream/src/share:../jakarta-servletapi/upstream/src/share:../xerces/xerces-1.4.2.jar -O2 -c upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java -MT upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.lo -MD -MP -MF .deps/upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.TPlo    -fPIC  -o upstream/src/share/org/apache/tomcat/util/xml/.libs/XmlMapper.lo
./upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java:23: Class `org.apache.tomcat.util.xml.XmlMapper' already defined in upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java:23.
   public class XmlMapper
                ^
./upstream/src/share/org/apache/tomcat/util/xml/XmlMapper.java:49: confused by earlier errors, bailing out
>Fix:

The problem appears to be in resolve_class.  It gets passed a
class_type that is:

 <pointer_type 0x4031fdec org.apache.tomcat.util.xml.XmlMapper$Rule[] VOID
    align 16 symtab 0 alias set -1>

The code handles signature-style array type names:

  /* 1- Check to see if we have an array. If true, find what we really
     want to resolve  */
  while (name[0] == '[')
    name++;
  if (base != name)
    {
      TYPE_NAME (class_type) = get_identifier (name);
      WFL_STRIP_BRACKET (cl, cl);
    }

However, it does not handle type names that end in "[]".  Note that
for example build_java_array_type creates type names ending in "[]".
I believe this is as it should be.
The following patch seems to fix it.  However, note that it doesn't
enulate the old logic of WFL_STRIP_BRACKET.  I'm not sure what is
correct.

It might make sense to add an error at the WFL_STRIP_BRACKET so
we can fix the callers that pass signature-style type names.
I think we should be consistent in that the name of a type is
the source-lvele name not the signature, whether the class
comes from .java or .class.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.311
diff -u -p -r1.311 parse.y
--- parse.y	2001/09/14 22:58:37	1.311
+++ parse.y	2001/09/18 21:10:43
@@ -5689,6 +5689,22 @@ java_complete_class ()
   return;
 }
 
+/* FIXME MOVE TO ../stringpool.c */
+#include "hashtable.h"
+extern tree get_identifier2 (const char *, unsigned int);
+tree
+get_identifier2 (text, length)
+     const char *text;
+     unsigned int length;
+{
+  hashnode ht_node = ht_lookup (ident_hash,
+				(const unsigned char *) text,
+				length, HT_ALLOC);
+
+  /* ht_node can't be NULL here.  */
+  return HT_IDENT_TO_GCC_IDENT (ht_node);
+}
+
 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
    array.  */
 
@@ -5696,7 +5712,10 @@ static tree
 resolve_class (enclosing, class_type, decl, cl)
      tree enclosing, class_type, decl, cl;
 {
-  const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
+  tree tname = TYPE_NAME (class_type);
+  const char *name = IDENTIFIER_POINTER (tname);
+  int arrays = 0;
+  int namelen = IDENTIFIER_LENGTH (tname);
   const char *base = name;
   tree resolved_type = TREE_TYPE (class_type);
   tree resolved_type_decl;
@@ -5716,6 +5735,31 @@ resolve_class (enclosing, class_type, de
 
   /* 1- Check to see if we have an array. If true, find what we really
      want to resolve  */
+  while (namelen > 2 && name[namelen - 1] == ']')
+    {
+      namelen -= 2;
+      arrays++;
+    }
+  if (arrays > 0)
+    {
+      TYPE_NAME (class_type) = get_identifier2 (name, namelen);
+#if 0
+      if (cl != NULL_TREE && TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION)
+	{
+	  tree _node = EXPR_WFL_NODE (cl);
+	  const char *_ptr = IDENTIFIER_POINTER (_node);
+	  const char *_ref = _ptr;
+	  while (_ptr[0] == '[')
+	    _ptr++;
+	  if (_ref != _ptr)
+	    {
+	      cl = copy_node (cl);
+	      EXPR_WFL_NODE (_new) = get_identifier (_ptr);
+	      cl = _new;
+	    }			
+	}
+#endif
+    }
   while (name[0] == '[')
     name++;
   if (base != name)

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-01-05  3:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-20  0:06 java/4352: jc1 gets confused looking for array of local class Alexandre Petit-Bianco
  -- strict thread matches above, loose matches on Subject: below --
2002-01-04 19:19 rodrigc
2001-09-20 14:46 Richard Henderson
2001-09-20 14:10 apbianco
2001-09-19 13:46 Alexandre Petit-Bianco
2001-09-18 14:26 per

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).