This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[hjl@lucon.org: Re: c++/5577 (was: Re: c++/4862 and PRs...)]


I am sending this just for a record in the gcc mailing list archive
since my last mail was not archived.


H.J.
----- Forwarded message from "H . J . Lu" <hjl@lucon.org> -----

Date: Sun, 3 Feb 2002 01:09:24 -0800
From: "H . J . Lu" <hjl@lucon.org>
To: Paolo Carlini <pcarlini@unitus.it>
Cc: gcc@gcc.gnu.org
Subject: Re: c++/5577 (was: Re: c++/4862 and PRs...)
User-Agent: Mutt/1.2.5i

On Sat, Feb 02, 2002 at 09:55:19PM +0100, Paolo Carlini wrote:
> "H . J . Lu" wrote:
> 
> > > How about c++/5577?? Does it fix this one too?? In that case it would be really nice
> > > to have it for 3.1 too...
> >
> > No, my patch doesn't fix 5577. It has been long time since I worked
> > on it last time. I don't have time to look into it. I am not sure if
> > they are related. Besides, my users haven't been bitten by it yet.
> 
> I see.
> c++/5777 seems quite nasty, even the new parser for the time being chokes on it :-(
> (not EDG ;-)
> 

Well, I have no idea what I am doing. But this patch seems to make gcc
to compile c++/5777 :-). But I don't know if it generates the correct
code or not.



H.J.
----
2002-02-03  H.J. Lu  (hjl@gnu.org)

	* gcc/cp/decl.c (lookup_name_real): Handle prefer_type == 3.

	* parse.y (object): Handle LOOKUP_EXPR and COMPONENT_REF.

--- gcc/cp/decl.c.template	Fri Feb  1 15:22:12 2002
+++ gcc/cp/decl.c	Fri Feb  1 16:39:39 2002
@@ -6067,6 +6067,8 @@ lookup_name_real (name, prefer_type, non
       else if ((flags & LOOKUP_PREFER_TYPES)
 	       && qualify_lookup (BINDING_TYPE (t), flags))
 	binding = BINDING_TYPE (t);
+      else if (prefer_type == 3)
+	binding = BINDING_VALUE (t);
       else
 	binding = NULL_TREE;
 
--- gcc/cp/parse.y.template	Fri Feb  1 15:22:13 2002
+++ gcc/cp/parse.y	Sun Feb  3 00:44:13 2002
@@ -1779,11 +1779,79 @@ nodecls:
 
 object:
 	  primary '.'
-		{ got_object = TREE_TYPE ($$); }
+		{
+		  tree name;
+		  got_object = TREE_TYPE ($$);
+		  name = $$;
+		  while (TREE_CODE (name) == ADDR_EXPR
+			 || TREE_CODE (name) == INDIRECT_REF
+			 || TREE_CODE (name) == COMPONENT_REF)
+		    if (TREE_CODE (name) == COMPONENT_REF)
+		      name = TREE_OPERAND (name, 1);
+		    else
+		      name = TREE_OPERAND (name, 0);
+		  if (got_object == NULL_TREE
+		      && (TREE_CODE (name) == LOOKUP_EXPR
+			  || TREE_CODE (name) == IDENTIFIER_NODE))
+		    {
+		      if (TREE_CODE (name) == LOOKUP_EXPR)
+			name = TREE_OPERAND (name, 0);
+		      name = lookup_name (name, 3);
+		      if (name)
+			{
+			  got_object = TREE_TYPE (name);
+			  if (got_object)
+			    {
+			      switch (TREE_CODE (got_object))
+			        {
+				case POINTER_TYPE:
+				case REFERENCE_TYPE:
+				  got_object = TREE_TYPE (got_object);
+				  break;
+				default:
+				  break;
+				}
+			    }
+			}
+		    }
+		}
 	| primary POINTSAT
 		{
+		  tree name;
+		  name = $$;
+		  while (TREE_CODE (name) == ADDR_EXPR
+			 || TREE_CODE (name) == INDIRECT_REF
+			 || TREE_CODE (name) == COMPONENT_REF)
+		    if (TREE_CODE (name) == COMPONENT_REF)
+		      name = TREE_OPERAND (name, 1);
+		    else
+		      name = TREE_OPERAND (name, 0);
 		  $$ = build_x_arrow ($$); 
 		  got_object = TREE_TYPE ($$);
+		  if (got_object == NULL_TREE
+		      && (TREE_CODE (name) == LOOKUP_EXPR
+			  || TREE_CODE (name) == IDENTIFIER_NODE))
+		    {
+		      if (TREE_CODE (name) == LOOKUP_EXPR)
+			name = TREE_OPERAND (name, 0);
+		      name = lookup_name (name, 3);
+		      if (name)
+			{
+			  got_object = TREE_TYPE (name);
+			  if (got_object)
+			    {
+			      switch (TREE_CODE (got_object))
+			        {
+				case POINTER_TYPE:
+				case REFERENCE_TYPE:
+				  got_object = TREE_TYPE (got_object);
+				  break;
+				default:
+				  break;
+				}
+			    }
+			}
+		    }
 		}
 	;
 

----- End forwarded message -----


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