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]

Re: [C++ Patch] PR 30659


... so I think a more correct fix is the below, which uses
CP_DECL_CONTEXT. In fact, DECL_CONTEXT is documented as being NULL_TREE
in case of global namespace. Also, I checked that the crash would not
happen for the same broken declaration inside an user defined namespace.

Tested x86_64-linux. Ok?

Paolo.

//////////////////
cp/
2007-10-28  Paolo Carlini  <pcarlini@suse.de>

	PR c++/30659
	* pt.c (do_decl_instantiation): Use CP_DECL_CONTEXT.

testsuite/
2007-10-28  Paolo Carlini  <pcarlini@suse.de>

	PR c++/30659
	* g++.dg/template/crash71.C: New.
Index: testsuite/g++.dg/template/crash71.C
===================================================================
*** testsuite/g++.dg/template/crash71.C	(revision 0)
--- testsuite/g++.dg/template/crash71.C	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/30659
+ 
+ extern "C" template A<char> foo(); // { dg-error "forbids|template|expected" }
Index: cp/pt.c
===================================================================
*** cp/pt.c	(revision 129697)
--- cp/pt.c	(working copy)
*************** do_decl_instantiation (tree decl, tree s
*** 13882,13888 ****
  	 VAR_DECLs so we do the lookup here.  Probably, grokdeclarator
  	 should handle VAR_DECLs as it currently handles
  	 FUNCTION_DECLs.  */
!       result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
        if (!result || TREE_CODE (result) != VAR_DECL)
  	{
  	  error ("no matching template for %qD found", decl);
--- 13882,13889 ----
  	 VAR_DECLs so we do the lookup here.  Probably, grokdeclarator
  	 should handle VAR_DECLs as it currently handles
  	 FUNCTION_DECLs.  */
!       result = lookup_field (CP_DECL_CONTEXT (decl), DECL_NAME (decl),
! 			     0, false);
        if (!result || TREE_CODE (result) != VAR_DECL)
  	{
  	  error ("no matching template for %qD found", decl);

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