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++) checks for valid templates


Now that random decls have DECL_LANG_SPECIFIC (was that intentional,
Mark?), the old check for invalid templates doesn't work.  So we check for
the valid forms.

1999-08-19  Jason Merrill  <jason@yorick.cygnus.com>

	* cp-tree.h: Declare flag_use_repository.
	* pt.c (do_decl_instantiation): Don't complain about duplicate
	instantiation with -frepo.
	(do_type_instantiation): Likewise.

	* pt.c (push_template_decl_real): Complain about everything
	that isn't a valid template.

Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.335
diff -c -p -r1.335 pt.c
*** pt.c	1999/08/19 08:06:15	1.335
--- pt.c	1999/08/19 21:11:30
*************** push_template_decl_real (decl, is_friend
*** 2424,2434 ****
        else if (TREE_CODE (decl) == TYPE_DECL 
  	       && ANON_AGGRNAME_P (DECL_NAME (decl))) 
  	cp_error ("template class without a name");
!       else if (TREE_CODE (decl) == TYPE_DECL 
! 	  && TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
! 	cp_error ("template declaration of `%#T'", TREE_TYPE (decl));
!       else if (TREE_CODE (decl) == VAR_DECL
! 	       && !CLASS_TYPE_P (CP_DECL_CONTEXT (decl)))
  	cp_error ("template declaration of `%#D'", decl);
      }
  
--- 2424,2435 ----
        else if (TREE_CODE (decl) == TYPE_DECL 
  	       && ANON_AGGRNAME_P (DECL_NAME (decl))) 
  	cp_error ("template class without a name");
!       else if ((DECL_IMPLICIT_TYPEDEF_P (decl)
! 		&& CLASS_TYPE_P (TREE_TYPE (decl)))
! 	       || (TREE_CODE (decl) == VAR_DECL && ctx && CLASS_TYPE_P (ctx))
! 	       || TREE_CODE (decl) == FUNCTION_DECL)
! 	/* OK */;
!       else
  	cp_error ("template declaration of `%#D'", decl);
      }
  
*************** push_template_decl_real (decl, is_friend
*** 2582,2590 ****
  	  && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE)
  	DECL_NAME (decl) = classtype_mangled_name (TREE_TYPE (decl));
      }
!   else if (! DECL_LANG_SPECIFIC (decl))
!     cp_error ("template declaration of `%#D'", decl);
!   else
      DECL_TEMPLATE_INFO (decl) = info;
  
    return DECL_TEMPLATE_RESULT (tmpl);
--- 2583,2589 ----
  	  && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE)
  	DECL_NAME (decl) = classtype_mangled_name (TREE_TYPE (decl));
      }
!   else if (DECL_LANG_SPECIFIC (decl))
      DECL_TEMPLATE_INFO (decl) = info;
  
    return DECL_TEMPLATE_RESULT (tmpl);

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