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]

[C++] Fix 17821


This patch fixes 17821, a reject legal regression.  There is no need to push a
conversion operator into the current binding level, as they are never searched
for by name.

I also tidied up a couple of places that had been bugging me.

booted & tested on i686-pc-linux-gnu.
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.695
diff -c -3 -p -r1.695 class.c
*** cp/class.c	16 Dec 2004 11:03:13 -0000	1.695
--- cp/class.c	17 Dec 2004 12:10:58 -0000
*************** add_method (tree type, tree method)
*** 857,863 ****
    int using;
    unsigned slot;
    tree overload;
!   int template_conv_p;
    VEC(tree) *method_vec;
    bool complete_p;
    bool insert_p = false;
--- 857,864 ----
    int using;
    unsigned slot;
    tree overload;
!   bool template_conv_p = false;
!   bool conv_p;
    VEC(tree) *method_vec;
    bool complete_p;
    bool insert_p = false;
*************** add_method (tree type, tree method)
*** 868,875 ****
  
    complete_p = COMPLETE_TYPE_P (type);
    using = (DECL_CONTEXT (method) != type);
!   template_conv_p = (TREE_CODE (method) == TEMPLATE_DECL
!                      && DECL_TEMPLATE_CONV_FN_P (method));
  
    method_vec = CLASSTYPE_METHOD_VEC (type);
    if (!method_vec)
--- 869,878 ----
  
    complete_p = COMPLETE_TYPE_P (type);
    using = (DECL_CONTEXT (method) != type);
!   conv_p = DECL_CONV_FN_P (method);
!   if (conv_p)
!     template_conv_p = (TREE_CODE (method) == TEMPLATE_DECL
! 		       && DECL_TEMPLATE_CONV_FN_P (method));
  
    method_vec = CLASSTYPE_METHOD_VEC (type);
    if (!method_vec)
*************** add_method (tree type, tree method)
*** 901,907 ****
      }
    else
      {
-       bool conv_p = DECL_CONV_FN_P (method);
        tree m;
  
        insert_p = true;
--- 904,909 ----
*************** add_method (tree type, tree method)
*** 1012,1018 ****
    /* Add the new binding.  */ 
    overload = build_overload (method, current_fns);
    
!   if (slot >= CLASSTYPE_FIRST_CONVERSION_SLOT && !complete_p)
      push_class_level_binding (DECL_NAME (method), overload);
  
    if (insert_p)
--- 1014,1020 ----
    /* Add the new binding.  */ 
    overload = build_overload (method, current_fns);
    
!   if (!conv_p && slot >= CLASSTYPE_FIRST_CONVERSION_SLOT && !complete_p)
      push_class_level_binding (DECL_NAME (method), overload);
  
    if (insert_p)
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1081
diff -c -3 -p -r1.1081 cp-tree.h
*** cp/cp-tree.h	16 Dec 2004 11:03:17 -0000	1.1081
--- cp/cp-tree.h	17 Dec 2004 12:11:10 -0000
*************** struct lang_decl GTY(())
*** 2192,2201 ****
  
  /* For a template instantiation TYPE, returns the TYPE corresponding
     to the primary template.  Otherwise returns TYPE itself.  */
! #define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE)						\
!   ((CLASSTYPE_USE_TEMPLATE ((TYPE)) && !CLASSTYPE_TEMPLATE_SPECIALIZATION ((TYPE)))	\
!    ? TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE				\
! 				      (CLASSTYPE_TI_TEMPLATE ((TYPE)))))		\
     : (TYPE))
  
  /* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
--- 2193,2203 ----
  
  /* For a template instantiation TYPE, returns the TYPE corresponding
     to the primary template.  Otherwise returns TYPE itself.  */
! #define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE)				\
!   ((CLASSTYPE_USE_TEMPLATE ((TYPE))					\
!     && !CLASSTYPE_TEMPLATE_SPECIALIZATION ((TYPE)))			\
!    ? TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE		\
! 				      (CLASSTYPE_TI_TEMPLATE ((TYPE))))) \
     : (TYPE))
  
  /* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.273
diff -c -3 -p -r1.273 error.c
*** cp/error.c	29 Nov 2004 20:10:11 -0000	1.273
--- cp/error.c	17 Dec 2004 12:11:38 -0000
*************** dump_decl (tree t, int flags)
*** 713,731 ****
    switch (TREE_CODE (t))
      {
      case TYPE_DECL:
!       {
! 	/* Don't say 'typedef class A' */
!         if (DECL_ARTIFICIAL (t))
! 	  {
! 	    if ((flags & TFF_DECL_SPECIFIERS)
! 	        && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
! 	      /* Say `class T' not just `T'.  */
! 	      pp_cxx_identifier (cxx_pp, "class");
! 
! 	    dump_type (TREE_TYPE (t), flags);
! 	    break;
! 	  }
!       }
        if (flags & TFF_DECL_SPECIFIERS)
  	pp_cxx_identifier (cxx_pp, "typedef");
        dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
--- 713,729 ----
    switch (TREE_CODE (t))
      {
      case TYPE_DECL:
!       /* Don't say 'typedef class A' */
!       if (DECL_ARTIFICIAL (t))
! 	{
! 	  if ((flags & TFF_DECL_SPECIFIERS)
! 	      && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
! 	    /* Say `class T' not just `T'.  */
! 	    pp_cxx_identifier (cxx_pp, "class");
! 	  
! 	  dump_type (TREE_TYPE (t), flags);
! 	  break;
! 	}
        if (flags & TFF_DECL_SPECIFIERS)
  	pp_cxx_identifier (cxx_pp, "typedef");
        dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
// { dg-do compile }

// Copyright (C) 2004 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 17 Dec 2004 <nathan@codesourcery.com>

// PR 17821. bogus error
// Origin:  Mikael Kilpel?inen <belz@kolumbus.fi>

struct A {
  template<typename T>
  operator T() const;
  
  operator float() const;
};


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