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]

(C++) patch for bogus ambiguity error


Fixes g++.other/lookup11.C.  We can't really give any errors in lookup_name
when we're parsing, because the name might be used as a declarator.

1999-03-25  Jason Merrill  <jason@yorick.cygnus.com>

	* decl.c (unqualified_namespace_lookup): Return error_mark_node
	on error.
	(lookup_name_real): Set LOOKUP_COMPLAIN when *not* parsing.
	* lex.c (do_identifier): If we got error_mark_node, call
	lookup_name again.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.329
diff -c -p -r1.329 decl.c
*** decl.c	1999/03/24 02:41:55	1.329
--- decl.c	1999/03/25 10:45:21
*************** unqualified_namespace_lookup (name, flag
*** 5291,5297 ****
  	if (!lookup_using_namespace (name, b, level->using_directives,
                                       scope, flags))
  	  /* Give up because of error. */
! 	  return NULL_TREE;
  
        /* Add all _DECLs seen through global using-directives. */
        /* XXX local and global using lists should work equally. */
--- 5291,5297 ----
  	if (!lookup_using_namespace (name, b, level->using_directives,
                                       scope, flags))
  	  /* Give up because of error. */
! 	  return error_mark_node;
  
        /* Add all _DECLs seen through global using-directives. */
        /* XXX local and global using lists should work equally. */
*************** unqualified_namespace_lookup (name, flag
*** 5301,5307 ****
  	  if (!lookup_using_namespace (name, b, DECL_NAMESPACE_USING (siter), 
  				       scope, flags))
  	    /* Give up because of error. */
! 	    return NULL_TREE;
  	  if (siter == scope) break;
  	  siter = CP_DECL_CONTEXT (siter);
  	}
--- 5301,5307 ----
  	  if (!lookup_using_namespace (name, b, DECL_NAMESPACE_USING (siter), 
  				       scope, flags))
  	    /* Give up because of error. */
! 	    return error_mark_node;
  	  if (siter == scope) break;
  	  siter = CP_DECL_CONTEXT (siter);
  	}
*************** lookup_name_real (name, prefer_type, non
*** 5388,5395 ****
        prefer_type = looking_for_typename;
  
        flags = lookup_flags (prefer_type, namespaces_only);
-       /* During parsing, we need to complain. */
-       flags |= LOOKUP_COMPLAIN;
        /* If the next thing is '<', class templates are types. */
        if (looking_for_template)
          flags |= LOOKUP_TEMPLATES_EXPECTED;
--- 5388,5393 ----
*************** lookup_name_real (name, prefer_type, non
*** 5463,5469 ****
  	from_obj = val;
      }
    else
!     flags = lookup_flags (prefer_type, namespaces_only);
  
    /* First, look in non-namespace scopes.  */
    for (val = IDENTIFIER_BINDING (name); val; val = TREE_CHAIN (val))
--- 5461,5471 ----
  	from_obj = val;
      }
    else
!     {
!       flags = lookup_flags (prefer_type, namespaces_only);
!       /* If we're not parsing, we need to complain. */
!       flags |= LOOKUP_COMPLAIN;
!     }
  
    /* First, look in non-namespace scopes.  */
    for (val = IDENTIFIER_BINDING (name); val; val = TREE_CHAIN (val))
Index: lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.103
diff -c -p -r1.103 lex.c
*** lex.c	1999/03/15 19:07:25	1.103
--- lex.c	1999/03/25 10:45:21
*************** do_identifier (token, parsing, args)
*** 2935,2941 ****
       expressions instead).  */
    if (args && !current_template_parms && (!id || is_global (id)))
      /* If we have arguments and we only found global names, do Koenig
!          lookup. */
      id = lookup_arg_dependent (token, id, args);
  
    /* Remember that this name has been used in the class definition, as per
--- 2935,2941 ----
       expressions instead).  */
    if (args && !current_template_parms && (!id || is_global (id)))
      /* If we have arguments and we only found global names, do Koenig
!        lookup. */
      id = lookup_arg_dependent (token, id, args);
  
    /* Remember that this name has been used in the class definition, as per
*************** do_identifier (token, parsing, args)
*** 2949,2966 ****
  	 after the class is complete.  (jason 3/12/97) */
        && TREE_CODE (id) != OVERLOAD)
      pushdecl_class_level (id);
-     
-   if (!id || id == error_mark_node)
-     {
-       if (id == error_mark_node && current_class_type != NULL_TREE)
- 	{
- 	  id = lookup_nested_field (token, 1);
- 	  /* In lookup_nested_field(), we marked this so we can gracefully
- 	     leave this whole mess.  */
- 	  if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node)
- 	    return id;
- 	}
  
        if (current_template_parms)
  	return build_min_nt (LOOKUP_EXPR, token);
        else if (IDENTIFIER_OPNAME_P (token))
--- 2949,2967 ----
  	 after the class is complete.  (jason 3/12/97) */
        && TREE_CODE (id) != OVERLOAD)
      pushdecl_class_level (id);
  
+   if (id == error_mark_node)
+     {
+       /* lookup_name quietly returns error_mark_node if we're parsing,
+ 	 as we don't want to complain about an identifier that ends up
+ 	 being used as a declarator.  So we call it again to get the error
+ 	 message.  */
+       id = lookup_name (token, 0);
+       return error_mark_node;
+     }
+       
+   if (!id)
+     {
        if (current_template_parms)
  	return build_min_nt (LOOKUP_EXPR, token);
        else if (IDENTIFIER_OPNAME_P (token))


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