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 to lookup_name_real


Installed.  Any other decl should suppress an implicit typename.

1998-10-03  Jason Merrill  <jason@yorick.cygnus.com>

	* decl.c (lookup_name_real): Template parms also take precedence
	over implicit typename.  Only warn if yylex.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.218
diff -c -p -r1.218 decl.c
*** decl.c	1998/10/01 10:44:46	1.218
--- decl.c	1998/10/04 05:51:57
*************** lookup_name_real (name, prefer_type, non
*** 5167,5191 ****
    else
      val = unqualified_namespace_lookup (name, flags);
  
    if (classval && TREE_CODE (val) == TYPE_DECL
        && TREE_CODE (TREE_TYPE (val)) == TYPENAME_TYPE
        && TREE_TYPE (TREE_TYPE (val)))
      {
!       tree nsval = unqualified_namespace_lookup (name, flags);
  
!       if (val && nsval && TREE_CODE (nsval) == TYPE_DECL)
  	{
! 	  static int explained;
! 	  cp_warning ("namespace-scope type `%#D'", nsval);
! 	  cp_warning
! 	    ("  is used instead of `%D' from dependent base class", val);
! 	  if (! explained)
  	    {
! 	      explained = 1;
! 	      cp_warning ("  (use `typename %D' if that's what you meant)",
! 			  val);
  	    }
- 	  val = nsval;
  	}
      }
  
--- 5167,5209 ----
    else
      val = unqualified_namespace_lookup (name, flags);
  
+   /* Any other name takes precedence over an implicit typename.  Warn the
+      user about this potentially confusing lookup.  */
    if (classval && TREE_CODE (val) == TYPE_DECL
        && TREE_CODE (TREE_TYPE (val)) == TYPENAME_TYPE
        && TREE_TYPE (TREE_TYPE (val)))
      {
!       if (locval == NULL_TREE)
! 	locval = unqualified_namespace_lookup (name, flags);
  
!       if (locval && val != locval)
  	{
! 	  tree subtype;
! 
! 	  val = locval;
! 
! 	  /* To avoid redundant warnings, only warn when lexing, and the
! 	     decls are significantly different.  */
! 	  subtype = TREE_TYPE (TREE_TYPE (classval));
! 	  if (yylex
! 	      && ! (TREE_CODE (locval) == TEMPLATE_DECL
! 		    && CLASSTYPE_TEMPLATE_INFO (subtype)
! 		    && CLASSTYPE_TI_TEMPLATE (subtype) == locval)
! 	      && ! (TREE_CODE (locval) == TYPE_DECL
! 		    && comptypes (TREE_TYPE (locval), subtype, 1)))
  	    {
! 	      static int explained;
! 
! 	      cp_warning ("lookup of `%D' finds `%#D'", name, locval);
! 	      cp_warning
! 		("  instead of `%D' from dependent base class", classval);
! 	      if (! explained)
! 		{
! 		  explained = 1;
! 		  cp_warning ("  (use `typename %D' if that's what you meant)",
! 			      classval);
! 		}
  	    }
  	}
      }
  


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